account: add group chats support

Related to https://github.com/status-im/status-bot/issues/8
This commit is contained in:
Nick Ninov
2026-03-14 20:19:35 +00:00
parent 6106e2f69a
commit 2b2d5c0a1d
2 changed files with 11 additions and 2 deletions
+9 -1
View File
@@ -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):
"""
+2 -1
View File
@@ -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. |