From 2bbe19fcd9a31efbdd33fbd0772ef9c5e201c231 Mon Sep 17 00:00:00 2001 From: Someone Date: Sat, 12 Feb 2022 00:56:45 +0100 Subject: [PATCH] modules/CommandSpoiler.py --- modules/CommandSpoiler.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/CommandSpoiler.py b/modules/CommandSpoiler.py index 5ef48c9..9db6b22 100644 --- a/modules/CommandSpoiler.py +++ b/modules/CommandSpoiler.py @@ -15,15 +15,20 @@ class CommandSpoiler(AbstractCommand): def on_POST(self, request, data): - if len(data['text']) > 15000: - request.respond_cmd_err("``/"+self.TRIGGER+"`` reason-text must be smaller than 15000 characters :(\nYour text is: "+str(len(data['text']))+" characters long.") + msg_text = data['text'].strip() + + if len(msg_text) == 1: + request.respond_cmd_err("``/"+self.TRIGGER+"`` It seems like you did not supply any spoiler-text. (use --remove to remove)") + return + if len(msg_text) > 15000: + request.respond_cmd_err("``/"+self.TRIGGER+"`` reason-text must be smaller than 15000 characters :(\nYour text is: "+str(len(msg_text))+" characters long.") return att = [{ "text": "This post contains spoilers.", "actions": [{ "name": ":ghost: show me the spoilers :ghost:", - "integration": {"url": self.URL+"/interactive", "context": {"action": "show_spoiler", "spoiler":data['text'].strip()}} + "integration": {"url": self.URL+"/interactive", "context": {"action": "show_spoiler", "spoiler":msg_text}} }] }] @@ -32,4 +37,7 @@ class CommandSpoiler(AbstractCommand): def on_POST_interactive(self, request, data): if data["context"]["action"] == "show_spoiler": - request.respond_interactive_temp(data["context"]["spoiler"]) + if data["context"]["spoiler"] != "": + request.respond_interactive_temp(data["context"]["spoiler"]) + else: + request.respond_interactive_err("Post has no stored spoiler text") -- 2.43.0