Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

telegram bot. Forward message to another chat

Tags:

I have a code simple telegram echo bot.

import config
import telebot

bot = telebot.TeleBot(config.token)

@bot.message_handler(content_types=["text"])
def repeat_all_messages(message): 
    bot.send_message(message.chat.id, message.text)

if __name__ == '__main__':
     bot.polling(none_stop=True)

But I want to bot which will send the received message to another chat as Forward. I tried following way

chat = '187458737'
bot.forward_message(chat, message.chat.id, message.text)

But It did not lead to success. How I should modify my bot?

like image 453
Algar Alg Avatar asked Jan 25 '17 08:01

Algar Alg


1 Answers

you shoul do this :

bot.forward_message(to_chat_id, from_chat_id, message_id)

message_id- id of message wich you want to repost

like image 86
egorkh Avatar answered Sep 21 '22 11:09

egorkh