CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-rocketchat-a-p-i

Python API wrapper for Rocket.Chat's REST API, enabling developers to programmatically interact with Rocket.Chat servers for chat automation, bot development, and integration purposes

Pending
Overview
Eval results
Files

subscriptions.mddocs/

Subscriptions

User subscription management for tracking user relationships with rooms, including read status, notifications, and room-specific user settings.

Capabilities

Subscription Information

def subscriptions_get(self, **kwargs):
    """
    Get user's subscriptions to rooms.
    
    Parameters:
    - updatedSince (str, optional): ISO date string to get subscriptions updated since
    
    Returns:
    requests.Response: List of user's room subscriptions
    """

def subscriptions_get_one(self, room_id, **kwargs):
    """
    Get subscription information for a specific room.
    
    Parameters:
    - room_id (str): Room ID
    
    Returns:
    requests.Response: Room subscription details
    """

Read Status Management

def subscriptions_read(self, rid, **kwargs):
    """
    Mark a room as read.
    
    Parameters:
    - rid (str): Room ID
    
    Returns:
    requests.Response: Read status update result
    """

def subscriptions_unread(self, room_id, **kwargs):
    """
    Mark a room as unread.
    
    Parameters:
    - room_id (str): Room ID
    - firstUnreadMessage (str, optional): First unread message ID
    
    Returns:
    requests.Response: Unread status update result
    """

Subscription Object Structure

SubscriptionObject = {
    "_id": "str",              # Subscription ID
    "u": {                     # User info
        "_id": "str",
        "username": "str",
        "name": "str"
    },
    "rid": "str",              # Room ID
    "name": "str",             # Room name
    "t": "str",                # Room type (c, p, d, l)
    "ts": "datetime",          # Subscription timestamp
    "ls": "datetime",          # Last seen timestamp
    "f": "bool",               # Favorite status
    "open": "bool",            # Open for user
    "alert": "bool",           # Has alerts
    "unread": "int",           # Unread count
    "userMentions": "int",     # User mention count
    "groupMentions": "int",    # Group mention count
    "roles": ["str"],          # User roles in room
    "disableNotifications": "bool",  # Notifications disabled
    "muteGroupMentions": "bool",     # Group mentions muted
    "hideUnreadStatus": "bool",      # Hide unread status
    "desktopNotifications": "str",   # Desktop notification setting
    "mobilePushNotifications": "str", # Mobile notification setting
    "emailNotifications": "str",     # Email notification setting
    "audioNotifications": "str",     # Audio notification setting
    "_updatedAt": "datetime"         # Last update timestamp
}

Usage Examples

# Get all user subscriptions
subs = rocket.subscriptions_get()
subscriptions = subs.json()['subscriptions']
print(f"User is subscribed to {len(subscriptions)} rooms")

# Find specific subscription
general_sub = None
for sub in subscriptions:
    if sub['name'] == 'general':
        general_sub = sub
        break

if general_sub:
    print(f"General channel has {general_sub['unread']} unread messages")
    print(f"User mentions: {general_sub['userMentions']}")

# Get single subscription
room_id = 'GENERAL'
sub_info = rocket.subscriptions_get_one(room_id)
subscription = sub_info.json()['subscription']

# Mark room as read
rocket.subscriptions_read(room_id)
print(f"Marked room {room_id} as read")

# Mark room as unread
rocket.subscriptions_unread(room_id)
print(f"Marked room {room_id} as unread")

# Get recently updated subscriptions
from datetime import datetime, timedelta
yesterday = (datetime.now() - timedelta(days=1)).isoformat() + 'Z'
recent_subs = rocket.subscriptions_get(updatedSince=yesterday)

print(f"Subscriptions updated since yesterday: {len(recent_subs.json()['subscriptions'])}")

Install with Tessl CLI

npx tessl i tessl/pypi-rocketchat-a-p-i

docs

administration.md

assets.md

channels.md

chat.md

direct-messages.md

groups.md

index.md

integrations.md

livechat.md

miscellaneous.md

permissions.md

roles.md

rooms.md

settings.md

statistics.md

subscriptions.md

teams.md

users.md

tile.json