0
@bot.on_message(filters.chat(INPUT_CHANNELS) & filters.text)
def forward_message(client, message: Message):
    text = message.text
    client.send_message(chat_id=DESTINATION_CHANNEL, text=text)

I got this code here, but it just forwards text from the message although there is an image. I need it to forward the original message, keeping all the content such as images, videos, text, etc.

Michael M.
  • 10,486
  • 9
  • 18
  • 34
Nghia Le
  • 3
  • 1

1 Answers1

0

You're grabbing the text of a message and then use send_message to send a new message. If you want to actually forward a message, you'll have to either use client.forward_messages, or the bound method Message.forward(). This will actually forward a message including any media (images, videos, etc).

@app.on_message(filters.chat(CHANNELS))
def forward_messages(app, message):

    # Either via forward_messages
    app.forward_messages(
        chat_id=TARGET,
        from_chat_id=message.chat.id,
        message_ids=message.id,
    )

    # or via bound method:
    message.forward(TARGET)
ColinShark
  • 1,047
  • 2
  • 10
  • 18
  • hi brother, is bound method optimal ? Im not very familiar with python, sorry for stupid questions. – Nghia Le Feb 11 '23 at 14:52
  • @NghiaLe Bound method just means that it is a method *bound* to the `Message` type. Since you receive a Message object, you can use the bound method `.forward()` as a convenience. Check the documentation I linked in my answer. – ColinShark Feb 11 '23 at 17:07