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:
UpdateShort | UpdateShortChatMessage |
UpdateShortMessage | UpdateShortSentMessage |
Updates | UpdatesCombined |
UpdatesTooLong |
Parameters
from_peer | InputPeer | Anything entity-like will work if the library can find its Input version (e.g., usernames, Peer , User or Channel objects, etc.). |
id | int | A list must be supplied. |
to_peer | InputPeer | Anything entity-like will work if the library can find its Input version (e.g., usernames, Peer , User or Channel objects, etc.). |
silent | flag | This argument defaults to None and can be omitted. |
background | flag | This argument defaults to None and can be omitted. |
with_my_score | flag | This argument defaults to None and can be omitted. |
drop_author | flag | This argument defaults to None and can be omitted. |
drop_media_captions | flag | This argument defaults to None and can be omitted. |
noforwards | flag | This argument defaults to None and can be omitted. |
random_id | long | If left unspecified, it will be inferred automatically. Otherwise, a list must be supplied. |
top_msg_id | int | This argument defaults to None and can be omitted. |
schedule_date | date | This argument defaults to None and can be omitted. |
send_as | InputPeer | This 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_shortcut | InputQuickReplyShortcut | This argument defaults to None and can be omitted. |
Known RPC errors
This request can cause 27 known errors:
BroadcastPublicVotersForbiddenError | You cannot broadcast polls where the voters are public. |
ChannelInvalidError | Invalid 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. |
ChannelPrivateError | The channel specified is private and you lack permission to access it. Another reason may be that you were banned from it. |
ChatAdminRequiredError | Chat 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. |
ChatIdInvalidError | Invalid 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. |
ChatSendGifsForbiddenError | You can't send gifs in this chat. |
ChatSendMediaForbiddenError | You can't send media in this chat. |
ChatSendStickersForbiddenError | You can't send stickers in this chat. |
ChatWriteForbiddenError | You can't write in this chat. |
GroupedMediaInvalidError | Invalid grouped media. |
InputUserDeactivatedError | The specified user was deleted. |
MediaEmptyError | The provided media object is invalid or the current account may not be able to send it (such as games as users). |
MessageIdsEmptyError | No message ids were provided. |
MessageIdInvalidError | The specified message ID is invalid or you can't do that operation on such message. |
PeerIdInvalidError | An invalid Peer was used. Make sure to pass the right peer type and that the value is valid (for instance, bots cannot start conversations). |
PtsChangeEmptyError | No PTS change. |
QuizAnswerMissingError | You can forward a quiz while hiding the original author only after choosing an option in the quiz. |
RandomIdDuplicateError | You provided a random ID that was already used. |
RandomIdInvalidError | A provided random ID is invalid. |
ScheduleDateTooLateError | The date you tried to schedule is too far in the future (last known limit of 1 year and a few hours). |
ScheduleTooMuchError | You cannot schedule more messages in this chat (last known limit of 100 per chat). |
TimeoutError | A timeout occurred while fetching data from the worker. |
TopicDeletedError | The topic was deleted. |
UserBannedInChannelError | You're banned from sending messages in supergroups/channels. |
UserIsBlockedError | User is blocked. |
UserIsBotError | Bots can't send messages to other bots. |
YouBlockedUserError | You 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())