Skip to content

Commit 30664b2

Browse files
committed
Remove "schedule" from docs
1 parent ce729fa commit 30664b2

1 file changed

Lines changed: 15 additions & 43 deletions

File tree

docs/source/topics/scheduling.rst

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ Scheduling Tasks
44
Scheduling tasks means executing one or more functions periodically at pre-defined intervals or after a delay. This is
55
useful, for example, to send recurring messages to specific chats or users.
66

7-
Since there's no built-in task scheduler in Pyrogram, this page will only show examples on how to integrate Pyrogram
8-
with the main Python schedule libraries such as ``schedule`` and ``apscheduler``. For more detailed information, you can
9-
visit and learn from each library documentation.
7+
This page will show examples on how to integrate Pyrogram with ``apscheduler`` in both asynchronous and
8+
non-asynchronous contexts. For more detailed information, you can visit and learn from the library documentation.
109

1110
.. contents:: Contents
1211
:backlinks: none
@@ -15,79 +14,52 @@ visit and learn from each library documentation.
1514

1615
-----
1716

18-
Using ``schedule``
19-
------------------
20-
21-
- Install with ``pip3 install schedule``
22-
- Documentation: https://schedule.readthedocs.io
23-
24-
.. code-block:: python
25-
26-
import time
27-
28-
import schedule
29-
30-
from pyrogram import Client
31-
32-
app = Client("my_account")
33-
34-
35-
def job():
36-
app.send_message("me", "Hi!")
37-
38-
39-
schedule.every(3).seconds.do(job)
40-
41-
with app:
42-
while True:
43-
schedule.run_pending()
44-
time.sleep(1)
45-
46-
47-
4817
Using ``apscheduler``
4918
---------------------
5019

5120
- Install with ``pip3 install apscheduler``
5221
- Documentation: https://apscheduler.readthedocs.io
5322

23+
Asynchronously
24+
^^^^^^^^^^^^^^
25+
5426
.. code-block:: python
5527
56-
from apscheduler.schedulers.background import BackgroundScheduler
28+
from apscheduler.schedulers.asyncio import AsyncIOScheduler
5729
5830
from pyrogram import Client
5931
6032
app = Client("my_account")
6133
6234
63-
def job():
64-
app.send_message("me", "Hi!")
35+
async def job():
36+
await app.send_message("me", "Hi!")
6537
6638
67-
scheduler = BackgroundScheduler()
39+
scheduler = AsyncIOScheduler()
6840
scheduler.add_job(job, "interval", seconds=3)
6941
7042
scheduler.start()
7143
app.run()
7244
73-
``apscheduler`` does also support async code, here's an example:
45+
Non-Asynchronously
46+
^^^^^^^^^^^^^^^^^^
7447

7548
.. code-block:: python
7649
77-
from apscheduler.schedulers.asyncio import AsyncIOScheduler
50+
from apscheduler.schedulers.background import BackgroundScheduler
7851
7952
from pyrogram import Client
8053
8154
app = Client("my_account")
8255
8356
84-
async def job():
85-
await app.send_message("me", "Hi!")
57+
def job():
58+
app.send_message("me", "Hi!")
8659
8760
88-
scheduler = AsyncIOScheduler()
61+
scheduler = BackgroundScheduler()
8962
scheduler.add_job(job, "interval", seconds=3)
9063
9164
scheduler.start()
9265
app.run()
93-

0 commit comments

Comments
 (0)