cma*_*nho 7 python tornado telegram python-telegram-bot telegram-bot
我有Telegram Bot Api和"ReplyKeyboard"的问题.我正在使用Python 2.7并发送帖子请求:
TelegramAPI.post(TELEGRAM_URL + "sendMessage", data=dict(chat_id=CHAT_ID, text="", keyboard={'keyboard': keyboard, 'one_time_keyboard': False, 'resize_keyboard': True})
这种格式的键盘:
[["A button"], ["B button"]]
但在电报中我没有看到键盘.可能有什么问题?
根据Bot API文档,自定义键盘需要一个reply_markup参数,其值是键盘的JSON序列化规范.假设您的TelegramAPI.post()函数没有为您进行JSON序列化,我会尝试以下方法:
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))
请注意,text必须非空.
| 归档时间: | 
 | 
| 查看次数: | 4518 次 | 
| 最近记录: |