From: Someone Date: Tue, 27 Feb 2024 23:12:11 +0000 (+0100) Subject: new file: modules/CommandFSOpen.py X-Git-Url: https://git.somenet.org/pub/jan/mattermost-bot.git/commitdiff_plain new file: modules/CommandFSOpen.py --- diff --git a/modules/CommandFSOpen.py b/modules/CommandFSOpen.py new file mode 100644 index 0000000..3023a79 --- /dev/null +++ b/modules/CommandFSOpen.py @@ -0,0 +1,36 @@ +# Mattermost Bot module. +# Copyright (c) 2016-2024 by Someone (aka. Jan Vales ) +# published under MIT-License + +from inspect import cleandoc + + +# pylint: disable=wrong-import-position +from AbstractCommand import AbstractCommand +from AbstractPublicWS import AbstractPublicWS +class CommandFSOpen(AbstractCommand,AbstractPublicWS): + TRIGGER=NAME = "is-it-open" + CONFIG = {"display_name": "somebot-command", "auto_complete": True, + "auto_complete_hint": "", + } + USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Is fsinf open?" + + cmd_state = live_state = "Unknown" + + + def __init__(self, team_id, channel_id): + super().__init__(team_id) + self.channel_id = channel_id + + + def on_POST(self, request, data): + request.respond_cmd_temp("## Is FSInf open?\n\n"+self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].cmd_state) + + + def on_public_POST(self, request, data): + if data["cmd_state"] != self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].cmd_state or data["live_state"] != self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].live_state: + self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].cmd_state=data["cmd_state"] + self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].live_state=data["live_state"] + self.bot.api.create_post(self.channel_id, data["live_state"]) + request.respond_public(200, {"status":"ok"}) +