diff --git a/mapinfo_stoat.js b/mapinfo_stoat.js index b4e8cd7..ac59605 100644 --- a/mapinfo_stoat.js +++ b/mapinfo_stoat.js @@ -274,8 +274,8 @@ async function checkNewMessages(channel_selected, admin_chat_bool) { if (!author || author.bot) continue; - const content = message.content || ""; - const username = author.username || "Unknown"; + const content = sanitizeForRcon(message.content) || ""; + const username = sanitizeForRcon(author.username) || "Unknown"; //console.log(`[New] ${username}: ${content}`); if (channel_selected == channel_livechat || channel_selected == channel_adminchat_ze) @@ -304,6 +304,15 @@ async function checkNewMessages(channel_selected, admin_chat_bool) { } } +function sanitizeForRcon(str, maxLength = 200) { + if (typeof str !== 'string') return ''; + return str + .replace(/[^\w\s.,!?'\-]/g, '') // keep only safe chars, strip everything else + .trim() + .slice(0, maxLength); +} + + var lastProcessedMessageId_rcon_ze = null; async function checkNewMessages_rcon_ze() { try {