From d7ff00cc5fd9b8c8fdf8f88d5eef9daccc48ec20 Mon Sep 17 00:00:00 2001 From: Someone Date: Mon, 5 Sep 2022 22:51:19 +0200 Subject: [PATCH] modules/CommandCurriculaSave.py --- modules/CommandCurriculaSave.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/modules/CommandCurriculaSave.py b/modules/CommandCurriculaSave.py index edc0364..b6dfedd 100644 --- a/modules/CommandCurriculaSave.py +++ b/modules/CommandCurriculaSave.py @@ -29,14 +29,15 @@ class CommandCurriculaSave(AbstractCommand,AbstractPublicWS): chan = self.bot.api.create_dm_channel_with(data['user_id']) post = self.bot.api.create_post(chan['id'], "### Generating curricula.fsinf.at storage ...", {"attachments":att, "context":{"curricula_fsinf":{}}}) - post["props"].update(dict({"attachments":att})) - post["message"] = cleandoc(""" ## ** https://curricula.fsinf.at storage** Please copy the following code into the https://curricula.fsinf.at storage section. - # ``"""+post["id"]+"""`` + ``` + """+post["id"]+""" + ``` There are **``"""+str(len(str(post["props"]["context"]["curricula_fsinf"])))+""" bytes``** of additional data stored in this message. """) + post["props"].update(dict({"attachments":att})) self.bot.api.update_post(post["id"], message=post["message"], is_pinned=post["is_pinned"], has_reactions=None, props=post["props"]) request.respond(200, {}) @@ -69,7 +70,7 @@ class CommandCurriculaSave(AbstractCommand,AbstractPublicWS): return post = self.bot.api.get_post(splitpath[1], exc=False) - if "props" in post and "context" in post["props"] and "curricula_fsinf" in post["props"]["context"]: + if "props" in post and "context" in post["props"] and "curricula_fsinf" in post["props"]["context"] and self.bot.api._my_user_id == post["user_id"]: if post["props"]["context"]["curricula_fsinf"] == data: request.respond_public(200, {"status":"unchanged"}) return @@ -78,10 +79,21 @@ class CommandCurriculaSave(AbstractCommand,AbstractPublicWS): post["message"] = cleandoc(""" ## ** https://curricula.fsinf.at storage** Please copy the following code into the https://curricula.fsinf.at storage section. - # ``"""+post["id"]+"""`` + ``` + """+post["id"]+""" + ``` There are **``"""+str(len(str(post["props"]["context"]["curricula_fsinf"])))+""" bytes``** of additional data stored in this message. """) + att = [{ + "text": "Delete this post.", + "color": "#ff0000", + "actions": [{ + "name": ":wastebasket: Delete this post and all associated data. :wastebasket:", + "integration": {"url": self.bot.modules[list(self.bot.modules.keys())[0]][self.TRIGGER].URL+"/interactive", "context": {"action": "delete_self"}} + }] + }] + post["props"].update(dict({"attachments":att})) saved_post = self.bot.api.update_post(post["id"], message=post["message"], is_pinned=post["is_pinned"], has_reactions=None, props=post["props"], exc=False) if "status_code" in saved_post and saved_post["status_code"] == 400 and saved_post['id'] == 'api.post.update_post.permissions_time_limit.app_error': -- 2.43.0