【问题标题】:telegram bot. Forward message to another chat电报机器人。将消息转发到另一个聊天
【发布时间】:2017-06-10 08:59:18
【问题描述】:

我有一个代码简单的电报回显机器人。

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)

但我想要 bot 将收到的消息作为转发发送到另一个聊天。 我尝试了以下方式

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

但这并没有导致成功。 我应该如何修改我的机器人?

【问题讨论】:

    标签: python telegram-bot


    【解决方案1】:

    你应该这样做:

    bot.forward_message(to_chat_id, from_chat_id, message_id)
    

    message_id- 您要转发的消息的 id

    【讨论】:

      【解决方案2】:

      forwardMessage 没有text 的参数。
      您需要传递chat_id(目标聊天)、from_chat_idmessage_id

      【讨论】:

      • chatId = int('187458737') bot.forward_message(chatId, chat.id, message.id) ?不工作((我错过了什么?
      • 你还是要使用message.chat.id
      • bot.forward_message(chatId, message.chat.id, message.id) ?你能写完整行吗?
      • 我不使用python bot,但大概是这样的:bot.forward_message(chatId, message.chat.id, message.message_id)
      猜你喜欢
      • 2018-01-09
      • 1970-01-01
      • 1970-01-01
      • 2021-09-03
      • 2017-05-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-26
      • 2020-08-25
      相关资源
      最近更新 更多