2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Pass update mentions to the event handler

This commit is contained in:
Dan 2018-02-10 16:30:13 +01:00
parent 0b15cb9867
commit a6fce057c7

View File

@ -274,36 +274,30 @@ class Client:
self.fetch_peers(update.chats) self.fetch_peers(update.chats)
for i in update.updates: for i in update.updates:
self.event_queue.put(i) self.event_queue.put((i, update.users, update.chats))
elif isinstance(update, types.UpdateShortMessage): elif isinstance(update, (types.UpdateShortMessage, types.UpdateShortChatMessage)):
if update.user_id not in self.peers_by_id: diff = self.send(
diff = self.send( functions.updates.GetDifference(
functions.updates.GetDifference( pts=update.pts - update.pts_count,
pts=update.pts - 1, date=update.date,
date=update.date, qts=-1
qts=-1
)
) )
)
self.fetch_peers(diff.users) self.fetch_peers(diff.users)
self.fetch_peers(diff.chats)
self.event_queue.put(update) self.event_queue.put((
elif isinstance(update, types.UpdateShortChatMessage): types.UpdateNewMessage(
if update.chat_id not in self.peers_by_id: message=diff.new_messages[0],
diff = self.send( pts=update.pts,
functions.updates.GetDifference( pts_count=update.pts_count
pts=update.pts - 1, ),
date=update.date, diff.users,
qts=-1 diff.chats
) ))
)
self.fetch_peers(diff.users)
self.fetch_peers(diff.chats)
self.event_queue.put(update)
elif isinstance(update, types.UpdateShort): elif isinstance(update, types.UpdateShort):
self.event_queue.put(update.update) self.event_queue.put((update.update, [], []))
except Exception as e: except Exception as e:
log.error(e, exc_info=True) log.error(e, exc_info=True)
@ -321,7 +315,12 @@ class Client:
try: try:
if self.event_handler: if self.event_handler:
self.event_handler(self, event) self.event_handler(
self,
event[0],
{i.id: i for i in event[1]},
{i.id: i for i in event[2]}
)
except Exception as e: except Exception as e:
log.error(e, exc_info=True) log.error(e, exc_info=True)