def on_POST(self, request, data):
msg_text = data['text'].strip().split(" ", 1)
+ pl_post_id = "--invalid--"
try:
splitpath = msg_text[0].strip().strip("/").split("/")
if splitpath[4] == "pl":
pl_post_id = splitpath[5]
+ else:
+ request.respond_err_temp("``/"+self.TRIGGER+"`` failed: The first parameter is not a valid post-permalink. :(")
+ return
+
except:
- request.cmd_respond_text_temp("``/"+self.TRIGGER+"`` failed: The first parameter is not a valid post-permalink. :(")
+ request.respond_err_temp("``/"+self.TRIGGER+"`` failed: The first parameter is not a valid post-permalink. :(")
return
+
post = self.bot.api.get_post(pl_post_id, exc=False)
+
if "status_code" in post and post["status_code"] == 404:
- request.cmd_respond_text_temp("``/"+self.TRIGGER+"`` failed: The perma-linked post doesnt seem to exist. Was it deleted?")
+ request.respond_err_temp("``/"+self.TRIGGER+"`` failed: The perma-linked post doesnt seem to exist. Was it deleted?")
return
if post["channel_id"] != data["channel_id"]:
- request.cmd_respond_text_temp("``/"+self.TRIGGER+"`` failed: Must be executed in the same channel as the post. :(")
+ request.respond_err_temp("``/"+self.TRIGGER+"`` failed: Must be executed in the same channel as the post. :(")
return
# do actual action
"callback_id": post["id"]+"-"+data["user_id"],
"title": "Report post",
"submit_label":"Report",
- "state": post["id"],
+ "state": post["id"],
"elements":[{
"display_name": "Reason",
"placeholder": "Write the reason here.",
}
self.bot.api.open_dialog(data["trigger_id"], self.URL+"/dialog", dialog)
- request.respond(200, {})
+ request.respond(200)