亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Python Telebot - 轉發不適用于媒體

Python Telebot - 轉發不適用于媒體

明月笑刀無情 2023-07-11 16:18:16
因此,我必須將傳入的頻道帖子轉發到我的私人聊天以進行測試。現在,它可以工作,但僅限于文本。如果頻道帖子是媒體,則不會轉發消息。這是轉發帖子的代碼: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


查看完整回答
反對 回復 2023-07-11
  • 1 回答
  • 0 關注
  • 125 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號