--- /dev/null
+# Mattermost Bot.
+# Copyright (c) 2016-2020 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
+# published under MIT-License
+
+
+import os
+from inspect import cleandoc
+
+from AbstractCommand import AbstractCommand
+class CoreCommandHCF(AbstractCommand):
+ TRIGGER = "hcf"
+ CONFIG = {"display_name": "somebot-command", "auto_complete": False}
+ CONFIG["auto_complete_desc"] = CONFIG["description"] = "Halt, but cleanup first."
+ USEINFO = cleandoc("""
+ ``/hcf`` Halt and catch fire. Or actually halt but cleanup first.
+ Used to wipe all this bot user's commands and then fail horribly.
+ """)
+
+
+ def on_POST(self, request, data):
+ self._require_bot_admin(data) # will throw an exception if not. (Dont try-except: Its handled up the stack.)
+
+ request.cmd_respond_text_chan("### Halting and catching fire. bye...")
+
+ # wipe all commands creted by this bot (not limited to this instance!)
+ for team in self.bot.api.get_teams():
+ for command in self.bot.api.list_custom_slash_commands_per_team(team["id"]):
+ if command["display_name"] == "somebot-command":
+ self.bot.api.delete_slash_command(command["id"])
+
+ # fail horribly.
+ self.bot.shutdown()
+ os._exit(42)