Add callback_query_handler.py example

This commit is contained in:
Dan 2018-05-06 13:03:37 +02:00
parent e8b708b35d
commit 735dfb6a0c
2 changed files with 21 additions and 0 deletions

View File

@ -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)

View File

@ -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()