diff --git a/bot/account.py b/bot/account.py index 74e3250..255f51d 100644 --- a/bot/account.py +++ b/bot/account.py @@ -365,7 +365,15 @@ class Account: {"type": "contact", "id": contact["chat_id"], "name": contact["display_name"]} for contact in self.contacts.values() ] - return contacts + communities + + # Group chats in RPC endpoint are chat type 3 + data = self.__call_rpc("messaging", "activeChats") + group_chats = [ + {"type": "group_chat", "id": active_chat["id"], "name": active_chat["name"]} + for active_chat in data.get("result", []) + if active_chat["chatType"] == 3 + ] + return contacts + communities + group_chats def send_message(self, chat_id: str, message: str): """ diff --git a/bot/docs/account.md b/bot/docs/account.md index 2fc0950..e1b4df6 100644 --- a/bot/docs/account.md +++ b/bot/docs/account.md @@ -496,12 +496,13 @@ for community in account.communities: Get all chats that the account can **send messages to**. This includes: - [`contacts`](./account.md#contacts) — direct messages with users - [`communities`](./account.md#communities) — community channels where the account has **posting permission** +- Group chats that the account is in Returns `list[dict]` where each `dict` represents a chat that can be used with [`send_message`](./account.md#send_messagechat_id-message) and [`get_messages`](./account.md#get_messageschat_id-start_timestampnone-end_timestampnone). | Key | Type | Description | |----|----|-------------| -| `type` | `str` | Type of chat (`contact` or `channel`). | +| `type` | `str` | Type of chat (`contact`, `channel` or `group_chat`). | | `id` | `str` | Chat identifier used when sending messages. | | `name` | `str` | Either the display name of the user or the community channel name. |