]> git.somenet.org - pub/jan/mattermost-bot.git/blob - modules/CommandBeratungsinfo.py
[somebot] /drink*
[pub/jan/mattermost-bot.git] / modules / CommandBeratungsinfo.py
1 # Mattermost Bot module.
2 #  Copyright (c) 2016-2021 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 from AbstractCommand import AbstractCommand
9 class CommandBeratungsinfo(AbstractCommand):
10     TRIGGER = "beratungsinfo"
11     CONFIG = {"display_name": "somebot-command", "auto_complete": True,
12               "auto_complete_hint": "",
13              }
14     USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Where to get help."
15
16
17     def on_POST(self, request, data):
18         msg = cleandoc("""``AUTODELETE-DAY``
19             Fragen zum Studium oder anderer Uni-Themen werden im [Beratungschannel](https://mattermost.fsinf.at/fsinf/channels/beratung) im [Community-Team](https://mattermost.fsinf.at/~invite~fsinf) beantwortet.\n
20             Questions regarding the curriculum or other university-related topics are answered in the [Beratungschannel](https://mattermost.fsinf.at/fsinf/channels/beratung) in the [Community-Team](https://mattermost.fsinf.at/~invite~fsinf)
21             """)
22
23         att = [{
24             "text": "Falls du dir nicht sicher bist, ob du schon im Channel bist...\n\nIf you are unsure whether you are in the Beratungschannel...",
25             "actions": [{
26                 "name": "/join Beratungchannel :+1:",
27                 "integration": {"url": self.URL+"/interactive", "context": {"action": "click"}}
28                 }]
29             }]
30
31         request.respond(200, {"response_type":"in_channel", "text":msg, "attachments":att})
32
33
34     def on_POST_interactive(self, request, data):
35         if data["context"]["action"] == "click":
36             self.bot.api.add_user_to_channel("3qu3dyzbupgm9kodrqaijwntgc", data["user_id"])
37             request.respond(200, {"ephemeral_text": "Du solltest gejoint worden sein: https://mattermost.fsinf.at/fsinf/channels/beratung\n\nYou should have been joined into: https://mattermost.fsinf.at/fsinf/channels/beratung"})