Fix events expiration
This commit is contained in:
parent
f2c44a1108
commit
e9cea5d010
3 changed files with 4 additions and 4 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue