forked from Galactic/galactic-bot
improve linkfilter
This commit is contained in:
parent
22bcb8ce89
commit
e261debb69
@ -441,7 +441,12 @@ module.exports = class AutoModeration extends Observer {
|
||||
if (!msg.content) return;
|
||||
const content = msg.content.split('').join(''); //Copy the string...
|
||||
let matches = content.match(this.regex.linkRegG);
|
||||
if (!matches) matches = content.replace(/\s/u, '').match(this.regex.linkRegG);
|
||||
let removedWhitespace = false;
|
||||
if (!matches) {
|
||||
matches = content.replace(/\s/u, '').match(this.regex.linkRegG);
|
||||
removedWhitespace = true;
|
||||
}
|
||||
|
||||
if (!matches) return;
|
||||
let remove = false;
|
||||
const filterResult = {};
|
||||
@ -480,6 +485,9 @@ module.exports = class AutoModeration extends Observer {
|
||||
// console.log(parts, validTld);
|
||||
if (!validTld) continue;
|
||||
const valid = await resolver.validateDomain(domain);
|
||||
|
||||
if (removedWhitespace && !match.includes(`${domain}/`)) continue;
|
||||
|
||||
if (!valid) {
|
||||
if (match.includes(`${domain}/`)) this.client.emit('linkFilterWarn', { guild: wrapper, message: wrapper.format('LINKFILTER_WARN', { domain, link: match }) });
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user