diff --git a/aiogram/api.py b/aiogram/api.py index 9d87e0ba..10e72326 100644 --- a/aiogram/api.py +++ b/aiogram/api.py @@ -57,7 +57,7 @@ class ApiMethods: DELETE_WEBHOOK = 'deleteWebhook' # TODO GET_WEBHOOK_INFO = 'getWebhookInfo' # TODO SEND_MESSAGE = 'sendMessage' - FORWARD_MESSAGE = 'forwardMessage' # TODO + FORWARD_MESSAGE = 'forwardMessage' SEND_PHOTO = 'sendPhoto' # TODO SEND_AUDIO = 'sendAudio' # TODO SEND_DOCUMENT = 'sendDocument' # TODO diff --git a/aiogram/bot.py b/aiogram/bot.py index 63d66bee..73aaf6c4 100644 --- a/aiogram/bot.py +++ b/aiogram/bot.py @@ -96,4 +96,18 @@ class AIOGramBot: async def delete_message(self, chat_id, message_id): payload = generate_payload(**locals()) - return await self.request(ApiMethods.DELETE_MESSAGE, payload) + await self.request(ApiMethods.DELETE_MESSAGE, payload) + return True + + async def forward_message(self, chat_id, from_chat_id, message_id, disable_notification=None): + """ + chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername) + from_chat_id Integer or String Yes Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) + disable_notification Boolean Optional Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound. + message_id Integer Yes Message identifier in the chat specified in from_chat_id + :return: + """ + + payload = generate_payload(**locals()) + message = await self.request(ApiMethods.FORWARD_MESSAGE, payload) + return self.prepare_object(Message.de_json(message)) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index f9e5eda3..c5ef2f0f 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -163,6 +163,9 @@ class Message(Deserializable): return await self.bot.send_message(self.chat.id, text, parse_mode, disable_web_page_preview, disable_notification, self.message_id, reply_markup) + async def forward(self, chat_id, disable_notification=None) -> 'Message': + return await self.bot.forward_message(chat_id, self.chat.id, self.message_id, disable_notification) + async def delete(self): try: await self.bot.delete_message(self.chat.id, self.message_id)