Пересыл сообщений с помощью ID

Как сделать, чтобы бот пересылал сообщения из переписки с ботом другим людям по их ID? Хотелось бы узнать структуру кода, хотя бы один пример.


Ответы (1 шт):

Автор решения: nmzgnv

await bot.forward_message(...)

Параметры:

chat_id: Union[int, str] Unique identifier for the target chat or username of the target channel (in the format @channelusername)

from_chat_id: Union[int, str] Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)

message_id: int Message identifier in the chat specified in from_chat_id

disable_notification: Optional[bool] Sends the message silently. Users will receive a notification with no sound.

  1. Получаете id человека, которому необходимо отправить сообщение (Важно! Бот не может инициировать диалог)
  2. Берете id чата (откуда переслать) и id сообщения
  3. Profit :)

Пример:

...
await bot.forward_message(chat_id=123123123, from_chat_id=message.chat.id, message_id=message.message_id)
...
→ Ссылка