From deed74840ab5a74755c3349b6a91d8628072b748 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 30 Apr 2018 13:13:30 +0200 Subject: [PATCH] Make send_message return the correct Message type --- pyrogram/client/client.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 22eee1bf..0853625e 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -262,7 +262,7 @@ class Client: return func return decorator - + # TODO: Maybe make add_handler return (handler, group)? def add_handler(self, handler, group: int = 0): """Use this method to register an update handler. @@ -1154,7 +1154,7 @@ class Client: """ style = self.html if parse_mode.lower() == "html" else self.markdown - return self.send( + r = self.send( functions.messages.SendMessage( peer=self.resolve_peer(chat_id), no_webpage=disable_web_page_preview or None, @@ -1166,6 +1166,21 @@ class Client: ) ) + if isinstance(r, types.UpdateShortSentMessage): + return pyrogram_types.Message( + message_id=r.id, + date=r.date, + outgoing=r.out, + entities=utils.parse_entities(r.entities, {}) or None + ) + + for i in r.updates: + if isinstance(i, (types.UpdateNewMessage, types.UpdateNewChannelMessage)): + users = {i.id: i for i in r.users} + chats = {i.id: i for i in r.chats} + + return utils.parse_message(self, i.message, users, chats) + def forward_messages(self, chat_id: int or str, from_chat_id: int or str,