From 33df446c833bcb9412b156a589fe024432df46aa Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 10 Jan 2022 19:27:34 +0100 Subject: [PATCH] modules/TACommandWipeChannel.py --- modules/TACommandWipeChannel.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/TACommandWipeChannel.py b/modules/TACommandWipeChannel.py index 4bb0cc6..02f66f4 100644 --- a/modules/TACommandWipeChannel.py +++ b/modules/TACommandWipeChannel.py @@ -17,19 +17,19 @@ class TACommandWipeChannel(AbstractCommand): def on_POST(self, request, data): self._require_team_admin(data) # will throw an exception if not. (Dont try-except: Its handled up the stack.) - u = self.bot.api.get_user_by_username(data["text"].strip(), exc=False) - if data["text"].strip() in ["--really-all", "--system"] and not u: + user = self.bot.api.get_user_by_username(data["text"].strip(), exc=False) + if data["text"].strip() in ["--really-all", "--system"] and not user: request.respond_cmd_err("``/"+self.TRIGGER+"`` parameter must be '--really-all', '--system' or a valid username.") return # needs indirection. see iterators. - posts = [p for p in self.bot.api.get_posts_for_channel(data["channel_id"])] - for p in posts: - if p["is_pinned"]: + posts = [post for post in self.bot.api.get_posts_for_channel(data["channel_id"])] + for post in posts: + if post["is_pinned"]: continue - if (data["text"].strip() == "--really-all") or (data["text"].strip() == "--system" and p["type"].startswith("system_")) or (data["text"].strip() != "" and u["id"] == p["user_id"]) or (data["text"].strip() == ""): - self.bot.api.delete_post(p["id"]) + if (data["text"].strip() == "--really-all") or (data["text"].strip() == "--system" and post["type"].startswith("system_")) or (data["text"].strip() != "" and user["id"] == post["user_id"]) or (data["text"].strip() == ""): + self.bot.api.delete_post(post["id"]) self.bot.debug_chan("``/ta-wipe-channel "+data["text"].strip()+"`` used by ``@"+data["user_name"]+"`` in ``"+data["team_domain"]+"::"+data["channel_name"]+"``") request.respond_cmd_temp("## :white_check_mark: Success! :)") -- 2.43.0