From fe88f4ac107cfed1210fbc044d412512e6bd5a5d Mon Sep 17 00:00:00 2001 From: PC-Admin Date: Mon, 14 Aug 2023 22:46:05 +0800 Subject: [PATCH] add alert messaging for when redlight server has unexpected response (fail softly) --- redlight_client_module.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/redlight_client_module.py b/redlight_client_module.py index d6fe3bb..fc751bc 100755 --- a/redlight_client_module.py +++ b/redlight_client_module.py @@ -129,9 +129,11 @@ class RedlightClientModule: logger.info(f"User {user} allowed to join room {room}.") return NOT_SPAM # Allow the user to join. else: - # Handle unexpected responses by logging them and allowing the user to join as a fallback. - logger.error(f"Unexpected response code {response.code} with body: {response_body}") - logger.warn(f"Defaulting to allowing user {user} to join due to unexpected response code.") + alert_message = f"Unexpected response code {response.code} with body {response_body}. Defaulting to allowing user {user} to join due to unexpected response code." + # Handle unexpected responses by alerting and logging them, and allowing the user to join as a fallback. + logger.error(alert_message) + loop = asyncio.get_event_loop() + loop.run_in_executor(None, self.bot.send_alert_message, self._redlight_alert_room, alert_message) return NOT_SPAM # Function to parse the module's configuration.