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
+5 -3
View File
@@ -1,5 +1,5 @@
const Command = require('../../structures/Command');
const { stripInvites } = require('../../util/Util');
const { stripInvites, stripNSFWURLs } = require('../../util/Util');
const { stripIndents } = require('common-tags');
const { PORTAL_EMOJI_ID, PORTAL_EMOJI_NAME } = process.env;
@@ -27,7 +27,6 @@ module.exports = class PortalSendCommand extends Command {
}
return true;
},
parse: val => val ? stripInvites(val) : '',
isEmpty: (val, msg) => !msg.attachments.size && !val
}
]
@@ -47,8 +46,11 @@ module.exports = class PortalSendCommand extends Command {
try {
const displayName = msg.guild ? msg.guild.name : 'DM';
const attachments = msg.attachments.size ? msg.attachments.map(a => a.url).join('\n') : null;
const content = !msg.channel.nsfw && this.client.adultSiteList
? stripNSFWURLs(stripInvites(message), this.client.adultSiteList)
: stripInvites(message);
await channel.send(stripIndents`
**${this.portalEmoji} ${msg.author.tag} (${displayName}):** ${message}
**${this.portalEmoji} ${msg.author.tag} (${displayName}):** ${content}
${attachments || ''}
`);
if (channel.topic.includes('<xiao:portal:hide-name>')) {
+3 -20
View File
@@ -1,6 +1,7 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const url = require('url');
const validURL = require('valid-url');
module.exports = class ScreenshotCommand extends Command {
constructor(client) {
@@ -16,12 +17,6 @@ module.exports = class ScreenshotCommand extends Command {
name: 'Thum.io',
url: 'https://www.thum.io/',
reason: 'API'
},
{
name: 'Block List Project',
url: 'https://blocklist.site/',
reason: 'NSFW Site List',
reasonURL: 'https://raw.githubusercontent.com/blocklistproject/Lists/master/porn.txt'
}
],
args: [
@@ -29,19 +24,16 @@ module.exports = class ScreenshotCommand extends Command {
key: 'site',
prompt: 'What webpage do you want to take a screenshot of?',
type: 'string',
parse: site => /^(https?:\/\/)/i.test(site) ? site : `http://${site}`
validate: site => validURL.isWebUri(site)
}
]
});
this.pornList = null;
}
async run(msg, { site }) {
try {
if (!this.pornList) await this.fetchPornList();
const parsed = url.parse(site);
if (!msg.channel.nsfw && this.pornList.some(pornURL => parsed.host === pornURL)) {
if (!msg.channel.nsfw && this.client.adultSiteList.some(pornURL => parsed.host === pornURL)) {
return msg.reply('This site is NSFW.');
}
const { body } = await request.get(`https://image.thum.io/get/width/1920/crop/675/noanimate/${site}`);
@@ -51,13 +43,4 @@ module.exports = class ScreenshotCommand extends Command {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
async fetchPornList(force = false) {
if (!force && this.pornList) return this.pornList;
const { text } = await request.get('https://raw.githubusercontent.com/blocklistproject/Lists/master/porn.txt');
this.pornList = text.split('\n')
.filter(site => site && !site.startsWith('#'))
.map(site => site.replace(/^(0.0.0.0 )/, '')); // eslint-disable-line no-control-regex
return this.pornList;
}
};