From b985a2d6c66d9851ccee8c30c70850d9e17e2329 Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:31:47 +0300 Subject: [PATCH] Embeds for translate webhook message (#629) ## About The Pull Request ![image](https://github.com/user-attachments/assets/20aef8f4-8df0-4f94-b6bb-7f3715a8dbbe) --- config/bandastation/bandastation_config.txt | 2 -- .../code/translate_suggest_ru_names.dm | 35 +++++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/config/bandastation/bandastation_config.txt b/config/bandastation/bandastation_config.txt index 3b74a63b73202..5fb35020705c7 100644 --- a/config/bandastation/bandastation_config.txt +++ b/config/bandastation/bandastation_config.txt @@ -12,7 +12,5 @@ #ROUNDSTART_SECURITY_FOR_THREAT 5 #TRANSLATE_SUGGEST_WEBHOOK_URL -#TRANSLATE_SUGGEST_WEBHOOK_PFP -#TRANSLATE_SUGGEST_WEBHOOK_NAME #INTERVIEW_WEBHOOK_URL diff --git a/modular_bandastation/translations/code/translate_suggest_ru_names.dm b/modular_bandastation/translations/code/translate_suggest_ru_names.dm index f5ecef78b1800..8cdc0edc502dc 100644 --- a/modular_bandastation/translations/code/translate_suggest_ru_names.dm +++ b/modular_bandastation/translations/code/translate_suggest_ru_names.dm @@ -65,8 +65,24 @@ ADMIN_VERB(ru_names_review_panel, R_ADMIN, "Ru Names Review", "Shows player-sugg var/suggested_list = "RU_NAMES_LIST_INIT(\"[data["suggested_list"]["base"]]\", \"[data["suggested_list"][NOMINATIVE]]\", \"[data["suggested_list"][GENITIVE]]\", \"[data["suggested_list"][DATIVE]]\", \"[data["suggested_list"][ACCUSATIVE]]\", \"[data["suggested_list"][INSTRUMENTAL]]\", \"[data["suggested_list"][PREPOSITIONAL]]\")" var/message = "approves [suggested_list] for [data["atom_path"]]" // Here we send message to discord - var/webhook_message = "[usr.ckey] [message] by [data["ckey"]]" - send2translate_webhook(webhook_message) + var/list/webhook_data = list( + "title" = data["atom_path"], + "fields" = list( + list( + "name" = "Suggested List:", + "value" = suggested_list, + ), + list( + "name" = "Suggested by:", + "value" = data["ckey"], + ), + list( + "name" = "Approved by:", + "value" = usr.ckey, + ), + ), + ) + send2translate_webhook(webhook_data) json_data.Remove(entry_id) // Logging write_data() @@ -104,21 +120,12 @@ ADMIN_VERB(ru_names_review_panel, R_ADMIN, "Ru Names Review", "Shows player-sugg // MARK: Webhook /datum/config_entry/string/translate_suggest_webhook_url -/datum/config_entry/string/translate_suggest_webhook_pfp - -/datum/config_entry/string/translate_suggest_webhook_name - -/proc/send2translate_webhook(message) +/proc/send2translate_webhook(list/webhook_data) var/webhook = CONFIG_GET(string/translate_suggest_webhook_url) - if(!webhook || !message) + if(!webhook || !list(webhook_data)) return var/list/webhook_info = list() - message = GLOB.has_discord_embeddable_links.Replace_char(replacetext_char(message, "`", ""), " ```$1``` ") - webhook_info["content"] = message - if(CONFIG_GET(string/translate_suggest_webhook_name)) - webhook_info["username"] = CONFIG_GET(string/translate_suggest_webhook_name) - if(CONFIG_GET(string/translate_suggest_webhook_pfp)) - webhook_info["avatar_url"] = CONFIG_GET(string/translate_suggest_webhook_pfp) + webhook_info["embeds"] = list(webhook_data) var/list/headers = list() headers["Content-Type"] = "application/json" var/datum/http_request/request = new()