X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fremind.rb;h=804e3f0bfd8968003182852d7b8b2f9b8727e6db;hb=16336b4a240a4265d1f2df1e30d7b68d3a924287;hp=78b3c0f24f7177d136c9f7a6fe11f74e2e888f05;hpb=7449580c5e83e290942ebe38cc157a339224e70d;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/remind.rb b/data/rbot/plugins/remind.rb index 78b3c0f2..804e3f0b 100644 --- a/data/rbot/plugins/remind.rb +++ b/data/rbot/plugins/remind.rb @@ -58,18 +58,19 @@ class RemindPlugin < Plugin else raise "invalid time string" end - when (/^(\d+):(\d+):(\d+)$/) + when (/^(\d+):(\d+)(?:\:(\d+))?$/) hour = $1.to_i min = $2.to_i sec = $3.to_i now = Time.now later = Time.mktime(now.year, now.month, now.day, hour, min, sec) - return later - now - when (/^(\d+):(\d+)$/) - hour = $1.to_i - min = $2.to_i - now = Time.now - later = Time.mktime(now.year, now.month, now.day, hour, min, now.sec) + + # if the given hour is earlier than current hour, given timestr + # must have been meant to be in the future + if hour < now.hour || hour <= now.hour && min < now.min + later += 60*60*24 + end + return later - now when (/^(\d+):(\d+)(am|pm)$/) hour = $1.to_i @@ -112,6 +113,7 @@ class RemindPlugin < Plugin } } @reminders.clear + super end def help(plugin, topic="") "reminder plugin: remind [about] in