UNTESTED: GROUP CHATS ;; add handlers for member join/leave and name changes
This commit is contained in:
parent
0823b72acc
commit
f251d67c32
1 changed files with 24 additions and 7 deletions
31
external/messenger.py
vendored
31
external/messenger.py
vendored
|
@ -389,7 +389,7 @@ class MessengerBridge:
|
|||
"room": room,
|
||||
}
|
||||
})
|
||||
self.joined_map[key] = true
|
||||
self.joined_map[key] = True
|
||||
|
||||
def onMessage(self, thread_id, thread_type, message_object, **kwargs):
|
||||
if message_object.author == self.client.uid:
|
||||
|
@ -443,12 +443,29 @@ class MessengerBridge:
|
|||
|
||||
self.cache_put("last_seen_%s"%thread_id, message_object.uid)
|
||||
|
||||
def onPeopleAdded(self, *args, **kwargs):
|
||||
pass
|
||||
def onPersonRemoved(self, *args, **kwargs):
|
||||
pass
|
||||
def onTitleChange(self, *args, **kwargs):
|
||||
pass
|
||||
def onPeopleAdded(self, added_ids, thread_id, *args, **kwargs):
|
||||
for user_id in added_ids:
|
||||
self.ensureJoined(self.getUserIdFromUid(user_id), thread_id)
|
||||
|
||||
def onPersonRemoved(self, removed_id, thread_id, *args, **kwargs):
|
||||
userId = self.getUserIdFromUid(removed_id),
|
||||
self.write({
|
||||
"_type": EVENT,
|
||||
"data": {
|
||||
"type": EVENT_JOIN,
|
||||
"author": userId,
|
||||
"room": thread_id,
|
||||
}
|
||||
})
|
||||
del self.joined_map["{}--{}".format(userId, thread_id)]
|
||||
|
||||
def onTitleChange(self, author_id, new_title, thread_id, thread_type, *args, **kwargs):
|
||||
if thread_type == ThreadType.GROUP:
|
||||
self.bridge.write({
|
||||
"_type": ROOM_INFO_UPDATED,
|
||||
"room": thread_id,
|
||||
"data": {"name": new_title},
|
||||
})
|
||||
|
||||
if __name__ == "__main__":
|
||||
bridge = MessengerBridge()
|
||||
|
|
Loading…
Reference in a new issue