jaraco / irc

Full-featured Python IRC library for Python.
MIT License
390 stars 84 forks source link

Example code for scheduling? #167

Closed d33tah closed 3 years ago

d33tah commented 4 years ago

Hi! Thanks for this library!

I'd like to write a bot that just joins a channel and stays up, writing the same message every day at 21:37. Could you add such an example to the "scripts" directory so that I could see how to use the scheduler interface?

jaraco commented 3 years ago

It should be something like:

conn = reactor.server()

def send_message():
    conn.privmsg(target, message)

cmd = tempora.schedule.PeriodicCommandFixedDelay.daily_at(datetime.time(21, 37), send_message)
conn.schedule.add(cmd)

Care to test it out and put together a PR?

jaraco commented 3 years ago

Also, you may choose to use tempora.utc.time(21, 37) if you want time in UTC (may be required unless you configure the scheduler for using local time).