From e602eefc5dc50db47dae6ff49e3942a8edbf93e8 Mon Sep 17 00:00:00 2001 From: Aster Fialla Date: Sat, 14 Feb 2026 15:20:05 -0500 Subject: [PATCH] hopefully added parsing for wrapping of proxies (at beginning, around, and end) --- helpers/messageHelper.js | 9 +++++++-- helpers/webhookHelper.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/helpers/messageHelper.js b/helpers/messageHelper.js index 261baaa..c78f650 100644 --- a/helpers/messageHelper.js +++ b/helpers/messageHelper.js @@ -1,4 +1,5 @@ import {memberHelper} from "./memberHelper.js"; +import {enums} from "../enums.js"; const msgh = {}; @@ -33,14 +34,18 @@ msgh.parseCommandArgs = function(content, commandName) { * Parses proxy tags and sees if they match the tags of any member belonging to an author. * * @param {string} authorId - The author of the message. + * @param {Object} attachment - An attachment for the message, if any exists. * @param {string} content - The full message content. * @returns {Object} The proxy message object. */ -msgh.parseProxyTags = async function (authorId, content){ +msgh.parseProxyTags = async function (authorId, attachment, content){ const members = await memberHelper.getMembersByAuthor(authorId); + const proxyMessage = {} members.forEach(member => { - if (content.startsWith(member.proxy) && content.length > member.proxy.length) { + if (content.length <= member.proxy.length && !attachment) throw new Error(enums.err.NO_MESSAGE_SENT_WITH_PROXY); + const splitProxy = member.proxy.split("text"); + if(content.startsWith(splitProxy[0]) && content.endsWith(splitProxy[1])) { proxyMessage.proxy = member.proxy; proxyMessage.message = content.slice(member.proxy.length).trim(); } diff --git a/helpers/webhookHelper.js b/helpers/webhookHelper.js index 91ec05a..6eab103 100644 --- a/helpers/webhookHelper.js +++ b/helpers/webhookHelper.js @@ -89,7 +89,7 @@ function preventSameNameCollapse(channel, username) { */ wh.sendMessageAsMember = async function(client, message, content) { - const proxyMatch = await messageHelper.parseProxyTags(message.author.id, content); + const proxyMatch = await messageHelper.parseProxyTags(message.author.id, message.attachments[0] ?? null, content); // If the message doesn't match a proxy, just return. if (!proxyMatch.proxy) { return;