mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 03:22:29 +00:00
Factor out setting entities to events
This commit is contained in:
@@ -47,18 +47,13 @@ class CallbackQuery(EventBuilder):
|
||||
@classmethod
|
||||
def build(cls, update):
|
||||
if isinstance(update, types.UpdateBotCallbackQuery):
|
||||
event = cls.Event(update, update.peer, update.msg_id)
|
||||
return cls.Event(update, update.peer, update.msg_id)
|
||||
elif isinstance(update, types.UpdateInlineBotCallbackQuery):
|
||||
# See https://github.com/LonamiWebs/Telethon/pull/1005
|
||||
# The long message ID is actually just msg_id + peer_id
|
||||
mid, pid = struct.unpack('<ii', struct.pack('<q', update.msg_id.id))
|
||||
peer = types.PeerChannel(-pid) if pid < 0 else types.PeerUser(pid)
|
||||
event = cls.Event(update, peer, mid)
|
||||
else:
|
||||
return
|
||||
|
||||
event._entities = update._entities
|
||||
return event
|
||||
return cls.Event(update, peer, mid)
|
||||
|
||||
def filter(self, event):
|
||||
# We can't call super().filter(...) because it ignores chat_instance
|
||||
|
Reference in New Issue
Block a user