Separate file and message methods from TelegramClient

This commit is contained in:
Lonami Exo
2018-06-09 22:05:06 +02:00
parent bb9b9796e0
commit 4bd20f1ce2
4 changed files with 1301 additions and 1206 deletions

View File

@@ -402,6 +402,27 @@ def get_input_message(message):
_raise_cast_fail(message, 'InputMedia')
def get_message_id(message):
"""Sanitizes the 'reply_to' parameter a user may send"""
if message is None:
return None
if isinstance(message, int):
return message
if hasattr(message, 'original_message'):
return message.original_message.id
try:
if message.SUBCLASS_OF_ID == 0x790009e3:
# hex(crc32(b'Message')) = 0x790009e3
return message.id
except AttributeError:
pass
raise TypeError('Invalid message type: {}'.format(type(message)))
def get_input_location(location):
"""Similar to :meth:`get_input_peer`, but for input messages."""
try: