Python 电报机器人。将消息转发到其他聊天室
我有一个简单的电报回音机器人Python 电报机器人。将消息转发到其他聊天室,python,telegram-bot,Python,Telegram 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
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)
但我想机器人将收到的消息发送到另一个聊天转发。
我试着用这种方法
chat = '187458737'
bot.forward_message(chat, message.chat.id, message.text)
但这并没有带来成功。
如何修改我的bot?转发消息的
没有文本的参数
您需要传递聊天id
(目标聊天)、来自聊天id
的和消息\u id
您应该这样做:
bot.forward_message(to_chat_id, from_chat_id, message_id)
message_id-要重新发布的消息的idchatId=int('187458737')bot.forward_消息(chatId,chat.id,message.id)?不工作((我错过了什么?你仍然需要使用message.chat.id
bot.forward\u message(chatId,message.chat.id,message.id)?你能写一行吗?我不使用python bot,但可能是这样:bot.forward\u message(chatId,message.chat.id,message.message\u id)