From bc22b85361a86ffd0f2d86361e9c602911c0f8bd Mon Sep 17 00:00:00 2001 From: Someone Date: Fri, 19 Jun 2020 01:32:13 +0200 Subject: [PATCH] [somebot] /hcf --- somebot/core/CoreCommandHCF.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 somebot/core/CoreCommandHCF.py diff --git a/somebot/core/CoreCommandHCF.py b/somebot/core/CoreCommandHCF.py new file mode 100644 index 0000000..d702220 --- /dev/null +++ b/somebot/core/CoreCommandHCF.py @@ -0,0 +1,33 @@ +# Mattermost Bot. +# Copyright (c) 2016-2020 by Someone (aka. Jan Vales ) +# 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) -- 2.43.0