diff --git a/modules/remind.py b/modules/remind.py index af08fc9..c1ac409 100755 --- a/modules/remind.py +++ b/modules/remind.py @@ -100,6 +100,17 @@ def remind_recur(bot, trigger): bot.reply(msg) +@module.require_admin +@module.commands('clear_dup_reminders') +def remind_recur(bot, trigger): + """ + Clear out duplicate reminders from Fulvia's memory. + This is only a temporary fix to the memory issue. + """ + bot.scheduler.tasks = list(dict.fromkeys(bot.scheduler.tasks)) + bot.scheduler.dump_database() + + def announce_reminder(bot, sched_time, channel, remindee, reminder, delta=None): """Announce the reminder.""" bot.msg(channel, reminder) diff --git a/scheduler.py b/scheduler.py index 02386d7..1b1efd9 100644 --- a/scheduler.py +++ b/scheduler.py @@ -71,3 +71,9 @@ class Scheduler: for task in tasks: t = tuple(pickle.loads(i) for i in task) self.tasks.append(t) + + def dump_database(self): + self.bot.db.execute("DELETE FROM scheduled_task") + for task in self.tasks: + t = tuple(pickle.dumps(i) for i in task) + self.bot.db.execute("INSERT INTO scheduled_task VALUES (?,?,?)", t)