From 8a55c7e3465cddb0dd5153d90f6fbd4b7e0fd172 Mon Sep 17 00:00:00 2001 From: Someone Date: Wed, 28 Feb 2024 00:12:11 +0100 Subject: [PATCH] new file: modules/CommandFSOpen.py --- modules/CommandFSOpen.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 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"}) + -- 2.43.0