diff --git a/main.py b/main.py index 67b3621..e2f05a0 100644 --- a/main.py +++ b/main.py @@ -334,6 +334,14 @@ class LabCleaningBot: else: print(res.unwrap_err()) + # check for timeouts + for request in task.freshly_expired_requests(datetime.datetime.now()): + print("Request expired:", repr(request)) + message = SendMessageSimple( + message="You did not respond to the task request in time.", + recipients=[request.user.name]) + res = self.api.send_message(message) + session.commit() await asyncio.sleep(1) diff --git a/models.py b/models.py index 33b14b1..9020d1f 100644 --- a/models.py +++ b/models.py @@ -113,6 +113,8 @@ class Task(SQLModel, table=True): if maybe_timeout is not None: expired_requests.append(r) + return expired_requests + def create_additional_requests(self, now: datetime.datetime, session: Session) -> Result[List["ParticipationRequest"], List["ParticipationRequest"]]: additional_requests = []