diff --git a/main.py b/main.py index f60fc4f..656258f 100644 --- a/main.py +++ b/main.py @@ -21,6 +21,9 @@ class Config(BaseModel): def signal_timestamp_to_datetime(timestamp: str) -> datetime.datetime: return datetime.datetime.fromtimestamp(int(timestamp)/1000) +def now(): + return datetime.datetime.now() + T = TypeVar("T") class Changes[T](BaseModel): @@ -391,8 +394,8 @@ class LabCleaningBot: if is_err(sync_result): print(sync_result.unwrap_err()) - for task in get_active_tasks(session, utc_now()): - reqs = task.create_additional_requests(utc_now(), session) + for task in get_active_tasks(session, now()): + reqs = task.create_additional_requests(now(), session) if is_err(reqs): if task not in unfulfillable_tasks: @@ -424,7 +427,7 @@ You have time to answer for {format_seconds(task.timeout)}.""" print(res.unwrap_err()) # check for timeouts - for request in task.freshly_expired_requests(datetime.datetime.now()): + for request in task.freshly_expired_requests(now()): print("Request expired:", repr(request)) message = SendMessageSimple( message="You did not respond to the task request in time.",