add phishing check
This commit is contained in:
parent
0f15e2fb2c
commit
a2e1e1a3cf
4 changed files with 128 additions and 1 deletions
30
index.ts
30
index.ts
|
@ -3,8 +3,10 @@ import { commands, aliases } from './commands';
|
|||
|
||||
import * as BuildConfig from './constants';
|
||||
import Filter from 'bad-words';
|
||||
import { isBad } from './badLinks';
|
||||
|
||||
import { green, bold, blue, underline } from 'kleur/colors';
|
||||
import urlRegex from 'url-regex';
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
|
@ -69,6 +71,34 @@ client.once('ready', async () => {
|
|||
});
|
||||
}
|
||||
|
||||
{
|
||||
const urlMatches = e.content.matchAll(urlRegex());
|
||||
|
||||
if (urlMatches) {
|
||||
console.log('Found links in message!');
|
||||
|
||||
for (const match of urlMatches) {
|
||||
console.log('[link]', match[0]);
|
||||
if (await isBad(match[0])) {
|
||||
await e.delete();
|
||||
await e.channel.send({
|
||||
content: `<@${e.author.id}>`,
|
||||
embeds: [
|
||||
{
|
||||
title: 'Hold on!',
|
||||
description:
|
||||
'There seems to be a phishing / malware link in your message.',
|
||||
color: 'RED',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const cmd = e.content.split(' ')[0];
|
||||
if (!cmd.startsWith('!')) return;
|
||||
let func = commands[cmd];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue