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
5 from inspect import cleandoc
8 # pylint: disable=wrong-import-position
9 from AbstractCommand import AbstractCommand
10 class CommandCurriculaSave(AbstractCommand):
11 TRIGGER = "curricula-save"
12 CONFIG = {"display_name": "somebot-command", "auto_complete": True,
13 "auto_complete_hint": "",
15 USEINFO = CONFIG["auto_complete_desc"] = CONFIG["description"] = "Generate save-code for curricula.fsinf.at."
18 def on_POST(self, request, data):
20 "text": "Delete this post.",
23 "name": ":wastebasket: Delete this post and all associated data. :wastebasket:",
24 "integration": {"url": self.URL+"/interactive", "context": {"action": "delete_self"}}
28 chan = self.bot.api.create_dm_channel_with(data['user_id'])
29 post = self.bot.api.create_post(chan['id'], "### Generating curricula.fsinf.at storage ...", {"attachments":att, "context":{"curricula_fsinf":{}}})
31 post["props"].update(dict({"attachments":att}))
33 post["message"] = cleandoc("""
34 ## ** https://curricula.fsinf.at storage**
35 Please copy the following code into the https://curricula.fsinf.at storage section.
36 # ``"""+post["id"]+"""``
37 There are **``"""+str(len(post["props"]["context"]["curricula_fsinf"]))+""" bytes``** of additional data stored in this message.
39 self.bot.api.update_post(post["id"], message=post["message"], is_pinned=post["is_pinned"], has_reactions=None, props=post["props"])
40 request.respond(200, {})
43 def on_POST_interactive(self, request, data):
44 if data["context"]["action"] == "delete_self":
45 self.bot.api.delete_post(data["post_id"])