Fix events expiration
This commit is contained in:
parent
f2c44a1108
commit
e9cea5d010
@ -133,7 +133,7 @@ def prettify(match):
|
|||||||
if match["status"] == "completed":
|
if match["status"] == "completed":
|
||||||
msg += "Match (%s) du %s terminé : " % (match["match_number"], matchdate.strftime("%A %d à %H:%M"))
|
msg += "Match (%s) du %s terminé : " % (match["match_number"], matchdate.strftime("%A %d à %H:%M"))
|
||||||
else:
|
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"])
|
msg += "%s %d - %d %s" % (match["home_team"]["country"], match["home_team"]["goals"], match["away_team"]["goals"], match["away_team"]["country"])
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ class Bot(threading.Thread):
|
|||||||
module_src.__nemubot_context__.events.append(evt.id)
|
module_src.__nemubot_context__.events.append(evt.id)
|
||||||
evt.module_src = module_src
|
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
|
return evt.id
|
||||||
|
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ class Bot(threading.Thread):
|
|||||||
self.event_timer.cancel()
|
self.event_timer.cancel()
|
||||||
|
|
||||||
if len(self.events):
|
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)
|
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 = threading.Timer(remaining if remaining > 0 else 0, self._end_event_timer)
|
||||||
self.event_timer.start()
|
self.event_timer.start()
|
||||||
|
@ -95,7 +95,7 @@ class ModuleEvent:
|
|||||||
"""Return the time left before/after the near check"""
|
"""Return the time left before/after the near check"""
|
||||||
if self.current is not None:
|
if self.current is not None:
|
||||||
return self.current - datetime.now(timezone.utc)
|
return self.current - datetime.now(timezone.utc)
|
||||||
return 99999 # TODO: 99999 is not a valid time to return
|
return timedelta.max
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
"""Run a check and realized the event if this is time"""
|
"""Run a check and realized the event if this is time"""
|
||||||
|
Loading…
Reference in New Issue
Block a user