From dc16bbf5812ec23f9b952864dad6da2df1d2a621 Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 10 Jan 2022 18:13:06 +0100 Subject: [PATCH] modules/CommandJoinActive.py --- modules/CommandJoinActive.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/CommandJoinActive.py b/modules/CommandJoinActive.py index 53a0e1f..93df366 100644 --- a/modules/CommandJoinActive.py +++ b/modules/CommandJoinActive.py @@ -41,20 +41,20 @@ class CommandJoinActive(AbstractCommand): return logger.info("_index_channels(): started") - new_dict = dict() - for c in self.bot.api.get_team_channels(self.TEAM_ID): - if c["id"] in self.skip_chann_ids: + new_dict = {} + for chan in self.bot.api.get_team_channels(self.TEAM_ID): + if chan["id"] in self.skip_chann_ids: continue posts = [] - for p in self.bot.api.get_posts_for_channel(c["id"]): - if p["type"] in ["", "slack_attachement"]: - posts.append(p) + for post in self.bot.api.get_posts_for_channel(chan["id"]): + if post["type"] in ["", "slack_attachement"]: + posts.append(post) if len(posts) == 5: break - new_dict[c["id"]] = min([x["create_at"] for x in posts]) + new_dict[chan["id"]] = min([x["create_at"] for x in posts]) self.channel_index = new_dict self.channel_index_th = threading.Timer(3600.0, self._index_channels) @@ -77,11 +77,11 @@ class CommandJoinActive(AbstractCommand): timestamp = int((datetime.datetime.now()-td).timestamp())*1000 msg = "" - for c in self.bot.api.get_team_channels(self.TEAM_ID): + for chan in self.bot.api.get_team_channels(self.TEAM_ID): #check against ban list and get the last 10 posts, if all of them are newer than min_timestamp: join - if not c["id"] in self.skip_chann_ids and self.channel_index[c["id"]] > timestamp: - self.bot.api.add_user_to_channel(c["id"], data["user_id"]) - msg += "\n + ~"+c["name"] + if not chan["id"] in self.skip_chann_ids and self.channel_index[chan["id"]] > timestamp: + self.bot.api.add_user_to_channel(chan["id"], data["user_id"]) + msg += "\n + ~"+chan["name"] request.respond_cmd_temp(cleandoc(""" ## :white_check_mark: Success! :) -- 2.43.0