【发布时间】:2021-09-13 22:11:36
【问题描述】:
我创建了电报机器人,现在它通过带有斜杠的命令处理程序使用命令来激活不同的功能,但问题是 - 是否有可能让他理解 text = /command,例如(“是,是,是,是" = /是)。
我想保留我的命令处理程序,但想用不带斜杠的命令制作键盘按钮。
self._keyboard: List[List[Union[str, KeyboardButton]]] = [
['/yes', '/no', '/sure'],
['/absolutely', '/allright'],
handles = [
CommandHandler('yes', self._yes),
CommandHandler('no', self._no),
CommandHandler('sure', self._sure),
CommandHandler('absolutely', self._absolutely),
CommandHandler('allright', self._allright),
#New added string: (Big Thanks to the user CallMeStag)
MessageHandler(Filters.regex('^yes$'), self._yes),
]
#I can start bot, bot not every function working, under is error which i got:
AttributeError: MessageHandler object has no attribute command
【问题讨论】:
-
如果不了解您是如何实现命令的,就很难回答这个问题。请发布您的代码的相关部分,以便其他人可以帮助您。
标签: python python-3.x telegram telegram-bot python-telegram-bot