]> git.somenet.org - pub/jan/mattermost.git/blob - somebot/modules/CommandBeratungsinfo.py
[somebot] /beratungsinfo
[pub/jan/mattermost.git] / somebot / modules / CommandBeratungsinfo.py
1 # Mattermost Bot.
2 #  Copyright (c) 2016-2020 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
3 #  published under MIT-License
4
5
6
7 from AbstractCommand import *
8 class CommandBeratungsinfo(AbstractCommand):
9     TRIGGER = "beratungsinfo"
10     CONFIG = {"display_name": "somebot-command", "auto_complete": True,
11         "auto_complete_hint": "",
12     }
13     USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Where to get help."
14
15
16     def on_POST(self, request, data):
17         msg = "``BOT-AUTODELETE-FAST``\nFragen zum Studium oder anderer Uni-Themen werden im [Beratungschannel](https://mattermost.fsinf.at/fsinf/channels/beratung) im [FSInf-Team](https://mattermost.fsinf.at/~invite~fsinf) beantwortet."
18         msg += "\n\n----\nQuestions regarding the curriculum or other university-related topics are answered in the [Beratungschannel](https://mattermost.fsinf.at/fsinf/channels/beratung) in the [FSInf-Team](https://mattermost.fsinf.at/~invite~fsinf)"
19         att = [{
20               "text": "Falls du dir nicht sicher bist, ob du schon im Channel bist...\n\nIf you are unsure whether you are in the Beratungschannel...",
21               "actions": [
22                 {
23                   "name": "/join Beratungchannel :+1:",
24                   "integration": { "url": self.URL+"/interactive", "context": { "action": "click" } }
25                 }
26                 ]
27               }]
28
29         request.respond(200, {"response_type":"in_channel", "text":msg, "attachments":att})
30
31
32     def on_POST_interactive(self, request, data):
33         if data["context"]["action"] == "click":
34             self.bot.api.add_user_to_channel("3qu3dyzbupgm9kodrqaijwntgc", data["user_id"])
35             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"})