From 131d792bad795d7898b30aef1fb14f7df2c4f069 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 3 Jun 2018 17:40:28 +0200 Subject: [PATCH] Add forward convenience method to Message objects --- pyrogram/client/types/message.py | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/pyrogram/client/types/message.py b/pyrogram/client/types/message.py index 4d9e6147..a6f099bb 100644 --- a/pyrogram/client/types/message.py +++ b/pyrogram/client/types/message.py @@ -371,3 +371,45 @@ class Message(Object): reply_to_message_id=reply_to_message_id, reply_markup=reply_markup ) + + def forward(self, + chat_id: int or str, + disable_notification: bool = None): + """Use this method as a shortcut for: + + .. code-block:: python + + client.forward_messages( + chat_id=chat_id, + from_chat_id=message.chat.id, + message_ids=message.message_id, + ) + + Example: + .. code-block:: python + + message.forward(chat_id) + + Args: + chat_id (``int`` | ``str``): + Unique identifier (int) or username (str) of the target chat. + For your personal cloud (Saved Messages) you can simply use "me" or "self". + For a contact that exists in your Telegram address book you can use his phone number (str). + For a private channel/supergroup you can use its *t.me/joinchat/* link. + + disable_notification (``bool``, *optional*): + Sends the message silently. + Users will receive a notification with no sound. + + Returns: + On success, the forwarded Message is returned. + + Raises: + :class:`Error ` + """ + return self.client.forward_messages( + chat_id=chat_id, + from_chat_id=self.chat.id, + message_ids=self.message_id, + disable_notification=disable_notification + )