X Tutup
Skip to content

Commit 139cbc6

Browse files
committed
add inline bot handler example
1 parent 4aca4d1 commit 139cbc6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,20 @@ Let's add some functionality to our bot. We want to add the ``/caps`` command, t
227227
...
228228
>>> dispatcher.addTelegramCommandHandler('caps', caps)
229229

230+
To enable our bot to respond to inline queries, we can add the following (you will also have to talk to BotFather)::
231+
232+
>>> from telegram import InlineQueryResultArticle
233+
>>> def inline_caps(bot, update):
234+
... # If you activated inline feedback, updates might either contain
235+
... # inline_query or chosen_inline_result, the other one will be None
236+
... if update.inline_query:
237+
... query = bot.update.inline_query.query
238+
... results = list()
239+
... results.append(InlineQueryResultArticle(query.upper(), 'Caps', text_caps))
240+
... bot.answerInlineQuery(update.inline_query.id, results)
241+
...
242+
>>> dispatcher.addTelegramInlineHandler(inline_caps)
243+
230244
Now it's time to stop the bot::
231245

232246
>>> updater.stop()

0 commit comments

Comments
 (0)
X Tutup