From 088e7427f6d7d72eb38d57f0a88bdc6f3b2b1c55 Mon Sep 17 00:00:00 2001 From: VitaliyS Date: Mon, 24 Jul 2017 13:25:26 +0300 Subject: add: keyboard in messages --- kernel.py | 4 ++++ plugins/oboobs.py | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel.py b/kernel.py index b06609e..866380f 100644 --- a/kernel.py +++ b/kernel.py @@ -579,6 +579,10 @@ def check_updates(): if msg_in.has_key('edited_message'): msg_in['message'] = msg_in['edited_message'] pprint('*** Edited message!', 'yellow') + elif msg_in.has_key('callback_query'): + msg_in['message'] = msg_in['callback_query']['message'] + msg_in['message']['text'] = msg_in['callback_query']['data'] + pprint('*** Callback query!', 'yellow') #send_msg(msg_in, 'Edited messages not supported now!') diff --git a/plugins/oboobs.py b/plugins/oboobs.py index 7cc5ea3..9ab81bf 100644 --- a/plugins/oboobs.py +++ b/plugins/oboobs.py @@ -25,7 +25,8 @@ def cmd_oboobs(raw_in): try: data = json.loads(load_page('http://api.oboobs.ru/noise/1/'))[0] photo_url = "http://media.oboobs.ru/%s" % data['preview'] - send_photo(raw_in, photo_url, {'caption': 'Another one - /oboobs'}) + kbd = {"inline_keyboard": [[{'text': 'Another one', 'callback_data': 'oboobs'}]]} + send_photo(raw_in, photo_url, custom={'reply_markup': json.dumps(kbd)}) except: msg = 'Error!' send_msg(raw_in, msg) @@ -34,7 +35,8 @@ def cmd_obutts(raw_in): try: data = json.loads(load_page('http://api.obutts.ru/noise/1/'))[0] photo_url = "http://media.obutts.ru/%s" % data['preview'] - send_photo(raw_in, photo_url, {'caption': 'Another one - /obutts'}) + kbd = {"inline_keyboard": [[{'text': 'Another one', 'callback_data': 'obutts'}]]} + send_photo(raw_in, photo_url, custom={'reply_markup': json.dumps(kbd)}) except: msg = 'Error!' send_msg(raw_in, msg) -- cgit v1.2.3