From 139cbc657daac478a53be2fd1ec66686a57ff786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Sun, 28 Feb 2016 01:51:14 +0100 Subject: [PATCH] add inline bot handler example --- README.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.rst b/README.rst index 2f9d9f162..f75e216ac 100644 --- a/README.rst +++ b/README.rst @@ -227,6 +227,20 @@ Let's add some functionality to our bot. We want to add the ``/caps`` command, t ... >>> dispatcher.addTelegramCommandHandler('caps', caps) +To enable our bot to respond to inline queries, we can add the following (you will also have to talk to BotFather):: + + >>> from telegram import InlineQueryResultArticle + >>> def inline_caps(bot, update): + ... # If you activated inline feedback, updates might either contain + ... # inline_query or chosen_inline_result, the other one will be None + ... if update.inline_query: + ... query = bot.update.inline_query.query + ... results = list() + ... results.append(InlineQueryResultArticle(query.upper(), 'Caps', text_caps)) + ... bot.answerInlineQuery(update.inline_query.id, results) + ... + >>> dispatcher.addTelegramInlineHandler(inline_caps) + Now it's time to stop the bot:: >>> updater.stop()