如何从有关特定消息的回复中获取信息-Telegram Bot
假设我有此命令处理程序:
@bot.message_handler(commands=['setalarm'])
def setalarmcmd(message):
alarmMessage = "Let's start with setting up alarm.\n\n" \
"First of all, provide the pair you want to observe."
bot.send_message(message.chat.id, alarmMessage)
当用户单击/setAlarm
命令并在此消息上回复时,我想设置一些操作。
实际上,我知道该怎么做,但是我已经对提供的文本进行处理:
@bot.message_handler(content_types=['text'])
def getpairfuncmessage(message):
userMessage = message.text.strip().upper()
pair = getPairApi(userMessage)
if not pair:
return bot.send_message(message.chat.id, "Nah, not that, try something else.")
pairResult = printPairResult(pair)
bot.send_message(message.chat.id, pairResult, parse_mode='html')
这就是问题所在。通过提供消息,用户可以触发此操作,但是我想在/setAlarm
命令之后设置另一个操作。这可能吗?
Let's say I have this command handler:
@bot.message_handler(commands=['setalarm'])
def setalarmcmd(message):
alarmMessage = "Let's start with setting up alarm.\n\n" \
"First of all, provide the pair you want to observe."
bot.send_message(message.chat.id, alarmMessage)
I want to set some action when user click /setalarm
command and replies on this message.
Actually, I know how to do that, but I already have handler on provided text:
@bot.message_handler(content_types=['text'])
def getpairfuncmessage(message):
userMessage = message.text.strip().upper()
pair = getPairApi(userMessage)
if not pair:
return bot.send_message(message.chat.id, "Nah, not that, try something else.")
pairResult = printPairResult(pair)
bot.send_message(message.chat.id, pairResult, parse_mode='html')
And that's the problem. By providing message, user triggers this action, but I want to set another one, after /setalarm
command. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以做到这一点:
使用
send_message
和register_next_step_handler
转到下一个功能。Here is how you can do this:
Using
send_message
andregister_next_step_handler
to go to next function.