mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 12:59:46 +00:00
Use the new in-memory entity cache
This should avoid a disk access every time an input entity is needed, which is very often. Another step for #1141.
This commit is contained in:
@@ -170,7 +170,7 @@ class UserUpdate(EventBuilder):
|
||||
def _set_client(self, client):
|
||||
if isinstance(self._chat_peer, int):
|
||||
try:
|
||||
chat = client.session.get_input_entity(self._chat_peer)
|
||||
chat = client._entity_cache[self._chat_peer]
|
||||
if isinstance(chat, types.InputPeerChat):
|
||||
self._chat_peer = types.PeerChat(self._chat_peer)
|
||||
elif isinstance(chat, types.InputPeerChannel):
|
||||
@@ -178,7 +178,7 @@ class UserUpdate(EventBuilder):
|
||||
else:
|
||||
# Should not happen
|
||||
self._chat_peer = types.PeerUser(self._chat_peer)
|
||||
except ValueError:
|
||||
except KeyError:
|
||||
# Hope for the best. We don't know where this event
|
||||
# occurred but it was most likely in a channel.
|
||||
self._chat_peer = types.PeerChannel(self._chat_peer)
|
||||
|
Reference in New Issue
Block a user