0

我正在用 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

它运作良好,但我要解决的复杂问题是我需要键盘等待完整的表达,因为当我点击创建的键盘的每个按钮时,角色进入聊天......我需要加载字符串中的整个表达式

我怎样才能使键盘允许与机器人交互的人使用按钮并构建一个完整的表达式,然后发送到聊天,以便它可以由另一个函数处理?

提前感谢您的任何指导,您可能需要发表评论...

4

1 回答 1

0

尽管它被称为“键盘”,但这些按钮只是消息的模板。

如果您真的想创建一个数学键盘,请使用带有即时消息编辑的内联键盘。您必须获得回调按钮的按下并相应地更新您的机器人的消息。我不确定这是否值得,但这完全取决于你。

于 2019-07-08T13:59:36.767 回答