Skip to content

Commit

Permalink
Fix SendMessageRequest could return UpdateShortSentMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Sep 18, 2017
1 parent 200d1d6 commit 91f4461
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions telethon/telegram_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
InputMediaUploadedDocument, InputMediaUploadedPhoto, InputPeerEmpty,
Message, MessageMediaContact, MessageMediaDocument, MessageMediaPhoto,
InputUserSelf, UserProfilePhoto, ChatPhoto, UpdateMessageID,
UpdateNewMessage
UpdateNewMessage, UpdateShortSentMessage
)
from .utils import find_user_or_chat, get_extension

Expand Down Expand Up @@ -418,14 +418,26 @@ def send_message(self,
If 'reply_to' is set to either a message or a message ID,
the sent message will be replying to such message.
"""
entity = self.get_entity(entity)
request = SendMessageRequest(
peer=self.get_entity(entity),
peer=entity,
message=message,
entities=[],
no_webpage=not link_preview,
reply_to_msg_id=self._get_reply_to(reply_to)
)
result = self(request)
if isinstance(request, UpdateShortSentMessage):
return Message(
id=result.id,
to_id=entity,
message=message,
date=result.date,
out=result.out,
media=result.media,
entities=result.entities
)

# Telegram seems to send updateMessageID first, then updateNewMessage,
# however let's not rely on that just in case.
msg_id = None
Expand Down

0 comments on commit 91f4461

Please sign in to comment.