Telegram bot api keyboard

依然范特西╮ 提交于 2019-12-05 04:54:40

According to the Bot API documentations, a custom keyboard requires a reply_markup parameter, whose value is a JSON-serialized specification of the keyboard. Assuming your TelegramAPI.post() function does not JSON-serialize for you, I would try the following:

import json

json_keyboard = json.dumps({'keyboard': [["A button"], ["B button"]], 
                            'one_time_keyboard': False, 
                            'resize_keyboard': True})

TelegramAPI.post(TELEGRAM_URL + "sendMessage", 
                 data=dict(chat_id=CHAT_ID, 
                           text="Has to be non-empty", 
                           reply_markup=json_keyboard))

Note that text has to be non-empty.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!