From 7dfc38bb5ca8fb5e0c2aee16b3c0cb5d4c5aa6c6 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 2 Jan 2016 04:25:47 -0500 Subject: [PATCH] Reminders that expire while the bot is offline trigger after startup. --- CHANGELOG | 3 ++- earwigbot/commands/remind.py | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 487237d..5256493 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,7 +3,8 @@ v0.3 (unreleased): - Copyvio detector: improved sentence splitting algorithm. - IRC > !notes: Improved help and added aliases. - IRC > !remind: Added !remind all. Fixed multithreading efficiency issues. - Improved time detection and argument parsing. + Improved time detection and argument parsing. Newly expired reminders are now + triggered on bot startup. - IRC > !stalk: Allow regular expressions as page titles or usernames. - IRC: Improved detection of maximum IRC message length. - IRC: Improved some help commands. diff --git a/earwigbot/commands/remind.py b/earwigbot/commands/remind.py index 42d0325..65638fe 100644 --- a/earwigbot/commands/remind.py +++ b/earwigbot/commands/remind.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2009-2015 Ben Kurtovic +# Copyright (C) 2009-2016 Ben Kurtovic # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -188,10 +188,13 @@ class Remind(Command): return permdb.set_attr("command:remind", "data", "[]") + connect_wait = 30 for item in ast.literal_eval(database): rid, user, wait, end, message, data = item - if end < time.time(): - continue + if end < time.time() + connect_wait: + # Make reminders that have expired while the bot was offline + # trigger shortly after startup + end = time.time() + connect_wait data = Data.unserialize(data) reminder = _Reminder(rid, user, wait, message, data, self, end) self._start_reminder(reminder, user)