Skip to content

Commit 2a356f0

Browse files
authored
Merge pull request #92 from thedevs-network/feat-configurable-blacklists
Feature: configurable blacklists
2 parents b11a35a + 9abf4ce commit 2a356f0

File tree

4 files changed

+392
-361
lines changed

4 files changed

+392
-361
lines changed

example.config.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
/* eslint-disable sort-keys */
4+
35
/*
46
* Create `config.js` by running `cp example.config.js config.js`
57
* in the project folder, then edit it.
@@ -30,7 +32,7 @@ module.exports = {
3032
* Which messages with commands should be deleted?
3133
* Defaults to 'own' -- don't delete commands meant for other bots.
3234
*/
33-
deleteCommands: 'own', // eslint-disable-line sort-keys
35+
deleteCommands: 'own',
3436

3537
/**
3638
* @type {( number | string | false )}
@@ -42,6 +44,15 @@ module.exports = {
4244
*/
4345
deleteJoinsAfter: '2 minutes',
4446

47+
/**
48+
* @type {string[]}
49+
* List of blacklisted domains.
50+
* Messages containing blacklisted domains will automatically be warned.
51+
* If the link is shortened, an attempt will be made to resolve it.
52+
* If resolved link is blacklisted, it will be warned for.
53+
*/
54+
blacklistedDomains: [],
55+
4556
/**
4657
* @type {( string[] | false )}
4758
* List of whitelisted links and usernames,

handlers/middlewares/checkLinks.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const { telegram } = require('../../bot');
1414

1515
const {
1616
excludeLinks = [],
17+
blacklistedDomains = [],
1718
notifyBrokenLink,
1819
} = require('../../config');
1920

@@ -101,13 +102,10 @@ const dh = {
101102
};
102103

103104
const domainHandlers = new Map([
104-
[ 'chat.whatsapp.com', dh.blacklistedDomain ],
105-
[ 'loverdesuootnosheniya.blogspot.com', dh.blacklistedDomain ],
106105
[ 't.me', dh.tme ],
107106
[ 'telegram.dog', dh.tme ],
108107
[ 'telegram.me', dh.tme ],
109-
[ 'tinyurl.com', dh.blacklistedDomain ],
110-
[ 'your-sweet-dating.com', dh.blacklistedDomain ],
108+
...blacklistedDomains.map(domain => [ domain, dh.blacklistedDomain ])
111109
]);
112110

113111
const isWhitelisted = (url) => customWhitelist.has(stripQuery(url.toString()));

0 commit comments

Comments
 (0)