from inspect import cleandoc
+import datetime
+import dateutil.parser
+import holidays
# pylint: disable=wrong-import-position
from AbstractCommand import AbstractCommand
}
USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Is fsinf open?"
- cmd_state = live_state = "Unknown"
+ cmd_state = msg_state = "Wos waas i" # unknown
def __init__(self, team_id, channel_id):
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:
+ if "ubahn_warnung" in data:
+ day=datetime.date.today()
+ if "## :white_check_mark: FsInf opening - Kumm ume!" in self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].msg_state.strip() and not (day.weekday() == 5 or day.weekday() == 6 or holidays.AT().get(day)):
+ self.bot.api.create_post(self.channel_id, data["ubahn_warnung"], props={"somecleaner_autodelete":"day"})
+ return
+
+ if data["cmd_state"] != self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].cmd_state or data["msg_state"] != self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].msg_state:
+ if self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].msg_state != "Wos waas i":
+ self.bot.api.create_post(self.channel_id, data["msg_state"], props={"somecleaner_autodelete":"day"})
+ if "## :white_check_mark: FsInf opening - Kumm ume!" in data["msg_state"]:
+ try:
+ self.bot.api._post("/v4/commands/execute", data={"channel_id":"e7ed3sdhbbba5xi86uaqbc4f8o", "command":"/fsinf-control open"});
+ except:
+ pass
+ else:
+ try:
+ self.bot.api._post("/v4/commands/execute", data={"channel_id":"e7ed3sdhbbba5xi86uaqbc4f8o", "command":"/fsinf-control close"});
+ except:
+ pass
+
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"})
+ self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].msg_state=data["msg_state"]
+ request.respond_public(200, {"status":"changed"})
+ else:
+ request.respond_public(200, {"status":"unchanged"})