2 # Copyright (c) 2016-2020 by Someone <someone@somenet.org> (aka. Jan Vales <jan@jvales.net>)
3 # published under MIT-License
8 from AbstractWSHandler import *
9 class WSWikiUpload(AbstractWSHandler):
12 def on_WS_EVENT(self, data):
13 if data["event"] != "posted" or 'file_ids' not in data['data']['post']:
16 data['data']['post']=json.loads(data['data']['post'])
18 msg = "``BOT-AUTODELETE-FAST``\nIs das n file, das retainenswert is?"
20 "text": "Als uploader_in kannst du das File mit einem Click auf Upload! ins Wiki hochladen",
23 "name": "Retainenswert",
24 "integration": { "url": self.URL+"/interactive", "context": { "action": "click_yes" } }
27 "integration": { "url": self.URL+"/interactive", "context": { "action": "click_no" } }
29 "name": "Upload (Uploader_in only)",
30 "integration": { "url": self.URL+"/interactive", "context": { "action": "click_upload" } }
32 "name": "Nicht retainenswert (Uploader_in only)",
33 "integration": { "url": self.URL+"/interactive", "context": { "action": "click_nope" } }
39 self.bot.api.create_post(data['data']['post']['channel_id'], msg, props={"from_webhook":"true", "attachments":att}, root_id=data['data']['post']['id'])
43 def on_POST_interactive(self, request, data):
45 pprint.pprint(request)
48 if data["context"]["action"] == "click_nope":
49 request.respond(200, {"update":{"message":"``BOT-AUTODELETE-FAST`` Uploader_in hat gegen einen wiki-upload entschieden. :(", "props":{}}})
51 elif data["context"]["action"] == "click_upload":
52 request.respond(200, {"ephemeral_text": "Du bist leider ned der/die uploader_in :("})
54 elif data["context"]["action"] == "click_yes":
55 request.respond(200, {"ephemeral_text": "Deine Stimme wurde gezählt - vielleicht TODO"})
57 elif data["context"]["action"] == "click_no":
58 request.respond(200, {"ephemeral_text": "Deine Stimme wurde gezählt - vielleicht TODO"})