Skip to content

Commit 9846510

Browse files
authored
fix: handle bot join messages properly to get conversation id and name (#385)
Changes proposed in this pull request: * handle bot join messages properly to get conversation id and name bot join message: ```py {'type': 'Join', 'actor': {'type': 'Application', 'id': 'bots/bot-8fbab44b3648e53e2252d262ab600532a4232ee8', 'name': 'SummaryBot'}, 'object': {'type': 'Collection', 'id': 'x8w9eukg', 'name': 'summary test'}, '_route': 'ocs.app_api.talkbot.proxytalkmessage', 'appId': 'summary_bot', 'route': 'summary_bot'} ``` user join message: ```py {'type': 'Activity', 'actor': {'type': 'Person', 'id': 'users/bob', 'name': 'bob'}, 'object': {'type': 'Note', 'id': '401', 'name': 'user_added', 'content': '{"message":"{actor} joined the conversation","parameters":{"actor":{"type":"user","id":"bob","name":"bob","mention-id":"bob"},"user":{"type":"user","id":"bob","name":"bob","mention-id":"bob"}}}', 'mediaType': 'text/markdown'}, 'target': {'type': 'Collection', 'id': 'x8w9eukg', 'name': 'summary test'}, '_route': 'ocs.app_api.talkbot.proxytalkmessage', 'appId': 'summary_bot', 'route': 'summary_bot'} ``` Signed-off-by: Anupam Kumar <[email protected]>
1 parent 7a374e5 commit 9846510

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

nc_py_api/talk_bot.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,17 @@ def conversation_token(self) -> str:
7676
7777
It can be used to react or reply to the given message.
7878
"""
79+
# bot join
80+
if self.message_type == "Join":
81+
return self._raw_data["object"]["id"]
7982
return self._raw_data["target"]["id"]
8083

8184
@property
8285
def conversation_name(self) -> str:
8386
"""The name of the conversation in which the message was posted."""
87+
# bot join
88+
if self.message_type == "Join":
89+
return self._raw_data["object"]["name"]
8490
return self._raw_data["target"]["name"]
8591

8692
def __repr__(self):

0 commit comments

Comments
 (0)