From e11c080eead280bdc5272e6aad32cb8a98ae624b Mon Sep 17 00:00:00 2001 From: Someone Date: Fri, 19 Jun 2020 01:32:13 +0200 Subject: [PATCH] TODO [somebot] WS:WikiUpload --- somebot/modules/WSWikiUpload.py | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 somebot/modules/WSWikiUpload.py diff --git a/somebot/modules/WSWikiUpload.py b/somebot/modules/WSWikiUpload.py new file mode 100644 index 0000000..d389cb3 --- /dev/null +++ b/somebot/modules/WSWikiUpload.py @@ -0,0 +1,59 @@ +# Mattermost Bot. +# Copyright (c) 2016-2020 by Someone (aka. Jan Vales ) +# published under MIT-License + +import json + + +from AbstractWSHandler import * +class WSWikiUpload(AbstractWSHandler): + NAME = "wikiupload" + + def on_WS_EVENT(self, data): + if data["event"] != "posted" or 'file_ids' not in data['data']['post']: + return + + data['data']['post']=json.loads(data['data']['post']) + + msg = "``BOT-AUTODELETE-FAST``\nIs das n file, das retainenswert is?" + att = [{ + "text": "Als uploader_in kannst du das File mit einem Click auf Upload! ins Wiki hochladen", + "actions": [ + { + "name": "Retainenswert", + "integration": { "url": self.URL+"/interactive", "context": { "action": "click_yes" } } + }, { + "name": "Blödsinn", + "integration": { "url": self.URL+"/interactive", "context": { "action": "click_no" } } + }, { + "name": "Upload (Uploader_in only)", + "integration": { "url": self.URL+"/interactive", "context": { "action": "click_upload" } } + }, { + "name": "Nicht retainenswert (Uploader_in only)", + "integration": { "url": self.URL+"/interactive", "context": { "action": "click_nope" } } + } + ] + }, + ] + + self.bot.api.create_post(data['data']['post']['channel_id'], msg, props={"from_webhook":"true", "attachments":att}, root_id=data['data']['post']['id']) + + + + def on_POST_interactive(self, request, data): + import pprint + pprint.pprint(request) + pprint.pprint(data) + + if data["context"]["action"] == "click_nope": + request.respond(200, {"update":{"message":"``BOT-AUTODELETE-FAST`` Uploader_in hat gegen einen wiki-upload entschieden. :(", "props":{}}}) + + elif data["context"]["action"] == "click_upload": + request.respond(200, {"ephemeral_text": "Du bist leider ned der/die uploader_in :("}) + + elif data["context"]["action"] == "click_yes": + request.respond(200, {"ephemeral_text": "Deine Stimme wurde gezählt - vielleicht TODO"}) + + elif data["context"]["action"] == "click_no": + request.respond(200, {"ephemeral_text": "Deine Stimme wurde gezählt - vielleicht TODO"}) + -- 2.43.0