From 0f18965bcd1882d0fe883cb59991943786b9bab1 Mon Sep 17 00:00:00 2001 From: MarkusRost <2701034-MarkusRost@users.noreply.gitlab.com> Date: Fri, 5 Jul 2024 21:37:51 +0000 Subject: [PATCH] add thank button --- extensions/hooks/buttons.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/extensions/hooks/buttons.py b/extensions/hooks/buttons.py index 88c7568..2213d84 100644 --- a/extensions/hooks/buttons.py +++ b/extensions/hooks/buttons.py @@ -29,6 +29,7 @@ from src.configloader import settings # "filerevert": "Revert", # "move": "Move back", # "rollback": "Rollback", +# "thank": "Thank user", # "undo": "Undo" # } # } @@ -67,12 +68,17 @@ def buttons_hook(message: DiscordMessage, metadata: DiscordMessageMetadata, cont if "move" in action_buttons and context.event in ("move/move", "move/move_redir"): add_button(message, BUTTON_PREFIX + " move " + str(change["pageid"]) + " " + change["title"], action_buttons["move"], 2, {"id": None, "name": "🔂"}) - if context.event != "edit": - return - if "rollback" in action_buttons: + if "rollback" in action_buttons and context.event == "edit": add_button(message, BUTTON_PREFIX + " rollback " + str(change["pageid"]) + " " + ( "#" + str(change["userid"]) if change["userid"] else change["user"]), action_buttons["rollback"], 1, {"id": None, "name": "🔁"}) - if "undo" in action_buttons: + if "undo" in action_buttons and context.event == "edit": add_button(message, BUTTON_PREFIX + " undo " + str(change["pageid"]) + " " + str(change["revid"]), action_buttons["undo"], 2, {"id": None, "name": "🔂"}) + if "thank" in action_buttons: + if change["type"] == "log": + add_button(message, BUTTON_PREFIX + " thank log " + str(change["logid"]), + action_buttons["thank"], 3, {"id": None, "name": "👍"}) + else: + add_button(message, BUTTON_PREFIX + " thank rev " + str(change["revid"]), + action_buttons["thank"], 3, {"id": None, "name": "👍"})