Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 转发消息bot电报_Python_Bots_Telegram - Fatal编程技术网

Python 转发消息bot电报

Python 转发消息bot电报,python,bots,telegram,Python,Bots,Telegram,我使用python Telegrame bot,我不知道如何将消息从用户转发到Telegrame组,我有这样的东西: def feed(bot, update): bot.send_message(chat_id=update.message.chat_id, text="reply this message" bot.forward_message(chat_id="telegram group", from_chat_id="username bot", message_id=?)

我使用python Telegrame bot,我不知道如何将消息从用户转发到Telegrame组,我有这样的东西:

def feed(bot, update):
  bot.send_message(chat_id=update.message.chat_id, text="reply this message"
  bot.forward_message(chat_id="telegram group", from_chat_id="username bot", message_id=?)
我需要转发用户共享的消息,回复必须发送到一个组

怎么可能呢?

发件人:
聊天室id-目标聊天室的唯一标识符…
来自聊天室\u id-发送原始消息的聊天室的唯一标识符
消息\u id-在from\u chat\u id中指定的聊天中的消息标识符

解决方案:

def feed(bot, update):
    # send reply to the user
    bot.send_message(chat_id=update.message.chat_id,
                     text='reply this message')
    # forward user message to group
    # note: group ID with the negative sign
    bot.forward_message(chat_id='-1010101001010',
                        from_chat_id=update.message.chat_id,
                        message_id=update.message.message_id)

使用
Telethon
很容易

您需要
聊天室id
来自聊天室id

你可以添加一个机器人,你将需要令牌