mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-11 03:56:36 +03:00
Stop calling .process_entities where not needed
This commit is contained in:
parent
401de913af
commit
4673a02ce6
|
@ -889,17 +889,16 @@ class TelegramClient(TelegramBareClient):
|
||||||
# crc32(b'InputPeer') and crc32(b'Peer')
|
# crc32(b'InputPeer') and crc32(b'Peer')
|
||||||
type(entity).SUBCLASS_OF_ID in (0xc91c90b6, 0x2d45687)):
|
type(entity).SUBCLASS_OF_ID in (0xc91c90b6, 0x2d45687)):
|
||||||
ie = self.get_input_entity(entity)
|
ie = self.get_input_entity(entity)
|
||||||
result = None
|
|
||||||
if isinstance(ie, InputPeerUser):
|
if isinstance(ie, InputPeerUser):
|
||||||
result = self(GetUsersRequest([ie]))
|
self(GetUsersRequest([ie]))
|
||||||
elif isinstance(ie, InputPeerChat):
|
elif isinstance(ie, InputPeerChat):
|
||||||
result = self(GetChatsRequest([ie.chat_id]))
|
self(GetChatsRequest([ie.chat_id]))
|
||||||
elif isinstance(ie, InputPeerChannel):
|
elif isinstance(ie, InputPeerChannel):
|
||||||
result = self(GetChannelsRequest([ie]))
|
self(GetChannelsRequest([ie]))
|
||||||
|
|
||||||
if result:
|
|
||||||
self.session.process_entities(result)
|
|
||||||
try:
|
try:
|
||||||
|
# session.process_entities has been called in the MtProtoSender
|
||||||
|
# with the result of these calls, so they should now be on the
|
||||||
|
# entities database.
|
||||||
return self.session.entities[ie]
|
return self.session.entities[ie]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
@ -918,11 +917,11 @@ class TelegramClient(TelegramBareClient):
|
||||||
phone = EntityDatabase.parse_phone(string)
|
phone = EntityDatabase.parse_phone(string)
|
||||||
if phone:
|
if phone:
|
||||||
entity = phone
|
entity = phone
|
||||||
self.session.process_entities(self(GetContactsRequest(0)))
|
self(GetContactsRequest(0))
|
||||||
else:
|
else:
|
||||||
entity = string.strip('@').lower()
|
entity = string.strip('@').lower()
|
||||||
self.session.process_entities(self(ResolveUsernameRequest(entity)))
|
self(ResolveUsernameRequest(entity))
|
||||||
|
# MtProtoSender will call .process_entities on the requests made
|
||||||
try:
|
try:
|
||||||
return self.session.entities[entity]
|
return self.session.entities[entity]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user