【问题标题】:telegram.ext CommandHandler works in personal chat but doesn't work in group chattelegram.ext CommandHandler 在个人聊天中有效,但在群聊中无效
【发布时间】:2018-06-09 08:23:54
【问题描述】:

我有一个电报机器人,我正在尝试通过添加更多CommandHandler 来添加一些我觉得有用的“功能”。新功能在个人聊天中运行良好,但在群聊中不起作用。我对此感到困惑。

我的代码如下

def func1(bot, update):
    <somecode>


def func2(bot, update, args):
    <somecode>

def error(bot, update, error):
    <errorhandler>

def newfunc(bot, update, args):
    <newcode>


dispatcher.add_handler(CommandHandler('func1', func1))
dispatcher.add_handler(CommandHandler('func2', func2, pass_args=True))
dispatcher.add_handler(CommandHandler('newfunc', newfunc, pass_args=True))
dispatcher.add_error_handler(error)

func1func2 工作正常,它们以前在那里,但新的 newfunc 在群聊中不起作用。

不知道是什么原因造成的

【问题讨论】:

  • 错误是什么?
  • 没有。在群聊的情况下,请求不会到达服务器。它适用于个人聊天

标签: python telegram telegram-bot python-telegram-bot telegram-webhook


【解决方案1】:

我发现了问题。

我在newfunc 代码中有update.message.reply_text 作为响应文本,但机器人处于隐私模式。

简单的解决方案是关闭隐私模式,以便它可以访问消息

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    相关资源
    最近更新 更多