mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
Forward message
This commit is contained in:
parent
e87180b6f4
commit
1351e65124
3 changed files with 19 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue