From e0eb3e99de83d24eb38eefdf4302b2c0ed3b5f7a Mon Sep 17 00:00:00 2001 From: Someone Date: Fri, 19 Jun 2020 01:32:13 +0200 Subject: [PATCH] [somebot] /beratungsinfo --- somebot/modules/CommandBeratungsinfo.py | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 somebot/modules/CommandBeratungsinfo.py diff --git a/somebot/modules/CommandBeratungsinfo.py b/somebot/modules/CommandBeratungsinfo.py new file mode 100644 index 0000000..8d735ca --- /dev/null +++ b/somebot/modules/CommandBeratungsinfo.py @@ -0,0 +1,35 @@ +# Mattermost Bot. +# Copyright (c) 2016-2020 by Someone (aka. Jan Vales ) +# published under MIT-License + + + +from AbstractCommand import * +class CommandBeratungsinfo(AbstractCommand): + TRIGGER = "beratungsinfo" + CONFIG = {"display_name": "somebot-command", "auto_complete": True, + "auto_complete_hint": "", + } + USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Where to get help." + + + def on_POST(self, request, data): + 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." + 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)" + att = [{ + "text": "Falls du dir nicht sicher bist, ob du schon im Channel bist...\n\nIf you are unsure whether you are in the Beratungschannel...", + "actions": [ + { + "name": "/join Beratungchannel :+1:", + "integration": { "url": self.URL+"/interactive", "context": { "action": "click" } } + } + ] + }] + + request.respond(200, {"response_type":"in_channel", "text":msg, "attachments":att}) + + + def on_POST_interactive(self, request, data): + if data["context"]["action"] == "click": + self.bot.api.add_user_to_channel("3qu3dyzbupgm9kodrqaijwntgc", data["user_id"]) + 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"}) -- 2.43.0