Scheduler
Scheduler wraps APScheduler's AsyncIOScheduler to let you run recurring tasks inside a bot. Jobs are defined with standard cron expressions and are automatically started alongside the bot.
from matrix import Bot
bot = Bot()
@bot.scheduler.job("0 9 * * 1-5") # weekdays at 09:00
async def morning_standup():
room = bot.get_room("!abc123:matrix.org")
await room.send_text("Good morning, team! 🌅")
matrix.scheduler.Scheduler
Scheduler()
The Scheduler class used to schedule tasks for a bot.
Uses APScheduler under the hood.
Source code in matrix/scheduler.py
10 11 12 13 14 15 | |
scheduler
instance-attribute
scheduler = AsyncIOScheduler()
jobs
property
jobs
schedule
schedule(cron, func)
Schedule a coroutine function to be run at specified intervals.
Example
@bot.schedule("0 9 * * 1-5")
async def morning_update() -> None:
await room.send("Good morning!")
Source code in matrix/scheduler.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
start
start()
Start the scheduler.
Source code in matrix/scheduler.py
51 52 53 | |