我正在用 python-telepot 做一个电报机器人,我想用 ReplyKeyboardMarkup 创建一个键盘,这个键盘具有输入我想推导的数学表达式的功能(应用导数的功能)我给你看键盘代码:
if data == 'resol_der':
bot.answerCallbackQuery(query_id, text='Use the keyboard to insert')
markup = ReplyKeyboardMarkup(
keyboard=[
[KeyboardButton(text='0'),KeyboardButton(text='1'),KeyboardButton(text='2'),KeyboardButton(text='3'),KeyboardButton(text='4'),
KeyboardButton(text='5'),KeyboardButton(text='6'),KeyboardButton(text='7'),KeyboardButton(text='8'),KeyboardButton(text='9')],
[KeyboardButton(text='+'),KeyboardButton(text='-'),KeyboardButton(text='*'),KeyboardButton(text='/'),KeyboardButton(text='='),
KeyboardButton(text='('),KeyboardButton(text=')'),KeyboardButton(text=','),KeyboardButton(text='x**'),KeyboardButton(text='√')],
[KeyboardButton(text='send'),KeyboardButton(text='/start')],
]
)
bot.sendChatAction(from_id, 'typing')
bot.sendMessage(from_id, 'OK! Give me the expression', reply_markup=markup)
看起来像这样 制作ReplyKeyboardMarkup
它运作良好,但我要解决的复杂问题是我需要键盘等待完整的表达,因为当我点击创建的键盘的每个按钮时,角色进入聊天......我需要加载字符串中的整个表达式
我怎样才能使键盘允许与机器人交互的人使用按钮并构建一个完整的表达式,然后发送到聊天,以便它可以由另一个函数处理?
提前感谢您的任何指导,您可能需要发表评论...