From f16ed40532059bf3ab2f06673bbcca7aeae7396b Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Fri, 10 May 2019 17:15:46 +0200 Subject: [PATCH] Update examples --- examples/README.md | 16 ++++++++-------- examples/{keyboards.py => bot_keyboards.py} | 2 +- .../{chat_members.py => get_chat_members.py} | 0 examples/{dialogs.py => get_dialogs.py} | 2 +- examples/{history.py => get_history.py} | 0 examples/use_inline_bots.py | 13 +++++++++++++ examples/using_inline_bots.py | 17 ----------------- examples/{welcome.py => welcomebot.py} | 0 8 files changed, 23 insertions(+), 27 deletions(-) rename examples/{keyboards.py => bot_keyboards.py} (99%) rename examples/{chat_members.py => get_chat_members.py} (100%) rename examples/{dialogs.py => get_dialogs.py} (72%) rename examples/{history.py => get_history.py} (100%) create mode 100644 examples/use_inline_bots.py delete mode 100644 examples/using_inline_bots.py rename examples/{welcome.py => welcomebot.py} (100%) diff --git a/examples/README.md b/examples/README.md index 643fe56d09..b8898a718a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -12,12 +12,12 @@ Example | Description ---: | :--- [**hello_world**](hello_world.py) | Demonstration of basic API usage [**echobot**](echobot.py) | Echo every private text message -[**welcome**](welcome.py) | The Welcome Bot in [@PyrogramChat](https://t.me/pyrogramchat) -[**history**](history.py) | Get the full message history of a chat -[**chat_members**](chat_members.py) | Get all the members of a chat -[**dialogs**](dialogs.py) | Get all of your dialog chats -[**using_inline_bots**](using_inline_bots.py) | Query an inline bot (as user) and send a result to a chat -[**keyboards**](keyboards.py) | Send normal and inline keyboards using regular bots -[**callback_queries**](callback_queries.py) | Handle queries coming from inline button presses -[**inline_queries**](inline_queries.py) | Handle inline queries +[**welcomebot**](welcomebot.py) | The Welcome Bot in [@PyrogramChat](https://t.me/pyrogramchat) +[**get_history**](get_history.py) | Get the full message history of a chat +[**get_chat_members**](get_chat_members.py) | Get all the members of a chat +[**get_dialogs**](get_dialogs.py) | Get all of your dialog chats +[**callback_queries**](callback_queries.py) | Handle callback queries (as bot) coming from inline button presses +[**inline_queries**](inline_queries.py) | Handle inline queries (as bot) and answer with results +[**use_inline_bots**](use_inline_bots.py) | Query an inline bot (as user) and send a result to a chat +[**bot_keyboards**](bot_keyboards.py) | Send normal and inline keyboards using regular bots [**raw_updates**](raw_updates.py) | Handle raw updates (old, should be avoided) diff --git a/examples/keyboards.py b/examples/bot_keyboards.py similarity index 99% rename from examples/keyboards.py rename to examples/bot_keyboards.py index 1a1140b645..4cbe8eaab0 100644 --- a/examples/keyboards.py +++ b/examples/bot_keyboards.py @@ -1,4 +1,4 @@ -"""This example will show you how to send normal and inline keyboards. +"""This example will show you how to send normal and inline keyboards (as bot). You must log-in as a regular bot in order to send keyboards (use the token from @BotFather). Any attempt in sending keyboards with a user account will be simply ignored by the server. diff --git a/examples/chat_members.py b/examples/get_chat_members.py similarity index 100% rename from examples/chat_members.py rename to examples/get_chat_members.py diff --git a/examples/dialogs.py b/examples/get_dialogs.py similarity index 72% rename from examples/dialogs.py rename to examples/get_dialogs.py index 08c769e2d6..92da8834c9 100644 --- a/examples/dialogs.py +++ b/examples/get_dialogs.py @@ -1,4 +1,4 @@ -"""This example shows how to get the full dialogs list of a user.""" +"""This example shows how to get the full dialogs list (as user).""" from pyrogram import Client diff --git a/examples/history.py b/examples/get_history.py similarity index 100% rename from examples/history.py rename to examples/get_history.py diff --git a/examples/use_inline_bots.py b/examples/use_inline_bots.py new file mode 100644 index 0000000000..5681df8778 --- /dev/null +++ b/examples/use_inline_bots.py @@ -0,0 +1,13 @@ +"""This example shows how to query an inline bot (as user)""" + +from pyrogram import Client + +# Create a new Client +app = Client("my_account") + +with app: + # Get bot results for "Fuzz Universe" from the inline bot @vid + bot_results = app.get_inline_bot_results("vid", "Fuzz Universe") + + # Send the first result (bot_results.results[0]) to your own chat (Saved Messages) + app.send_inline_bot_result("me", bot_results.query_id, bot_results.results[0].id) diff --git a/examples/using_inline_bots.py b/examples/using_inline_bots.py deleted file mode 100644 index c3b48874cc..0000000000 --- a/examples/using_inline_bots.py +++ /dev/null @@ -1,17 +0,0 @@ -"""This example shows how to query an inline bot""" - -from pyrogram import Client - -# Create a new Client -app = Client("my_account") - -# Start the Client -app.start() - -# Get bot results for "Fuzz Universe" from the inline bot @vid -bot_results = app.get_inline_bot_results("vid", "Fuzz Universe") -# Send the first result (bot_results.results[0]) to your own chat (Saved Messages) -app.send_inline_bot_result("me", bot_results.query_id, bot_results.results[0].id) - -# Stop the client -app.stop() diff --git a/examples/welcome.py b/examples/welcomebot.py similarity index 100% rename from examples/welcome.py rename to examples/welcomebot.py