Use NSFW Site List in Phone and Portal

This commit is contained in:
Dragon Fire
2021-02-28 14:47:02 -05:00
parent ca5d3c02d3
commit 85d25cd2d7
7 changed files with 78 additions and 62 deletions
+11
View File
@@ -1,6 +1,7 @@
const crypto = require('crypto');
const { decode: decodeHTML } = require('html-entities');
const { stripIndents } = require('common-tags');
const url = require('url');
const { SUCCESS_EMOJI_ID } = process.env;
const yes = ['yes', 'y', 'ye', 'yeah', 'yup', 'yea', 'ya', 'hai', 'si', 'sí', 'oui', 'はい', 'correct'];
const no = ['no', 'n', 'nah', 'nope', 'nop', 'iie', 'いいえ', 'non', 'fuck off'];
@@ -204,6 +205,16 @@ module.exports = class Util {
return str.replace(/(https?:\/\/\S+)/g, '<$1>');
}
static stripNSFWURLs(str, siteList, text = '[redacted nsfw url]') {
const uris = str.match(/(https?:\/\/\S+)/g);
for (const uri of uris) {
const parsed = url.parse(uri);
if (!siteList.some(pornURL => parsed.host === pornURL)) continue;
str = str.replace(uri, text);
}
return str;
}
static async reactIfAble(msg, user, emoji, fallbackEmoji) {
const dm = !msg.guild;
if (fallbackEmoji && (!dm && !msg.channel.permissionsFor(user).has('USE_EXTERNAL_EMOJIS'))) {