mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-09 08:00:53 +03:00
client: return the message in send_file, too
This commit is contained in:
parent
b9cd9a6639
commit
78871b697e
|
@ -363,6 +363,22 @@ class TelegramClient(TelegramBareClient):
|
||||||
drafts = [Draft._from_update(self, u) for u in response.updates]
|
drafts = [Draft._from_update(self, u) for u in response.updates]
|
||||||
return drafts
|
return drafts
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_response_message(request, result):
|
||||||
|
# Telegram seems to send updateMessageID first, then updateNewMessage,
|
||||||
|
# however let's not rely on that just in case.
|
||||||
|
msg_id = None
|
||||||
|
for update in result.updates:
|
||||||
|
if isinstance(update, UpdateMessageID):
|
||||||
|
if update.random_id == request.random_id:
|
||||||
|
msg_id = update.id
|
||||||
|
break
|
||||||
|
|
||||||
|
for update in result.updates:
|
||||||
|
if isinstance(update, (UpdateNewChannelMessage, UpdateNewMessage)):
|
||||||
|
if update.message.id == msg_id:
|
||||||
|
return update.message
|
||||||
|
|
||||||
def send_message(self,
|
def send_message(self,
|
||||||
entity,
|
entity,
|
||||||
message,
|
message,
|
||||||
|
@ -415,21 +431,7 @@ class TelegramClient(TelegramBareClient):
|
||||||
entities=result.entities
|
entities=result.entities
|
||||||
)
|
)
|
||||||
|
|
||||||
# Telegram seems to send updateMessageID first, then updateNewMessage,
|
return self._get_response_message(request, result)
|
||||||
# however let's not rely on that just in case.
|
|
||||||
msg_id = None
|
|
||||||
for update in result.updates:
|
|
||||||
if isinstance(update, UpdateMessageID):
|
|
||||||
if update.random_id == request.random_id:
|
|
||||||
msg_id = update.id
|
|
||||||
break
|
|
||||||
|
|
||||||
for update in result.updates:
|
|
||||||
if isinstance(update, (UpdateNewChannelMessage, UpdateNewMessage)):
|
|
||||||
if update.message.id == msg_id:
|
|
||||||
return update.message
|
|
||||||
|
|
||||||
return None # Should not happen
|
|
||||||
|
|
||||||
def delete_messages(self, entity, message_ids, revoke=True):
|
def delete_messages(self, entity, message_ids, revoke=True):
|
||||||
"""
|
"""
|
||||||
|
@ -723,11 +725,14 @@ 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(
|
request = SendMediaRequest(
|
||||||
peer=self.get_input_entity(entity),
|
peer=self.get_input_entity(entity),
|
||||||
media=media,
|
media=media,
|
||||||
reply_to_msg_id=self._get_reply_to(reply_to)
|
reply_to_msg_id=self._get_reply_to(reply_to)
|
||||||
))
|
)
|
||||||
|
result = self(request)
|
||||||
|
|
||||||
|
return self._get_response_message(request, result)
|
||||||
|
|
||||||
def send_voice_note(self, entity, file, caption='', upload_progress=None,
|
def send_voice_note(self, entity, file, caption='', upload_progress=None,
|
||||||
reply_to=None):
|
reply_to=None):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user