mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 13:56:43 +02:00
Use NSFW Site List in Phone and Portal
This commit is contained in:
@@ -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>')) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user