Inline the old _load_entities code

This commit is contained in:
Lonami Exo
2019-05-01 17:07:12 +02:00
parent e84c9847c5
commit 6d004601d0
7 changed files with 19 additions and 46 deletions

View File

@@ -204,31 +204,19 @@ class NewMessage(EventBuilder):
def _set_client(self, client):
super()._set_client(client)
self.message._finish_init(client, self._entities, None)
self.__dict__['_init'] = True # No new attributes can be set
def _load_entities(self):
m = self.message
m._finish_init(client, self._entities, None)
# TODO Duplicated work here
m._chat, m._input_chat = self._get_entity_pair(m.chat_id)
m._sender, m._input_sender = self._get_entity_pair(m.sender_id)
m._via_bot, m._via_input_bot = self._get_entity_pair(m.via_bot_id)
if not m.forward:
forward_ok = True
else:
if m.forward:
f = m.forward
f._chat, f._input_chat = self._get_entity_pair(f.chat_id)
f._sender, f._input_sender = self._get_entity_pair(f.sender_id)
forward_ok = (
(not f.chat_id or f._input_chat is not None)
and (not f.sender_id or f._input_sender is not None)
)
return (
m._input_chat is not None
and (not m.sender_id or m._input_sender is not None)
and (not m.via_bot_id or m._via_input_bot is not None)
and forward_ok
)
self.__dict__['_init'] = True # No new attributes can be set
def __getattr__(self, item):
if item in self.__dict__: