Source code for tgram.methods.copy_message

import tgram
from typing import List
from typing import Union
from tgram.types import ForceReply
from tgram.types import InlineKeyboardMarkup
from tgram.types import MessageEntity
from tgram.types import MessageId
from tgram.types import ReplyKeyboardMarkup
from tgram.types import ReplyKeyboardRemove
from tgram.types import ReplyParameters


[docs] class CopyMessage:
[docs] async def copy_message( self: "tgram.TgBot", chat_id: Union[int, str], from_chat_id: Union[int, str], message_id: int, message_thread_id: int = None, caption: str = None, parse_mode: str = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, disable_notification: bool = None, protect_content: bool = None, reply_parameters: ReplyParameters = None, reply_markup: Union[ InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply ] = None, ) -> MessageId: """ Use this method to copy messages of any kind. Telegram documentation: https://core.telegram.org/bots/api#copymessage :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) :type chat_id: :obj:`int` or :obj:`str` :param from_chat_id: Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername) :type from_chat_id: :obj:`int` or :obj:`str` :param message_id: Message identifier in the chat specified in from_chat_id :type message_id: :obj:`int` :param caption: New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept :type caption: :obj:`str` :param parse_mode: Mode for parsing entities in the new caption. :type parse_mode: :obj:`str` :param caption_entities: A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of parse_mode :type caption_entities: Array of :class:`tgram.types.MessageEntity` :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: :obj:`bool` :param protect_content: Protects the contents of the sent message from forwarding and saving :type protect_content: :obj:`bool` :param reply_to_message_id: Deprecated - Use reply_parameters instead. If the message is a reply, ID of the original message :type reply_to_message_id: :obj:`int` :param allow_sending_without_reply: Deprecated - Use reply_parameters instead. Pass True, if the message should be sent even if the specified replied-to message is not found :type allow_sending_without_reply: :obj:`bool` :param reply_markup: Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. :type reply_markup: :class:`tgram.types.InlineKeyboardMarkup` or :class:`tgram.types.ReplyKeyboardMarkup` or :class:`tgram.types.ReplyKeyboardRemove` or :class:`tgram.types.ForceReply` :param timeout: Timeout in seconds for the request. :type timeout: :obj:`int` :param message_thread_id: Identifier of a message thread, in which the message will be sent :type message_thread_id: :obj:`int` :param reply_parameters: Reply parameters. :type reply_parameters: :class:`tgram.types.ReplyParameters` :param show_caption_above_media: Pass True, if the caption must be shown above the message media. Supported only for animation, photo and video messages. :type show_caption_above_media: :obj:`bool` :return: On success, the MessageId of the sent message is returned. :rtype: :class:`tgram.types.MessageID` """ result = await self._send_request( "copyMessage", chat_id=chat_id, from_chat_id=from_chat_id, message_id=message_id, message_thread_id=message_thread_id, caption=caption, parse_mode=parse_mode or self.parse_mode, caption_entities=caption_entities, show_caption_above_media=show_caption_above_media, disable_notification=disable_notification, protect_content=protect_content if protect_content is not None else self.protect_content, reply_parameters=reply_parameters, reply_markup=reply_markup, ) return MessageId._parse(me=self, d=result["result"])