From e9cea5d010366e90cc15fbd08b4f25e538d0b5a4 Mon Sep 17 00:00:00 2001 From: nemunaire Date: Fri, 29 Jul 2016 02:55:24 +0200 Subject: [PATCH] Fix events expiration --- modules/worldcup.py | 2 +- nemubot/bot.py | 4 ++-- nemubot/event/__init__.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/worldcup.py b/modules/worldcup.py index 512a247..7b4f53d 100644 --- a/modules/worldcup.py +++ b/modules/worldcup.py @@ -133,7 +133,7 @@ def prettify(match): if match["status"] == "completed": msg += "Match (%s) du %s terminé : " % (match["match_number"], matchdate.strftime("%A %d à %H:%M")) else: - msg += "Match en cours (%s) depuis %d minutes : " % (match["match_number"], (datetime.now(matchdate.tzinfo) - matchdate_local).seconds / 60) + msg += "Match en cours (%s) depuis %d minutes : " % (match["match_number"], (datetime.now(matchdate.tzinfo) - matchdate_local).total_seconds() / 60) msg += "%s %d - %d %s" % (match["home_team"]["country"], match["home_team"]["goals"], match["away_team"]["goals"], match["away_team"]["country"]) diff --git a/nemubot/bot.py b/nemubot/bot.py index 0adb587..e449f35 100644 --- a/nemubot/bot.py +++ b/nemubot/bot.py @@ -331,7 +331,7 @@ class Bot(threading.Thread): module_src.__nemubot_context__.events.append(evt.id) evt.module_src = module_src - logger.info("New event registered: %s -> %s", evt.id, evt) + logger.info("New event registered in %d position: %s", i, t) return evt.id @@ -382,7 +382,7 @@ class Bot(threading.Thread): self.event_timer.cancel() if len(self.events): - remaining = self.events[0].time_left.seconds + self.events[0].time_left.microseconds / 1000000 + remaining = self.events[0].time_left.total_seconds() logger.debug("Update timer: next event in %d seconds", remaining) self.event_timer = threading.Timer(remaining if remaining > 0 else 0, self._end_event_timer) self.event_timer.start() diff --git a/nemubot/event/__init__.py b/nemubot/event/__init__.py index 7b2adfd..c45081c 100644 --- a/nemubot/event/__init__.py +++ b/nemubot/event/__init__.py @@ -95,7 +95,7 @@ class ModuleEvent: """Return the time left before/after the near check""" if self.current is not None: return self.current - datetime.now(timezone.utc) - return 99999 # TODO: 99999 is not a valid time to return + return timedelta.max def check(self): """Run a check and realized the event if this is time"""