[somebot] /lernrauminfo
authorSomeone <someone@somenet.org>
Wed, 8 Dec 2021 18:38:38 +0000 (19:38 +0100)
committerSomeone <someone@somenet.org>
Wed, 8 Dec 2021 18:38:38 +0000 (19:38 +0100)
modules/CommandLernrauminfo.py [new file with mode: 0644]

diff --git a/modules/CommandLernrauminfo.py b/modules/CommandLernrauminfo.py
new file mode 100644 (file)
index 0000000..2157a73
--- /dev/null
@@ -0,0 +1,37 @@
+# Mattermost Bot module.
+#  Copyright (c) 2016-2021 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
+#  notable mention: Ju <daju@fsinf.at> and @baerza
+#  published under MIT-License
+
+from inspect import cleandoc
+
+
+from AbstractCommand import AbstractCommand
+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 = cleandoc("""``AUTODELETE-DAY``
+            Wenn 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 [Community-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"})