2015-12-16 17 views
5

Ho problemi con Telegram Bot Api e con "ReplyKeyboard". Sto usando Python 2.7 e mi invia una richiesta posta:Tastiera computer tastiera Telegram

TelegramAPI.post(TELEGRAM_URL + "sendMessage", data=dict(chat_id=CHAT_ID, text="", keyboard={'keyboard': keyboard, 'one_time_keyboard': False, 'resize_keyboard': True}) 

tastiera in questo formato:

[["A button"], ["B button"]] 

Ma nel telegramma non vedo tastiera. Quale problema può essere?

+0

Quale involucro stai usando? Puoi condividere il documento per 'TelegramAPI'? – balki

risposta

3

In base allo Bot API documentations, una tastiera personalizzata richiede un parametro reply_markup, il cui valore è una specifica serializzata JSON della tastiera. Assumendo che la funzione TelegramAPI.post() non JSON-serializzare per te, vorrei provare il seguente:

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)) 

Nota che text deve essere non vuoto.

Problemi correlati