Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 处理API浮动键盘值_Python_Py Telegram Bot Api - Fatal编程技术网

Python 处理API浮动键盘值

Python 处理API浮动键盘值,python,py-telegram-bot-api,Python,Py Telegram Bot Api,我对使用pyTelegramBotAPI制作电报聊天机器人很陌生。在这种情况下,我有多种选择,“梯形”和“辛普森”。下面是下面的代码 @bot.message_handler(commands=['calculate']) def welcome(message): print(message) markup = types.ReplyKeyboardMarkup(one_time_keyboard=True) markup.add('Trapezoid', 'Simps

我对使用pyTelegramBotAPI制作电报聊天机器人很陌生。在这种情况下,我有多种选择,“梯形”和“辛普森”。下面是下面的代码

@bot.message_handler(commands=['calculate'])
def welcome(message):
    print(message)
    markup = types.ReplyKeyboardMarkup(one_time_keyboard=True)
    markup.add('Trapezoid', 'Simpson')
    reply = bot.reply_to(message, "Select computation method" ,reply_markup=markup)
    if(reply.text == 'Trapezoid'):
        bot.register_next_step_handler(reply, trapezoid_handler)
    elif(reply.text == 'Simpson'):
        bot.register_next_step_handler(reply, simpson_handler)

def trapezoid_handler(message):
    bot.send_message(message.id, "Trapezoid Block")

def simpson_handler(message):
    bot.send_message(message.id, "Simpson Block")
下面是我运行/calculate命令时的一张图片

这是我按下“梯形”按钮时的图片

如您所见,当我按下“梯形”按钮时,梯形\u处理程序未执行

目标是,当我按下“梯形”或“辛普森”按钮时,它随后移动到以下按钮值。我是否正确访问浮动键盘值?如何访问浮动键盘值


感谢您的回复

此处,它返回回复文本(即“选择计算方法”),因此当您单击按钮时,不会得到实际值

固定代码:

@bot.message_handler(commands=['caluculate'])
def welcome(message):
    print(message)
    markup = types.ReplyKeyboardMarkup(one_time_keyboard=True)
    markup.add('Trapezoid', 'Simpson')
    reply = bot.reply_to(message, "Select computation method" ,reply_markup=markup)
    bot.register_next_step_handler(reply, markup_handler)

def markup_handler(message):
    if(message.text == 'Trapezoid'):
        bot.send_message(message.chat.id, "Trapezoid Block")
    elif(message.text == 'Simpson'):
        bot.send_message(message.chat.id, "Simpson Block")