簡體   English   中英

轉發消息機器人電報python

[英]Forward message bot telegram python

我使用 python-telegram-bot 並且我不明白如何將消息從用戶轉發到電報組,我有這樣的事情:

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=?)

我需要轉發用戶共享消息的消息,並且回復必須發送到一個組。

怎么可能?

文檔
chat_id - 目標聊天的唯一標識符...
from_chat_id -發送原始消息聊天的唯一標識符...
message_id - from_chat_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很容易。

您需要chat_idfrom_chat_id

您可以添加一個機器人,您將需要令牌。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM