From c8bc3ec58420c686acba019895aa4de8119f3016 Mon Sep 17 00:00:00 2001 From: William Kray Date: Fri, 22 Jul 2022 16:16:42 -0700 Subject: [PATCH] include a response of who was added/dropped during sync command --- kickbot/bot.py | 9 +++++++++ maubot.yaml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/kickbot/bot.py b/kickbot/bot.py index b5428bd..6100f28 100644 --- a/kickbot/bot.py +++ b/kickbot/bot.py @@ -64,6 +64,8 @@ class KickBot(Plugin): table_user_list = [ row["mxid"] for row in table_users ] untracked_users = set(space_members_list) - set(table_user_list) non_space_members = set(table_user_list) - set(space_members_list) + added = [] + dropped = [] try: for user in untracked_users: now = int(time.time() * 1000) @@ -72,11 +74,18 @@ class KickBot(Plugin): VALUES ($1, $2) """ await self.database.execute(q, user, now) + added.append(user) self.log.info(f"{user} inserted into activity tracking table") for user in non_space_members: await self.database.execute("DELETE FROM user_events WHERE mxid = $1", user) self.log.info(f"{user} is not a space member, dropped from activity tracking table") + dropped.append(user) await evt.react("✅") + + added_str = "
".join(added) + dropped_str = "
".join(dropped) + await evt.respond(f"Added: {added_str}

Dropped: {dropped_str}", allow_html=True) + except Exception as e: self.log.exception(e) else: diff --git a/maubot.yaml b/maubot.yaml index 8178cf0..2e77068 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: org.jobmachine.kickbot -version: 0.0.1 +version: 0.0.4 modules: - kickbot main_class: KickBot