[英]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_id
、 from_chat_id
。
您可以添加一個機器人,您將需要令牌。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.