justinweiss / robut

A simple plugin-enabled HipChat bot
171 stars 48 forks source link

Plugin activity on Robut startup... #31

Closed kitplummer closed 11 years ago

kitplummer commented 11 years ago

I'm pretty sure I know the answer already but I'm curious if anyone else is looking to do this, or if there's a work around. I've hacked together a cron job plugin - and I want to persist cron jobs via the store['jobs'] facility, which I can do no problem. But, what I'm really looking to do now, is have the plugin restore those jobs on a Robut restart - reading them from the file and resubmitting the jobs to rufus-scheduler. Any ideas on how to "initialize" stuff in Plugin-land when Robut starts?

justinweiss commented 11 years ago

You could initialize the plugin using a class method, in the Chatfile:

Robut::Plugin::Lunch.places = YAML.load_file(…)
Robut::Plugin.plugins << Robut::Plugin::Lunch

Would that work for you?

kitplummer commented 11 years ago

Yeh, I think that'll work. Cheers for the tip.