From 5065b8595228b400b0607b8818ea5d79c50e9985 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Tue, 28 Jun 2022 18:48:52 +0300 Subject: [PATCH] linkfilter debugging --- src/structure/components/observers/Automoderation.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/structure/components/observers/Automoderation.js b/src/structure/components/observers/Automoderation.js index 4069536..a8799e4 100644 --- a/src/structure/components/observers/Automoderation.js +++ b/src/structure/components/observers/Automoderation.js @@ -515,9 +515,11 @@ module.exports = class AutoModeration extends Observer { if (!matches) return; let remove = false; const filterResult = {}; + let log = 'Link filter debug:'; for (const match of matches) { const { domain } = match.match(linkReg).groups; + log += `\nMatched link ${match}: `; const predicate = (dom) => { return dom.includes(domain) || domain.includes(dom); @@ -534,7 +536,10 @@ module.exports = class AutoModeration extends Observer { remove = true; break; } else if (whitelistMode) { - if (whitelist.some(predicate)) continue; + if (whitelist.some(predicate)) { + log += 'in whitelist'; + continue; + } const valid = await resolver.validateDomain(domain); if (!valid) { this.client.emit('linkFilterWarn', { message: guild.format('LINKFILTER_WARN', { domain }) }); @@ -549,6 +554,9 @@ module.exports = class AutoModeration extends Observer { } + log += `\nFilter result: ${inspect(filterResult)}\nRemove: ${remove}`; + this.logger.debug(log); + if (!remove) return; msg.filtered = filterResult; filterResult.filter = 'link';