diff --git a/main.py b/main.py index e2f05a0..7220ed0 100644 --- a/main.py +++ b/main.py @@ -170,6 +170,7 @@ class LabCleaningBot: self.base_group = base_group def get_other_members(self) -> Result[List[str], str]: + # Get all members of the base group except the bot group = self.api.get_group(self.base_group) if group.is_err(): return Err(group.unwrap_err()) @@ -184,6 +185,8 @@ class LabCleaningBot: return Ok(other_members) def sync_members_as_active_users(self, session) -> Result[None, str]: + # Get all members of the base group and set them as active users + # if they are not already in the database maybe_members = self.get_other_members() if is_err(maybe_members): @@ -209,10 +212,13 @@ class LabCleaningBot: return Ok(None) def send_to_base_group(self, message: str) -> Result[None, str]: + # Send a message to the base group message = SendMessageSimple(message=message, recipients=[self.base_group]) return self.api.send_message(message) async def receiver(self, session: Session): + # Async routine that receives messages and calles message_received() for + # each message async for websocket in self.api.websocket_connect_receive(): try: while True: @@ -230,6 +236,7 @@ class LabCleaningBot: print("Websockets connection closed. Reestablishing connection.") def message_received(self, message: Message, session: Session): + # This method is called by the async receiver for each message envelope = message.envelope match envelope: @@ -298,6 +305,9 @@ class LabCleaningBot: print(emoji, "direct", sourceNumber, isRemove) async def sync_members_and_tasks(self, session: Session): + # Async routine that syncs active members using sync_members_as_active_users(), + # sends out new requests for tasks to active users and handles timeouts for the + # requests. unfulfillable_tasks = [] while True: