From 73e8a947f9f033fdb5680e739ac88f32a43bfa7e Mon Sep 17 00:00:00 2001 From: Someone Date: Fri, 19 Jun 2020 01:32:13 +0200 Subject: [PATCH] [somebot] /lernrauminfo --- somebot/modules/CommandLernrauminfo.py | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 somebot/modules/CommandLernrauminfo.py diff --git a/somebot/modules/CommandLernrauminfo.py b/somebot/modules/CommandLernrauminfo.py new file mode 100644 index 0000000..b3cd77d --- /dev/null +++ b/somebot/modules/CommandLernrauminfo.py @@ -0,0 +1,36 @@ +# Mattermost Bot. +# Copyright (c) 2016-2020 by Someone (aka. Jan Vales ) +# notable mention: Ju and @baerza +# published under MIT-License + + + +from AbstractCommand import * +class CommandLernrauminfo(AbstractCommand): + TRIGGER = "lernrauminfo" + CONFIG = {"display_name": "somebot-command", "auto_complete": True, + "auto_complete_hint": "", + } + USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Remind of Lernraum channel / is anybody at the fsinf." + + + def on_POST(self, request, data): + msg = "``BOT-AUTODELETE-FAST``\nWenn du wissen willst, ob gerade jemand auf der FsInf ist, oder am Wochenende offen ist, wende dich bitte an den [(Lern) Räume](https://mattermost.fsinf.at/fsinf/channels/raeume)-Channel im [FSInf-Team](https://mattermost.fsinf.at/~invite~fsinf)." + att = [{ + "text": "Falls du dir nicht sicher bist, ob du schon im Channel bist...", + "actions": [ + { + "name": "/join (Lern-)Räume :+1:", + "integration": { "url": self.URL+"/interactive", "context": { "action": "click" } } + } + ] + }] + + request.respond(200, {"response_type":"in_channel", "text":msg, "attachments":att}) + + + def on_POST_interactive(self, request, data): + if data["context"]["action"] == "click": + self.bot.api.add_user_to_channel("3qu3dyzbupgm9kodrqaijwntgc", data["user_id"]) + request.respond(200, {"ephemeral_text": "Du solltest gejoint worden sein: https://mattermost.fsinf.at/fsinf/channels/raeume"}) + -- 2.43.0