因此,我必須將傳入的頻道帖子轉發到我的私人聊天以進行測試。現在,它可以工作,但僅限于文本。如果頻道帖子是媒體,則不會轉發消息。這是轉發帖子的代碼:bot.forward_message(myId, '@ ' + username, msg.message_id)# Where: myId is my telegram chat ID; '@' + username is the channel (done like this because # there will be multiple channels); msg.message_id is the ID of the message it has to forward我正在使用庫 pyTelegramBotAPI (模塊的名稱是telebot)
1 回答

紅顏莎娜
TA貢獻1842條經驗 獲得超13個贊
好吧,我想出了如何讓它發揮作用。使用 pyTelegramBotAPI,只需將 content_types 參數放入裝飾器中即可:
@bot.channel_post_handler(content_types = ['text', 'photo', 'video', 'gif', 'sticker'])
def channel_post_handler(msg):
# Your code here
可以在 中完成相同的操作@bot.message_handler,因為您可以向其傳遞相同的參數@bot.channel_post_handler
添加回答
舉報
0/150
提交
取消