]> git.somenet.org - pub/jan/mattermost.git/blob - somebot/modules/CommandLernrauminfo.py
[somebot] /should_i_tu_it
[pub/jan/mattermost.git] / somebot / modules / CommandLernrauminfo.py
1 # Mattermost Bot.
2 #  Copyright (c) 2016-2020 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
7
8 from AbstractCommand import *
9 class CommandLernrauminfo(AbstractCommand):
10     TRIGGER = "lernrauminfo"
11     CONFIG = {"display_name": "somebot-command", "auto_complete": True,
12         "auto_complete_hint": "",
13     }
14     USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Remind of Lernraum channel / is anybody at the fsinf."
15
16
17     def on_POST(self, request, data):
18         msg = "``BOT-AUTODELETE-FAST``\nWenn 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 [FSInf-Team](https://mattermost.fsinf.at/~invite~fsinf)."
19         att = [{
20               "text": "Falls du dir nicht sicher bist, ob du schon im Channel bist...",
21               "actions": [
22                 {
23                   "name": "/join (Lern-)Räume :+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/raeume"})
36