From 1d938512e261ffa0ba643371d5d56c1f193ed96f Mon Sep 17 00:00:00 2001 From: William Kray Date: Mon, 26 Aug 2024 11:58:17 -0700 Subject: [PATCH] include ignored users in report command --- community/bot.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/community/bot.py b/community/bot.py index 51be2e8..e762302 100644 --- a/community/bot.py +++ b/community/bot.py @@ -99,11 +99,16 @@ class CommunityBot(Plugin): SELECT mxid FROM user_events WHERE last_message_timestamp <= $1 AND ignore_inactivity = 0 """ + ignored_q = """ + SELECT mxid FROM user_events WHERE ignore_inactivity = 1 + """ warn_inactive_results = await self.database.fetch(warn_q, warn_days_ago, kick_days_ago) kick_inactive_results = await self.database.fetch(kick_q, kick_days_ago) + ignored_results = await self.database.fetch(ignored_q) report = {} report["warn_inactive"] = [ row["mxid"] for row in warn_inactive_results ] or ["none"] report["kick_inactive"] = [ row["mxid"] for row in kick_inactive_results ] or ["none"] + report["ignored"] = [ row["mxid"] for row in ignored_results ] or ["none"] return report @@ -212,10 +217,13 @@ class CommunityBot(Plugin): async def get_report(self, evt: MessageEvent) -> None: sync_results = await self.do_sync() report = await self.generate_report() - await evt.respond(f"Users inactive for at least {self.config['warn_threshold_days']} days:
\ + await evt.respond(f"Users inactive for between {self.config['warn_threshold_days']} and \ + {self.config['kick_threshold_days']} days:
\ {'
'.join(report['warn_inactive'])}
\ Users inactive for at least {self.config['kick_threshold_days']} days:
\ - {'
'.join(report['kick_inactive'])}", \ + {'
'.join(report['kick_inactive'])}
\ + Ignored users:
\ + {'
'.join(report['ignored'])}", \ allow_html=True)