]> git.somenet.org - pub/jan/mattermost-bot.git/blob - modules/CommandFSOpen.py
new file: modules/CommandFSOpen.py
[pub/jan/mattermost-bot.git] / modules / CommandFSOpen.py
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
4
5 from inspect import cleandoc
6
7
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": "",
15              }
16     USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Is fsinf open?"
17
18     cmd_state = live_state = "Unknown"
19
20     
21     def __init__(self, team_id, channel_id):
22         super().__init__(team_id)
23         self.channel_id = channel_id
24
25
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)
28
29
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"})
36