Skip to content
Advertisement

Telegram API Python – Automatically forward user input message (including formatting) to another chat_id

Good evening.

I hope that you are well.

I have posted an excerpt below of some Telegram bot code which auto forwards any messages it receives to another channel which has the bot added :-

JavaScript

This code works fine for any text based messages that are sent to the bot (which includes standard formatting such as Bold, Italic, Underline, Emojis, Hyperlinks etc.) however if I attempt to attach an image to a message and then send it, the message is not forwarded on at all.

Does anyone have any idea how I can handle image based messages so that they forward successfully please? Does it need another function that deals with a different telebot.types method perhaps?

Many thanks in advance

Jimmy

Advertisement

Answer

I have a bot that does something like this, but I only need to handle text and photos separately. I hope this code snipped helps!

JavaScript

just make sure that you add the bot to both chats as an admin or this will not work since the bot needs admin priveleges to respond to all messages not just commands.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement