From fce1f54a1f594df4d2f341582b15d9246d5511cd Mon Sep 17 00:00:00 2001
From: Someone <someone@somenet.org>
Date: Sun, 9 Jan 2022 00:57:52 +0100
Subject: [PATCH] modules/TACommandDelAnnounce.py

---
 modules/TACommandDelAnnounce.py | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/modules/TACommandDelAnnounce.py b/modules/TACommandDelAnnounce.py
index 9205257..b440948 100644
--- a/modules/TACommandDelAnnounce.py
+++ b/modules/TACommandDelAnnounce.py
@@ -4,32 +4,33 @@
 
 
 
-from AbstractCommand import *
+from AbstractCommand import AbstractCommand
 class TACommandDelAnnounce(AbstractCommand):
     TRIGGER = "ta-delete-announce"
     CONFIG = {"display_name": "somebot-command", "auto_complete": True,
               "auto_complete_hint": "<permalink>",
              }
-    CONFIG["auto_complete_desc"] = CONFIG["description"] = "Delete announcement referenced by <permalink>. Must be executed in the same team. [TEAM_ADMIN]"
+    CONFIG["auto_complete_desc"] = CONFIG["description"] = "📢 Delete announcement referenced by <permalink>. Must be executed in the same team. [TEAM_ADMIN]"
 
 
     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.)
 
+        msg_text = data['text'].strip().split(" ", 1)
+
         try:
-            splitpath = data['text'].strip().strip("/").split("/")
+            splitpath = msg_text[0].strip().strip("/").split("/")
             if splitpath[4] == "pl":
-                pl_post_id = splitpath[5]
+                post = self.bot.api.get_post(splitpath[5])
         except:
-            request.cmd_respond_text_temp("The parameter is not a valid post-permalink. :(")
+            request.respond_cmd_err("``/"+self.TRIGGER+"`` The first parameter is not a valid post-permalink or the permalinked post has been deleted.")
             return
 
-        post = self.bot.api.get_post(pl_post_id)
         channel = self.bot.api.get_channel(post["channel_id"])
 
-        if channel['team_id'] == data['team_id']:
-            self.bot.api.delete_post(splitpath[5])
-            request.cmd_respond_text_temp("### ``Done.`` :)")
+        if channel['team_id'] != data['team_id']:
+            request.respond_cmd_err("``/"+self.TRIGGER+"`` Must be executed in the same team as the permalinked post.")
+            return
 
-        else:
-            request.cmd_respond_text_temp("Falsches Team?")
+        self.bot.api.delete_post(splitpath[5])
+        request.respond_cmd_temp("## :white_check_mark: Success! :)")
-- 
2.43.0