Add some telethon examples

スタークギャング 2021-02-03 22:31:58 +05:30
parent e8d70769f1
commit 7b63d34c88

@ -68,7 +68,8 @@ Here is a example for running a job (Function) everyday at 6am.
from apscheduler.schedulers.asyncio import AsyncIOScheduler from apscheduler.schedulers.asyncio import AsyncIOScheduler
async def greet_me(): async def greet_me():
print("Good morning Midhun") print("Good morning Midhun.")
await client.send_message('me', 'Good Morning To Myself !')
scheduler = AsyncIOScheduler() scheduler = AsyncIOScheduler()
scheduler.add_job(greet_me, trigger="cron", hour=06) scheduler.add_job(greet_me, trigger="cron", hour=06)
@ -81,7 +82,7 @@ You can also run a job at specific intervals, here is a example for it.
from apscheduler.schedulers.asyncio import AsyncIOScheduler from apscheduler.schedulers.asyncio import AsyncIOScheduler
async def this_will_run_at_every_one_hour(): async def this_will_run_at_every_one_hour():
print("One hour has passed") await client.send_message('me', 'One hour has passed.')
scheduler = AsyncIOScheduler() scheduler = AsyncIOScheduler()
scheduler.add_job(this_will_run_at_every_one_hour, 'interval', minutes=60) scheduler.add_job(this_will_run_at_every_one_hour, 'interval', minutes=60)
@ -89,6 +90,6 @@ scheduler.start()
``` ```
You can also set custom Time zone and also use database for running these functions. You can also set custom Time zone and also use database for running these functions.
This is more advance And works smoothly with telethon. This is more advance And works smoothly with Telethon.
Read more about this from [`Here`](https://apscheduler.readthedocs.io/en/stable) Read more about this from [`Here`](https://apscheduler.readthedocs.io/en/stable)