datamachine / twx

Unofficial Telegram Bot API for Python
MIT License
25 stars 7 forks source link

reply_markup #4

Closed fopina closed 9 years ago

fopina commented 9 years ago

How do I use reply_markup in send_message?

I've tried

bot.send_message(message.chat.id, 'done', reply_to_message_id=message.message_id, reply_markup=ReplyKeyboardHide(hide_keyboard=True, selective=False))

In this class https://github.com/fopina/py-tgbot/blob/master/tgbot/types.py (that I'll discontinue now that I found your library that looks more advanced and robust :)) I managed to use reply_markup but only if the required parameter is the only sent (force_reply or hide_keyboard or keyboard). If any other optional parameter is passed (like selective or one_time_keyboard) then the whole reply_markup instruction is ignored.. I was hoping I could see what I was doing wrong in the JSON-serialization looking at yours, but I can't get it to work in yours...

Thanks

fopina commented 9 years ago

After enabling logging I see that I'm probably using it wrong indeed...

Content-Type: application/x-www-form-urlencoded

text=done&reply_to_message_id=615&reply_markup=True&reply_markup=False&chat_id=...

reply_markup should be the JSON serialized object such as

reply_markup=%7B%22hide_keyboard%22%3Atrue%7D
xlopo commented 9 years ago

ReplyKeyboardMarkup is now implemented and documented. A usage example can be found in the docstring here https://github.com/datamachine/twx/blob/master/twx/botapi/botapi.py#L313-L350

I will push the update to pypi after I finish testing