From 735dfb6a0c6eb8e7e4773431ff28b8158d434212 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 6 May 2018 13:03:37 +0200 Subject: [PATCH] Add callback_query_handler.py example --- examples/README.md | 1 + examples/callback_query_handler.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 examples/callback_query_handler.py diff --git a/examples/README.md b/examples/README.md index cb2432a8..298d9d20 100644 --- a/examples/README.md +++ b/examples/README.md @@ -15,4 +15,5 @@ you can simply copy-paste and run, the only things you have to change are your s - [**get_participants2.py**](get_participants2.py) - [**query_inline_bots.py**](query_inline_bots.py) - [**send_bot_keyboards.py**](send_bot_keyboards.py) +- [**callback_query_handler.py**](callback_query_handler.py) - [**raw_update_handler.py**](raw_update_handler.py) diff --git a/examples/callback_query_handler.py b/examples/callback_query_handler.py new file mode 100644 index 00000000..3aa5b11c --- /dev/null +++ b/examples/callback_query_handler.py @@ -0,0 +1,20 @@ +from pyrogram import Client + +"""This example shows how to handle callback queries, i.e.: queries coming from inline button presses. + +It uses the @on_callback_query decorator to register a CallbackQueryHandler.""" + +app = Client("123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11") + + +@app.on_callback_query() +def answer(client, callback_query): + client.answer_callback_query( + callback_query.id, + text='Button contains: "{}"'.format(callback_query.data), + show_alert=True + ) + + +app.start() +app.idle()