class SchedulerPlugin(IPlugin): """Plugin to support scheduling messages to be parsed at a later date. Special tags #weekly, #daily, #hourly are do what they should do, although the behaviour of messages which give these tags with a datum time is undefined. These frequency tags can be combined, though I am not sure of the utility (or even bug-free-ness) of this in its current implementation. The interplay between timezones: * server in one TZ and user in another, * "remind at 10pm" is also not thoroughly tested, and not expected to work. """ def __init__(self, parser=None, db=None): self.is_followed_by = ["scheduling"] self.parser = parser self.db = db self.properties = None def install(self, ctx): self.scheduler = Scheduler() self.properties["scheduler"] = self.scheduler def start_up(self, ctx): ctx.er.parser_filters.add(TimedReminder()) ctx.er.parser_filters.add(FrequencyTagDetector()) ctx.er.parser_actions.add(ScheduleAction(self.scheduler)) commands = Commands() ctx.er.message_patterns.add("^scheduler", commands.inspect_scheduler) ctx.er.message_patterns.add("^(remind( me)?|r( me)?|echo|remember) (?P<reminder_text>.*)", commands.remind_me) ctx.er.template_files.add(self, "ui/templates/scheduler_commands.txt") ctx.er.phrase_banks.add(self, "ui/templates/zander_scheduler_commands.txt") def run(self): self.scheduler.start() def stop(self): self.scheduler.dispose()
def install(self, ctx): self.scheduler = Scheduler() self.properties["scheduler"] = self.scheduler