Factor out setting entities to events

This commit is contained in:
Lonami Exo
2019-06-30 13:23:18 +02:00
parent 8c771a842f
commit aa2b3daccc
11 changed files with 69 additions and 100 deletions

View File

@@ -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