Skip to content

Commit 142a27f

Browse files
committed
Use app.run() in the examples
1 parent fa65abf commit 142a27f

7 files changed

Lines changed: 10 additions & 15 deletions

File tree

examples/callback_query_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ def answer(client, callback_query):
3434
)
3535

3636

37-
app.start()
38-
app.idle()
37+
app.run() # Automatically start() and idle()

examples/echo_bot.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@ def echo(client, message):
3636
)
3737

3838

39-
app.start()
40-
app.idle()
39+
app.run() # Automatically start() and idle()

examples/get_history.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
"""This example shows how to retrieve the full message history of a chat"""
2525

2626
app = Client("my_account")
27-
app.start()
28-
2927
target = "me" # "me" refers to your own chat (Saved Messages)
3028
messages = [] # List that will contain all the messages of the target chat
3129
offset_id = 0 # ID of the last message of the chunk
3230

31+
app.start()
32+
3333
while True:
3434
try:
3535
m = app.get_history(target, offset_id=offset_id)

examples/get_participants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
"""
2929

3030
app = Client("my_account")
31-
app.start()
32-
3331
target = "pyrogramchat" # Target channel/supergroup
3432
users = [] # List that will contain all the users of the target chat
3533
limit = 200 # Amount of users to retrieve for each API call
3634
offset = 0 # Offset starts at 0
3735

36+
app.start()
37+
3838
while True:
3939
try:
4040
participants = app.send(

examples/get_participants2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@
3333
"""
3434

3535
app = Client("my_account")
36-
app.start()
37-
3836
target = "pyrogramchat" # Target channel/supergroup username or id
3937
users = {} # To ensure uniqueness, users will be stored in a dictionary with user_id as key
4038
limit = 200 # Amount of users to retrieve for each API call (200 is the maximum)
41-
4239
# "" + "0123456789" + "abcdefghijklmnopqrstuvwxyz" (as list)
4340
queries = [""] + [str(i) for i in range(10)] + list(ascii_lowercase)
4441

42+
app.start()
43+
4544
for q in queries:
4645
print("Searching for '{}'".format(q))
4746
offset = 0 # For each query, offset restarts from 0

examples/raw_update_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ def raw(client, update, users, chats):
2828
print(update)
2929

3030

31-
app.start()
32-
app.idle()
31+
app.run() # Automatically start() and idle()

examples/welcome_bot.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,4 @@ def welcome(client, message):
4949
)
5050

5151

52-
app.start()
53-
app.idle()
52+
app.run() # Automatically start() and idle()

0 commit comments

Comments
 (0)