From b08c5d74e44d4bc7f0f1074fd2dab145b62f4798 Mon Sep 17 00:00:00 2001 From: Someone Date: Wed, 19 Oct 2022 23:21:48 +0200 Subject: [PATCH] modules/DialogManagedReport.py --- modules/DialogManagedReport.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/DialogManagedReport.py b/modules/DialogManagedReport.py index 7be68e5..d3c12fd 100644 --- a/modules/DialogManagedReport.py +++ b/modules/DialogManagedReport.py @@ -67,12 +67,12 @@ class DialogManagedReport(AbstractCommand): "text": "It's spam", "value": "spam" },{ - "text": "Other (Fill in below)", - "value": "other" + "text": "Other reason (Fill in below)", + "value": "other_reason" } ], "optional": False, - "default": "other" + "default": "other_reason" },{ "display_name": "Other reason or additional details", "placeholder": "Write a custom reason or additional details here.", @@ -93,4 +93,13 @@ class DialogManagedReport(AbstractCommand): team = self.bot.api.get_team(data["team_id"]) chan = self.bot.api.get_channel(data["channel_id"]) - self.bot.api.create_post(self.report_chan_id, "``AUTODELETE-MONTH`` ``/"+self.TRIGGER+"`` used by ``@"+user["username"]+"`` in ``"+team["name"]+"::"+chan["name"]+"``\n#### Reported post: https://mattermost.fsinf.at/"+team["name"]+"/pl/"+data["state"]+"\nReason: "+data["submission"]["report_reason"]+"\n```\n"+data["submission"]["report_other_reason"].strip()+"\n```") + if "report_other_reason" in data["submission"] and data["submission"]["report_other_reason"]: + report_other_reason = "\nAdditional details/other reason:\n```\n"+data["submission"]["report_other_reason"].strip()+"\n```" + else: + report_other_reason = "" + if "report_reason" in data["submission"] and data["submission"]["report_reason"] == "other_reason": + request.respond(200, {"errors": {"report_reason": "Please write some details below, if selecting 'other reason'"}}) + return + + self.bot.api.create_post(self.report_chan_id, "``AUTODELETE-MONTH`` ``/"+self.TRIGGER+"`` used by ``@"+user["username"]+"`` in ``"+team["name"]+"::"+chan["name"]+"``\n#### Reported post: https://mattermost.fsinf.at/"+team["name"]+"/pl/"+data["state"]+"\nReason selected: **``"+data["submission"]["report_reason"]+"``**"+report_other_reason) + -- 2.43.0