1 # Mattermost Bot module.
2 # Copyright (c) 2016-2024 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
3 # published under MIT-License
5 from inspect import cleandoc
8 # pylint: disable=wrong-import-position
9 from AbstractCommand import AbstractCommand
10 from AbstractPublicWS import AbstractPublicWS
11 class CommandFSOpen(AbstractCommand,AbstractPublicWS):
12 TRIGGER=NAME = "is-it-open"
13 CONFIG = {"display_name": "somebot-command", "auto_complete": True,
14 "auto_complete_hint": "",
16 USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Is fsinf open?"
18 cmd_state = live_state = "Unknown"
21 def __init__(self, team_id, channel_id):
22 super().__init__(team_id)
23 self.channel_id = channel_id
26 def on_POST(self, request, data):
27 request.respond_cmd_temp("## Is FSInf open?\n\n"+self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].cmd_state)
30 def on_public_POST(self, request, data):
31 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:
32 self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].cmd_state=data["cmd_state"]
33 self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].live_state=data["live_state"]
34 self.bot.api.create_post(self.channel_id, data["live_state"])
35 request.respond_public(200, {"status":"ok"})