mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-19 21:11:06 +03:00
Make .get_entity() public
This commit is contained in:
parent
188b1c8816
commit
83f9cafabf
|
@ -415,7 +415,7 @@ class TelegramClient(TelegramBareClient):
|
||||||
some performance loss.
|
some performance loss.
|
||||||
"""
|
"""
|
||||||
request = SendMessageRequest(
|
request = SendMessageRequest(
|
||||||
peer=self._get_entity(entity),
|
peer=self.get_entity(entity),
|
||||||
message=message,
|
message=message,
|
||||||
entities=[],
|
entities=[],
|
||||||
no_webpage=not link_preview
|
no_webpage=not link_preview
|
||||||
|
@ -449,7 +449,7 @@ class TelegramClient(TelegramBareClient):
|
||||||
some performance loss.
|
some performance loss.
|
||||||
"""
|
"""
|
||||||
result = self(GetHistoryRequest(
|
result = self(GetHistoryRequest(
|
||||||
peer=self._get_entity(entity),
|
peer=self.get_entity(entity),
|
||||||
limit=limit,
|
limit=limit,
|
||||||
offset_date=offset_date,
|
offset_date=offset_date,
|
||||||
offset_id=offset_id,
|
offset_id=offset_id,
|
||||||
|
@ -495,7 +495,7 @@ class TelegramClient(TelegramBareClient):
|
||||||
max_id = messages.id
|
max_id = messages.id
|
||||||
|
|
||||||
return self(ReadHistoryRequest(
|
return self(ReadHistoryRequest(
|
||||||
peer=self._get_entity(entity),
|
peer=self.get_entity(entity),
|
||||||
max_id=max_id
|
max_id=max_id
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -572,7 +572,7 @@ class TelegramClient(TelegramBareClient):
|
||||||
# Once the media type is properly specified and the file uploaded,
|
# Once the media type is properly specified and the file uploaded,
|
||||||
# send the media message to the desired entity.
|
# send the media message to the desired entity.
|
||||||
self(SendMediaRequest(
|
self(SendMediaRequest(
|
||||||
peer=self._get_entity(entity),
|
peer=self.get_entity(entity),
|
||||||
media=media
|
media=media
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ class TelegramClient(TelegramBareClient):
|
||||||
# The hexadecimal numbers above are simply:
|
# The hexadecimal numbers above are simply:
|
||||||
# hex(crc32(x.encode('ascii'))) for x in
|
# hex(crc32(x.encode('ascii'))) for x in
|
||||||
# ('User', 'Chat', 'UserFull', 'ChatFull')
|
# ('User', 'Chat', 'UserFull', 'ChatFull')
|
||||||
entity = self._get_entity(entity)
|
entity = self.get_entity(entity)
|
||||||
if not hasattr(entity, 'photo'):
|
if not hasattr(entity, 'photo'):
|
||||||
# Special case: may be a ChatFull with photo:Photo
|
# Special case: may be a ChatFull with photo:Photo
|
||||||
# This is different from a normal UserProfilePhoto and Chat
|
# This is different from a normal UserProfilePhoto and Chat
|
||||||
|
@ -850,7 +850,7 @@ class TelegramClient(TelegramBareClient):
|
||||||
|
|
||||||
# region Small utilities to make users' life easier
|
# region Small utilities to make users' life easier
|
||||||
|
|
||||||
def _get_entity(self, entity):
|
def get_entity(self, entity):
|
||||||
"""Turns an entity into a valid Telegram user or chat.
|
"""Turns an entity into a valid Telegram user or chat.
|
||||||
If "entity" is a string, and starts with '+', or if
|
If "entity" is a string, and starts with '+', or if
|
||||||
it is an integer value, it will be resolved as if it
|
it is an integer value, it will be resolved as if it
|
||||||
|
|
Loading…
Reference in New Issue
Block a user