-
-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scheduled callable events #1222
Comments
https://github.com/RebelCodeBase/sopel-rss Try .help at and .help in for your other question |
I looked at .help in and .help at I'm not looking for something that I call from within IRC, but directly in the module. I found a workaround, but I feel like there should be a better way:
I feel like what Sopel needs is something along the lines of:
|
Additional Ideas: Idea 1, optionally pass timezone along with it.
Wouldn't be often needed, but I could see it coming in handy. Idea 2I have some stuff that I like to run when the bot is starting. Right now, I use a poor method:
What I'd suggest is something more like:
Idea 3, what I sometimes do for the bot joining a new channel
should have something like:
|
@SpiceBot Apart from being off-topic for this issue, Idea 2 is already available if you define a method in your module called Idea 1 goes with this discussion, though. Timezone is probably a good optional parameter, yes. Fallback can be either UTC or |
Are you sure that it doesn't just run every 5 seconds anyway? |
As far as I'm concerned, this looks like it requires developers to write a Sopel plugin with the right usage of the @dgw we can consider this as a feature request, but I'm more or less thinking that we should decline this, and put an emphasis on documentation, eg. having better example of how |
Basically, anything we might implement would be a wrapper around standard library functionality. It's not worth having a decorator. Plus, as soon as we implement scheduling callables at the same time every day, someone will ask for choosing which days of the week/month/blah. Choosing multiple times. Choosing random times. All of which is pretty easily doable with stdlib tools, without any help from Sopel. 😸 |
@deathbybandaid, since I know you're still writing tons of plugin code, I'll leave you with a third-party-library approach and one of many stdlib-based examples. |
@dgw Yes, I tried couple of those but didn't get any output (yes, Timezone set to here, Europe/Helsinki). I'm not very experienced in Python so it's difficult for me to modify some raw python to sopel bot.say... Been searching for a long time an example sopel script that has timed message but have not find one yet. I'd just need bot to say something when it hits 00:00 (midnight) local time. |
Probably the easiest way to do it is by installing import schedule
from sopel import module
def scheduled_message(bot):
bot.say("This is the scheduled message.", "#channelname")
def setup(bot):
# schedule the message at midnight every day
schedule.every().day.at('00:00').do(scheduled_message, bot=bot)
@module.interval(60)
def run_schedule(bot):
schedule.run_pending() Note, I haven't tested this at all (not even syntax validation), but it's the general idea. You use Edge cases like the bot getting disconnected just as the scheduled job gets started aren't currently handled by the example code above, either. I'm very much rushing to get this typed out in between $day_job tasks. 😅 |
Finally gave it a go and couln't get it to work :( the message never triggers. |
Tested it again and figured it out. Fixed some syntax errors. Scheduled message for midnight works like this: def scheduled_message(bot):
bot.say('This is the scheduled message.', '#channel')
def setup(bot):
schedule.every().day.at('00:00').do(scheduled_message, bot=bot)
@sopel.module.interval(60)
def run_schedule(bot):
schedule.run_pending() Thanks! |
Well done. :) |
I see, I forgot a |
Hi, not really an issue, but I wanted to know if the functionality existed and how to use it.
I have an event that is at 7pm daily, I want sopel to announce it to the channel.
I also want sopel to check an rss feed for updates at regular intervals, and if there is new content, to announce it to the channel.
I see there is something called "jobs", but I'm not sure how to add "jobs"
Thanks!
The text was updated successfully, but these errors were encountered: