add bandaid to fix reminder memory issue
This commit is contained in:
parent
7413860601
commit
736a98e274
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user