diff --git a/telethon/_client/updates.py b/telethon/_client/updates.py index 71a3e7e8..5f30fbd8 100644 --- a/telethon/_client/updates.py +++ b/telethon/_client/updates.py @@ -444,9 +444,10 @@ class EventBuilderDict: return self.__dict__[builder] except KeyError: event = self.__dict__[builder] = builder.build( - self.update, self.others, self.client._session_state.user_id) + self.update, self.others, self.client._session_state.user_id, self.entities or {}, self.client) if isinstance(event, EventCommon): + # TODO eww event.original_update = self.update event._entities = self.entities or {} event._set_client(self.client) diff --git a/telethon/_events/album.py b/telethon/_events/album.py index d8dacb98..cb9c39a8 100644 --- a/telethon/_events/album.py +++ b/telethon/_events/album.py @@ -96,7 +96,7 @@ class Album(EventBuilder): super().__init__(chats, blacklist_chats=blacklist_chats, func=func) @classmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others=None, self_id=None, *todo, **todo2): if not others: return # We only care about albums which come inside the same Updates diff --git a/telethon/_events/callbackquery.py b/telethon/_events/callbackquery.py index 0c944400..15f8d12f 100644 --- a/telethon/_events/callbackquery.py +++ b/telethon/_events/callbackquery.py @@ -87,7 +87,7 @@ class CallbackQuery(EventBuilder): )) @classmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others=None, self_id=None, *todo, **todo2): if isinstance(update, _tl.UpdateBotCallbackQuery): return cls.Event(update, update.peer, update.msg_id) elif isinstance(update, _tl.UpdateInlineBotCallbackQuery): diff --git a/telethon/_events/chataction.py b/telethon/_events/chataction.py index 35a5d549..b34ecd65 100644 --- a/telethon/_events/chataction.py +++ b/telethon/_events/chataction.py @@ -33,7 +33,7 @@ class ChatAction(EventBuilder): """ @classmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others=None, self_id=None, *todo, **todo2): # Rely on specific pin updates for unpins, but otherwise ignore them # for new pins (we'd rather handle the new service message with pin, # so that we can act on that message'). @@ -206,9 +206,6 @@ class ChatAction(EventBuilder): self.new_score = new_score self.unpin = not pin - def _set_client(self, client): - super()._set_client(client) - async def respond(self, *args, **kwargs): """ Responds to the chat action message (not as a reply). Shorthand for diff --git a/telethon/_events/common.py b/telethon/_events/common.py index f7b2e066..bfaf3227 100644 --- a/telethon/_events/common.py +++ b/telethon/_events/common.py @@ -67,7 +67,7 @@ class EventBuilder(abc.ABC): @classmethod @abc.abstractmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others, self_id, entities, client): """ Builds an event for the given update if possible, or returns None. @@ -144,6 +144,7 @@ class EventCommon(ChatGetter, abc.ABC): """ Setter so subclasses can act accordingly when the client is set. """ + # TODO Nuke self._client = client if self._chat_peer: self._chat, self._input_chat = utils._get_entity_pair( diff --git a/telethon/_events/inlinequery.py b/telethon/_events/inlinequery.py index 0af44dd0..d3cd6822 100644 --- a/telethon/_events/inlinequery.py +++ b/telethon/_events/inlinequery.py @@ -61,7 +61,7 @@ class InlineQuery(EventBuilder): raise TypeError('Invalid pattern type given') @classmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others=None, self_id=None, *todo, **todo2): if isinstance(update, _tl.UpdateBotInlineQuery): return cls.Event(update) diff --git a/telethon/_events/messagedeleted.py b/telethon/_events/messagedeleted.py index f2a2e9f9..58f9ff5f 100644 --- a/telethon/_events/messagedeleted.py +++ b/telethon/_events/messagedeleted.py @@ -36,7 +36,7 @@ class MessageDeleted(EventBuilder): print('Message', msg_id, 'was deleted in', event.chat_id) """ @classmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others=None, self_id=None, *todo, **todo2): if isinstance(update, _tl.UpdateDeleteMessages): return cls.Event( deleted_ids=update.messages, diff --git a/telethon/_events/messageedited.py b/telethon/_events/messageedited.py index 8eefb9f5..3f430a68 100644 --- a/telethon/_events/messageedited.py +++ b/telethon/_events/messageedited.py @@ -43,7 +43,7 @@ class MessageEdited(NewMessage): print('Message', event.id, 'changed at', event.date) """ @classmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others=None, self_id=None, *todo, **todo2): if isinstance(update, (_tl.UpdateEditMessage, _tl.UpdateEditChannelMessage)): return cls.Event(update.message) diff --git a/telethon/_events/messageread.py b/telethon/_events/messageread.py index 5c37eb2c..0cd50de0 100644 --- a/telethon/_events/messageread.py +++ b/telethon/_events/messageread.py @@ -35,7 +35,7 @@ class MessageRead(EventBuilder): self.inbox = inbox @classmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others=None, self_id=None, *todo, **todo2): if isinstance(update, _tl.UpdateReadHistoryInbox): return cls.Event(update.peer, update.max_id, False) elif isinstance(update, _tl.UpdateReadHistoryOutbox): diff --git a/telethon/_events/newmessage.py b/telethon/_events/newmessage.py index b7b9efc0..e4887002 100644 --- a/telethon/_events/newmessage.py +++ b/telethon/_events/newmessage.py @@ -95,14 +95,14 @@ class NewMessage(EventBuilder): self.from_users = await _into_id_set(client, self.from_users) @classmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others, self_id, entities, client): if isinstance(update, (_tl.UpdateNewMessage, _tl.UpdateNewChannelMessage)): if not isinstance(update.message, _tl.Message): return # We don't care about MessageService's here - event = cls.Event(update.message) + msg = update.message elif isinstance(update, _tl.UpdateShortMessage): - event = cls.Event(_tl.Message( + msg = _tl.Message( out=update.out, mentioned=update.mentioned, media_unread=update.media_unread, @@ -117,9 +117,9 @@ class NewMessage(EventBuilder): reply_to=update.reply_to, entities=update.entities, ttl_period=update.ttl_period - )) + ) elif isinstance(update, _tl.UpdateShortChatMessage): - event = cls.Event(_tl.Message( + msg = _tl.Message( out=update.out, mentioned=update.mentioned, media_unread=update.media_unread, @@ -134,11 +134,11 @@ class NewMessage(EventBuilder): reply_to=update.reply_to, entities=update.entities, ttl_period=update.ttl_period - )) + ) else: return - return event + return cls.Event(_custom.Message._new(client, msg, entities, None)) def filter(self, event): if self._no_check: diff --git a/telethon/_events/raw.py b/telethon/_events/raw.py index 68fdfc0c..496f39e5 100644 --- a/telethon/_events/raw.py +++ b/telethon/_events/raw.py @@ -42,7 +42,7 @@ class Raw(EventBuilder): self.resolved = True @classmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others=None, self_id=None, *todo, **todo2): return update def filter(self, event): diff --git a/telethon/_events/userupdate.py b/telethon/_events/userupdate.py index 61db39ea..b5354ae0 100644 --- a/telethon/_events/userupdate.py +++ b/telethon/_events/userupdate.py @@ -49,7 +49,7 @@ class UserUpdate(EventBuilder): await client.send_message(event.user_id, 'What are you sending?') """ @classmethod - def build(cls, update, others=None, self_id=None): + def build(cls, update, others=None, self_id=None, *todo, **todo2): if isinstance(update, _tl.UpdateUserStatus): return cls.Event(_tl.PeerUser(update.user_id), status=update.status)