为了账号安全,请及时绑定邮箱和手机立即绑定

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条经验 获得超12个赞

好吧,我想出了如何让它发挥作用。使用 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 关注
  • 74 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信