Skip to content

Commit 7ae9a06

Browse files
committed
Update examples
1 parent 491b96c commit 7ae9a06

18 files changed

+146
-241
lines changed

examples/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
This folder contains example scripts to show you how **Pyrogram** looks like.
44

5-
Every script is working right away (provided you correctly set up your credentials), meaning
6-
you can simply copy-paste and run. The only things you have to change are session names and target chats.
5+
Every script is working right away (provided you correctly set up your credentials), meaning you can simply copy-paste
6+
and run. The only things you have to change are session names and target chats.
77

88
All the examples listed in this directory are licensed under the terms of the [CC0 1.0 Universal](LICENSE) license and
99
can be freely used as basic building blocks for your own applications without worrying about copyrights.
1010

1111
Example | Description
1212
---: | :---
13-
[**hello_world**](hello_world.py) | Demonstration of basic API usages
14-
[**echo_bot**](echo_bot.py) | Echo bot that replies to every private text message
15-
[**welcome_bot**](welcome_bot.py) | The Welcome Bot source code in [@PyrogramChat](https://t.me/pyrogramchat)
16-
[**get_history**](get_history.py) | How to retrieve the full message history of a chat
17-
[**get_chat_members**](get_chat_members.py) | How to get the first 10.000 members of a supergroup/channel
18-
[**get_chat_members2**](get_chat_members2.py) | Improved version to get more than 10.000 members
19-
[**query_inline_bots**](query_inline_bots.py) | How to query an inline bot and send a result to a chat
20-
[**send_bot_keyboards**](send_bot_keyboards.py) | How to send normal and inline keyboards using regular bots
21-
[**callback_query_handler**](callback_query_handler.py) | How to handle queries coming from inline button presses
22-
[**raw_update_handler**](raw_update_handler.py) | How to handle raw updates (old, should be avoided)
13+
[**hello**](hello.py) | Demonstration of basic API usage
14+
[**echo**](echo.py) | Reply to every private text message
15+
[**welcome**](welcome.py) | The Welcome Bot in [@PyrogramChat](https://t.me/pyrogramchat)
16+
[**history**](history.py) | Get the full message history of a chat
17+
[**chat_members**](chat_members.py) | Get all the members of a chat
18+
[**dialogs**](dialogs.py) | Get all of your dialog chats
19+
[**inline_bots**](inline_bots.py) | Query an inline bot and send a result to a chat
20+
[**keyboards**](keyboards.py) | Send normal and inline keyboards using regular bots
21+
[**callback_queries**](callback_queries.py) | Handle queries coming from inline button presses
22+
[**raw_updates**](raw_updates.py) | Handle raw updates (old, should be avoided)

examples/chat_members.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""This example shows how to get all the members of a chat."""
2+
3+
from pyrogram import Client
4+
5+
app = Client("my_count")
6+
target = "pyrogramchat" # Target channel/supergroup
7+
8+
with app:
9+
for member in app.iter_chat_members(target):
10+
print(member.user.first_name)

examples/dialogs.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""This example shows how to get the full dialogs list of a user."""
2+
3+
from pyrogram import Client
4+
5+
app = Client("my_account")
6+
7+
with app:
8+
for dialog in app.iter_dialogs():
9+
print(dialog.chat.title or dialog.chat.first_name)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@app.on_message(Filters.text & Filters.private)
1313
def echo(client, message):
14-
message.reply(message.text, quote=True)
14+
message.reply(message.text)
1515

1616

1717
app.run() # Automatically start() and idle()

examples/get_chat_members.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/get_chat_members2.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

examples/get_history.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/hello.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""This example demonstrates a basic API usage"""
2+
3+
from pyrogram import Client
4+
5+
# Create a new Client instance
6+
app = Client("my_account")
7+
8+
with app:
9+
# Send a message, Markdown is enabled by default
10+
app.send_message("me", "Hi there! I'm using **Pyrogram**")
11+
12+
# Send a location
13+
app.send_location("me", 51.500729, -0.124583)
14+
15+
# Send a sticker
16+
app.send_sticker("me", "CAADBAADhw4AAvLQYAHICbZ5SUs_jwI")

examples/hello_world.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)