]> git.somenet.org - pub/jan/mattermost-bot.git/blob - modules/CommandBeratungsinfo.py
requirements.txt
[pub/jan/mattermost-bot.git] / modules / CommandBeratungsinfo.py
1 # Mattermost Bot module.
2 #  Copyright (c) 2016-2022 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 # pylint: disable=wrong-import-position
9 from AbstractCommand import AbstractCommand
10 class CommandBeratungsinfo(AbstractCommand):
11     TRIGGER = "beratungsinfo"
12     CONFIG = {"display_name": "somebot-command", "auto_complete": True,
13               "auto_complete_hint": "",
14              }
15     USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = AbstractCommand.ICON_PUBLIC+"Where to get help."
16
17
18     def on_POST(self, request, data):
19         msg = cleandoc("""``AUTODELETE-DAY``
20             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
21             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)
22             """)
23
24         att = [{
25             "text": "Falls du dir nicht sicher bist, ob du schon im Channel bist...\n\nIf you are unsure whether you are in the Beratungschannel...",
26             "actions": [{
27                 "name": "/join Beratungchannel :+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: https://mattermost.fsinf.at/fsinf/channels/beratung\n\nYou should have been joined into: https://mattermost.fsinf.at/fsinf/channels/beratung")