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,
|
"room": room,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.joined_map[key] = true
|
self.joined_map[key] = True
|
||||||
|
|
||||||
def onMessage(self, thread_id, thread_type, message_object, **kwargs):
|
def onMessage(self, thread_id, thread_type, message_object, **kwargs):
|
||||||
if message_object.author == self.client.uid:
|
if message_object.author == self.client.uid:
|
||||||
|
@ -443,12 +443,29 @@ class MessengerBridge:
|
||||||
|
|
||||||
self.cache_put("last_seen_%s"%thread_id, message_object.uid)
|
self.cache_put("last_seen_%s"%thread_id, message_object.uid)
|
||||||
|
|
||||||
def onPeopleAdded(self, *args, **kwargs):
|
def onPeopleAdded(self, added_ids, thread_id, *args, **kwargs):
|
||||||
pass
|
for user_id in added_ids:
|
||||||
def onPersonRemoved(self, *args, **kwargs):
|
self.ensureJoined(self.getUserIdFromUid(user_id), thread_id)
|
||||||
pass
|
|
||||||
def onTitleChange(self, *args, **kwargs):
|
def onPersonRemoved(self, removed_id, thread_id, *args, **kwargs):
|
||||||
pass
|
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__":
|
if __name__ == "__main__":
|
||||||
bridge = MessengerBridge()
|
bridge = MessengerBridge()
|
||||||
|
|
Loading…
Reference in a new issue