]> git.somenet.org - pub/jan/mattermost-bot.git/blob - modules/CommandLernrauminfo.py
new file: modules/CommandFSOpen.py
[pub/jan/mattermost-bot.git] / modules / CommandLernrauminfo.py
1 # Mattermost Bot module.
2 #  Copyright (c) 2016-2022 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
3 #  notable mention: Ju <daju@fsinf.at> and @baerza
4 #  published under MIT-License
5
6 from inspect import cleandoc
7
8
9 # pylint: disable=wrong-import-position
10 from AbstractCommand import AbstractCommand
11 class CommandLernrauminfo(AbstractCommand):
12     TRIGGER = "lernrauminfo"
13     CONFIG = {"display_name": "somebot-command", "auto_complete": True,
14               "auto_complete_hint": "",
15              }
16     USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Remind of Lernraum channel / is anybody at the fsinf."
17
18
19     def on_POST(self, request, data):
20         msg = cleandoc("""``AUTODELETE-DAY``
21             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).
22             """)
23
24         att = [{
25             "text": "Falls du dir nicht sicher bist, ob du schon im Channel bist...",
26             "actions": [{
27                 "name": "/join (Lern-)Räume :+1:",
28                 "integration": {"url": self.URL+"/interactive", "context": {"action": "click"}}
29                 }]
30             }]
31
32         request.respond_cmd_chan(msg, att=att)
33
34
35     def on_POST_interactive(self, request, data):
36         if data["context"]["action"] == "click":
37             self.bot.api.add_user_to_channel("3qu3dyzbupgm9kodrqaijwntgc", data["user_id"])
38             request.respond_interactive_temp("## :white_check_mark: Success! :)\n### Du solltest gejoint worden sein nach: https://mattermost.fsinf.at/fsinf/channels/raeume")