mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Simplify event building logic
This will also fix some bugs where the event type being accessed would not be available, since it is now built on-demand, without the need to keep track for the count of each event type.
This commit is contained in:
@@ -273,26 +273,18 @@ class Conversation(ChatGetter):
|
||||
self._custom[counter] = (event, future, False)
|
||||
return await result()
|
||||
|
||||
async def _check_custom(self, built, update):
|
||||
async def _check_custom(self, built):
|
||||
# TODO This code is quite much a copy paste of registering events
|
||||
# in the client, resolving them and setting the client; perhaps
|
||||
# there is a better way?
|
||||
for i, (ev, fut, resolved) in self._custom.items():
|
||||
ev_type = type(ev)
|
||||
if ev_type not in built:
|
||||
built[ev_type] = ev.build(update)
|
||||
|
||||
if built[ev_type]:
|
||||
if not resolved:
|
||||
await ev.resolve(self._client)
|
||||
self._custom[i] = (ev, fut, True)
|
||||
|
||||
if ev.filter(built[ev_type]):
|
||||
if hasattr(built[ev_type], '_set_client'):
|
||||
built[ev_type]._set_client(self._client)
|
||||
else:
|
||||
built[ev_type]._client = self._client
|
||||
|
||||
fut.set_result(built[ev_type])
|
||||
|
||||
def _on_new_message(self, response):
|
||||
|
Reference in New Issue
Block a user