telegram.ext CommandHandler 在个人聊天中有效,但在群聊中无效
telegram.ext CommandHandler works in personal chat but doesn't work in group chat
我有一个电报机器人,我正在尝试向其中添加少量 "features",我发现添加更多 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)
func1
和 func2
工作正常,他们以前在那里,但新的 newfunc
在群聊中不起作用。
我不知道是什么原因造成的
我找到问题了
我在 newfunc
代码中将 update.message.reply_text
作为响应文本,但机器人处于隐私模式。
简单的解决方案是关闭隐私模式,以便它可以访问消息
我有一个电报机器人,我正在尝试向其中添加少量 "features",我发现添加更多 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)
func1
和 func2
工作正常,他们以前在那里,但新的 newfunc
在群聊中不起作用。
我不知道是什么原因造成的
我找到问题了
我在 newfunc
代码中将 update.message.reply_text
作为响应文本,但机器人处于隐私模式。
简单的解决方案是关闭隐私模式,以便它可以访问消息