mirror of
https://github.com/status-im/status-python-sdk.git
synced 2026-08-30 21:51:14 +00:00
account: add group chats support
Related to https://github.com/status-im/status-bot/issues/8
This commit is contained in:
+9
-1
@@ -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
@@ -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. |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user