From 1ce2e01f5c4ce6d5c9351ae6d6c289d8ac3b91aa Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 21 Dec 2025 21:30:54 -0700 Subject: [PATCH] Fix bug preventing all non-image messages from being sent (closes #30) --- module/tweaks/chatImageLinks.mjs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/module/tweaks/chatImageLinks.mjs b/module/tweaks/chatImageLinks.mjs index b75ad9c..6b4b226 100644 --- a/module/tweaks/chatImageLinks.mjs +++ b/module/tweaks/chatImageLinks.mjs @@ -28,7 +28,7 @@ export function chatImageLinks() { type: Boolean, default: true, config: true, - requiresReload: true, + requiresReload: false, onChange: (newValue) => { if (newValue) { hookID = Hooks.on(`chatMessage`, chatMessageHandler); @@ -37,13 +37,6 @@ export function chatImageLinks() { }; }, }); - - game.settings.register(__ID__, key + `-showPromptAgain`, { - scope: `user`, - type: Boolean, - default: true, - config: false, - }); // #endregion Registration // #region Implementation @@ -65,9 +58,6 @@ const pattern = new RegExp( // MARK: Mutate & Resend const handled = new Set(); async function mutateAndResendMessage(chatLog, message, options) { - const match = message.match(pattern); - if (!match) { return }; - const validMatches = new Set(); const matches = message.match(pattern); @@ -99,7 +89,14 @@ async function mutateAndResendMessage(chatLog, message, options) { */ function chatMessageHandler(chatLog, message, options) { if (!game.settings.get(__ID__, key)) { return }; + + // Don't re-process the same message if (handled.has(message)) { return }; + + // Prevent cancellation for non-matching messages + const match = message.match(pattern); + if (!match) { return }; + mutateAndResendMessage(chatLog, message, options); return false; };