MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / forward_messages

Method forward_messages

src/telegram/_bot.py:1410–1474  ·  view source on GitHub ↗

Use this method to forward messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages. .. versionadded:

(
        self,
        chat_id: int | str,
        from_chat_id: str | int,
        message_ids: Sequence[int],
        disable_notification: ODVInput[bool] = DEFAULT_NONE,
        protect_content: ODVInput[bool] = DEFAULT_NONE,
        message_thread_id: int | None = None,
        direct_messages_topic_id: int | None = None,
        *,
        read_timeout: ODVInput[float] = DEFAULT_NONE,
        write_timeout: ODVInput[float] = DEFAULT_NONE,
        connect_timeout: ODVInput[float] = DEFAULT_NONE,
        pool_timeout: ODVInput[float] = DEFAULT_NONE,
        api_kwargs: JSONDict | None = None,
    )

Source from the content-addressed store, hash-verified

1408 )
1409
1410 async def forward_messages(
1411 self,
1412 chat_id: int | str,
1413 from_chat_id: str | int,
1414 message_ids: Sequence[int],
1415 disable_notification: ODVInput[bool] = DEFAULT_NONE,
1416 protect_content: ODVInput[bool] = DEFAULT_NONE,
1417 message_thread_id: int | None = None,
1418 direct_messages_topic_id: int | None = None,
1419 *,
1420 read_timeout: ODVInput[float] = DEFAULT_NONE,
1421 write_timeout: ODVInput[float] = DEFAULT_NONE,
1422 connect_timeout: ODVInput[float] = DEFAULT_NONE,
1423 pool_timeout: ODVInput[float] = DEFAULT_NONE,
1424 api_kwargs: JSONDict | None = None,
1425 ) -> tuple[MessageId, ...]:
1426 """
1427 Use this method to forward messages of any kind. If some of the specified messages can't be
1428 found or forwarded, they are skipped. Service messages and messages with protected content
1429 can't be forwarded. Album grouping is kept for forwarded messages.
1430
1431 .. versionadded:: 20.8
1432
1433 Args:
1434 chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
1435 from_chat_id (:obj:`int` | :obj:`str`): Unique identifier for the chat where the
1436 original message was sent (or channel username in the format ``@channelusername``).
1437 message_ids (Sequence[:obj:`int`]): A list of
1438 :tg-const:`telegram.constants.BulkRequestLimit.MIN_LIMIT`-
1439 :tg-const:`telegram.constants.BulkRequestLimit.MAX_LIMIT` identifiers of messages
1440 in the chat :paramref:`from_chat_id` to forward. The identifiers must be specified
1441 in a strictly increasing order.
1442 disable_notification (:obj:`bool`, optional): |disable_notification|
1443 protect_content (:obj:`bool`, optional): |protect_content|
1444 message_thread_id (:obj:`int`, optional): |message_thread_id_arg|
1445 direct_messages_topic_id (:obj:`int`, optional): Identifier of the direct messages
1446 topic to which the messages will be forwarded; required if the messages are
1447 forwarded to a direct messages chat.
1448
1449 .. versionadded:: 22.4
1450
1451 Returns:
1452 tuple[:class:`telegram.Message`]: On success, a tuple of ``MessageId`` of sent messages
1453 is returned.
1454 """
1455 data: JSONDict = {
1456 "chat_id": chat_id,
1457 "from_chat_id": from_chat_id,
1458 "message_ids": message_ids,
1459 "disable_notification": disable_notification,
1460 "protect_content": protect_content,
1461 "message_thread_id": message_thread_id,
1462 "direct_messages_topic_id": direct_messages_topic_id,
1463 }
1464
1465 result = await self._post(
1466 "forwardMessages",
1467 data,

Callers 5

forward_messages_fromMethod · 0.45
forward_messages_toMethod · 0.45
forward_messages_fromMethod · 0.45
forward_messages_toMethod · 0.45
test_forward_messagesMethod · 0.45

Calls 2

_postMethod · 0.95
de_listMethod · 0.80

Tested by 1

test_forward_messagesMethod · 0.36