你好。我正在尝试使用正则表达式从用户那里获取电报机器人命令。这种形式的命令是'/45623456'、'/45678909',即一个反斜杠和八位数字。这是处理程序:
@bot.message_handler(regexp="/\d{8}")
def handle_message(message):
pass
但是这个例子没有给出任何合理的东西:
2017-10-24 09:00:35,845 (util.py:64 WorkerThread2) ERROR - TeleBot: "TypeError occurred, args=("'NoneType' object is not callable",)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/telebot/util.py", line 58, in run
task(*args, **kwargs)
TypeError: 'NoneType' object is not callable
谁练过,请告诉我怎么做对吗?
python3.4远程机器人
pyTelegramBotAPI文档中有一个带有 lambda 函数的处理程序示例,您可以使用它灵活地设置捕获消息的条件:
因此,
True
必须用必要条件代替。