mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-11-10 02:50:36 +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:
@@ -49,9 +49,8 @@ class ChatGetter(abc.ABC):
|
||||
"""
|
||||
if self._input_chat is None and self._chat_peer:
|
||||
try:
|
||||
self._input_chat =\
|
||||
self._client.session.get_input_entity(self._chat_peer)
|
||||
except ValueError:
|
||||
self._input_chat = self._client._entity_cache(self._chat_peer)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return self._input_chat
|
||||
|
||||
@@ -64,9 +64,8 @@ class Draft:
|
||||
"""
|
||||
if not self._input_entity:
|
||||
try:
|
||||
self._input_entity =\
|
||||
self._client.session.get_input_entity(self._peer)
|
||||
except ValueError:
|
||||
self._input_entity = self._client._entity_cache[self._peer]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return self._input_entity
|
||||
|
||||
@@ -834,8 +834,10 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
|
||||
if not bot:
|
||||
raise ValueError('No input sender')
|
||||
else:
|
||||
return self._client.session.get_input_entity(
|
||||
self.via_bot_id)
|
||||
try:
|
||||
return self._client._entity_cache[self.via_bot_id]
|
||||
except KeyError:
|
||||
raise ValueError('No input sender') from None
|
||||
|
||||
def _document_by_attribute(self, kind, condition=None):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user