我用telegram bot更新程序来处理从发送到它的消息。但是,我想让它对我给出的任何字符串做出响应,前面加一个“#”。在
尝试了AnyString方法,但不起作用。还有,试过“*”wilcard的东西。在
from telegram.ext import Updater, CommandHandler
def hello(bot, update):
update.message.reply_text(
'Hey {}!'.format(update.message.from_user.first_name))
updater = Updater('770165564:AAEJm45dqDNkOnlso0YK6hQoCbXoCySiHcQ')
updater.dispatcher.add_handler(CommandHandler('*', hello))
updater.start_polling()
updater.idle()
当我发送诸如“/anything”、“/test”之类的消息时,bot将用我描述的函数来响应,说“嘿{user name}!”。在
您可以使用前缀处理器(docs)
示例:
命令和单个前缀:
多个前缀,单个命令:
^{pr2}$多前缀和命令:
相关问题 更多 >
编程相关推荐