0

我想将我的机器人和另一个人的整个对话转发给我自己

这是我的代码:

import telepot
bot = telepot.Bot('<Token>')
def handle(msg):
    my_id = 123456789    # this is my id for example
    chat_id = telepot.glance(msg)[2]
    bot_msg = bot.sendMessage(chat_id, 'this message is sent by bot')
    bot.forwardMessage(my_id, bot_msg['from']['id'], bot_msg['message_id']) # this line gets error

但是当我尝试从机器人转发消息时,我收到了这个错误:

telepot.exception.TelegramError: ('Bad Request: message to forward not found', 400, {'ok': False, 'error_code': 400, 'description': 'Bad Request: message to forward not found'})

我做错了吗?还是只是受电报限制?

4

1 回答 1

0

转发的第二个参数应该是发起聊天 ID,而不是用户 ID。尝试调用:

bot.forwardMessage(my_id, bot_msg['chat']['id'], bot_msg['message_id'])

于 2018-10-25T00:12:44.527 回答