ForwardMessagesRequest

Both users and bots can use this request. See code examples.

---functions---
messages.forwardMessages#d5039208 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true drop_author:flags.11?true drop_media_captions:flags.12?true noforwards:flags.14?true from_peer:InputPeer id:Vector<int> random_id:Vector<long> to_peer:InputPeer top_msg_id:flags.9?int schedule_date:flags.10?date send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut = Updates

Returns

Updates

This type can be an instance of either:

UpdateShortUpdateShortChatMessage
UpdateShortMessageUpdateShortSentMessage
UpdatesUpdatesCombined
UpdatesTooLong

Parameters

from_peerInputPeerAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
idintA list must be supplied.
to_peerInputPeerAnything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
silentflagThis argument defaults to None and can be omitted.
backgroundflagThis argument defaults to None and can be omitted.
with_my_scoreflagThis argument defaults to None and can be omitted.
drop_authorflagThis argument defaults to None and can be omitted.
drop_media_captionsflagThis argument defaults to None and can be omitted.
noforwardsflagThis argument defaults to None and can be omitted.
random_idlongIf left unspecified, it will be inferred automatically. Otherwise, a list must be supplied.
top_msg_idintThis argument defaults to None and can be omitted.
schedule_datedateThis argument defaults to None and can be omitted.
send_asInputPeerThis argument defaults to None and can be omitted. Anything entity-like will work if the library can find its Input version (e.g., usernames, Peer, User or Channel objects, etc.).
quick_reply_shortcutInputQuickReplyShortcutThis argument defaults to None and can be omitted.

Known RPC errors

This request can cause 27 known errors:

BroadcastPublicVotersForbiddenErrorYou cannot broadcast polls where the voters are public.
ChannelInvalidErrorInvalid channel object. Make sure to pass the right types, for instance making sure that the request is designed for channels or otherwise look for a different one more suited.
ChannelPrivateErrorThe channel specified is private and you lack permission to access it. Another reason may be that you were banned from it.
ChatAdminRequiredErrorChat admin privileges are required to do that in the specified chat (for example, to send a message in a channel which is not yours), or invalid permissions used for the channel or group.
ChatIdInvalidErrorInvalid object ID for a chat. Make sure to pass the right types, for instance making sure that the request is designed for chats (not channels/megagroups) or otherwise look for a different one more suited\nAn example working with a megagroup and AddChatUserRequest, it will fail because megagroups are channels. Use InviteToChannelRequest instead.
ChatSendGifsForbiddenErrorYou can't send gifs in this chat.
ChatSendMediaForbiddenErrorYou can't send media in this chat.
ChatSendStickersForbiddenErrorYou can't send stickers in this chat.
ChatWriteForbiddenErrorYou can't write in this chat.
GroupedMediaInvalidErrorInvalid grouped media.
InputUserDeactivatedErrorThe specified user was deleted.
MediaEmptyErrorThe provided media object is invalid or the current account may not be able to send it (such as games as users).
MessageIdsEmptyErrorNo message ids were provided.
MessageIdInvalidErrorThe specified message ID is invalid or you can't do that operation on such message.
PeerIdInvalidErrorAn invalid Peer was used. Make sure to pass the right peer type and that the value is valid (for instance, bots cannot start conversations).
PtsChangeEmptyErrorNo PTS change.
QuizAnswerMissingErrorYou can forward a quiz while hiding the original author only after choosing an option in the quiz.
RandomIdDuplicateErrorYou provided a random ID that was already used.
RandomIdInvalidErrorA provided random ID is invalid.
ScheduleDateTooLateErrorThe date you tried to schedule is too far in the future (last known limit of 1 year and a few hours).
ScheduleTooMuchErrorYou cannot schedule more messages in this chat (last known limit of 100 per chat).
TimeoutErrorA timeout occurred while fetching data from the worker.
TopicDeletedErrorThe topic was deleted.
UserBannedInChannelErrorYou're banned from sending messages in supergroups/channels.
UserIsBlockedErrorUser is blocked.
UserIsBotErrorBots can't send messages to other bots.
YouBlockedUserErrorYou blocked this user.

You can import these from telethon.errors.

Example

Please refer to the documentation of client.forward_messages() to learn about the parameters and see several code examples on how to use it.

The method above is the recommended way to do it. If you need more control over the parameters or want to learn how it is implemented, open the details by clicking on the "Details" text.

from telethon.sync import TelegramClient
from telethon import functions, types

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.messages.ForwardMessagesRequest(
        from_peer='username',
        id=[42],
        to_peer='username',
        with_my_score=True,
        drop_author=True,
        drop_media_captions=True,
        noforwards=True,
        top_msg_id=42,
        schedule_date=datetime.datetime(2018, 6, 25),
        send_as='username',
        quick_reply_shortcut=types.InputQuickReplyShortcut(
            shortcut='some string here'
        )
    ))
    print(result.stringify())