diff --git a/edmond/plugins/reminder.py b/edmond/plugins/reminder.py index f067e79..8bb0011 100644 --- a/edmond/plugins/reminder.py +++ b/edmond/plugins/reminder.py @@ -1,6 +1,7 @@ import datetime import re import string +from typing import Optional from apscheduler.triggers.date import DateTrigger @@ -44,7 +45,7 @@ class ReminderPlugin(Plugin): return True # self.bot.scheduler.add_job(, 'cron', hour='1', minute='52') - def parse_time(self, time: str) -> dict[str, int] | None: + def parse_time(self, time: str) -> Optional[dict[str, int]]: """Parse a time request string. Return a dict with day/hour/minute/second set as integers if specified. @@ -80,7 +81,12 @@ class ReminderPlugin(Plugin): if mode == self.config["at_word"]: if "day" in time: # "day" is not supported in at mode. del time["day"] - when = now.replace(**time) + when = datetime.datetime.today().replace( + hour=time.get("hour", 0), + minute=time.get("minute", 0), + second=time.get("second", 0), + microsecond=0 + ) elif mode == self.config["in_word"]: time = { k + "s": v for k, v in time.items() } # Use plural names. when = now + datetime.timedelta(**time) @@ -99,6 +105,7 @@ class ReminderPlugin(Plugin): trigger=DateTrigger(when), args=(reminder, sender, target) ) + self.bot.log_d(f"Scheduled for {when}, time was {time}.") self.bot.say(target, self.config["done"]) async def remind(self, reminder: str, username: str, target: str) -> None: