mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Remove NSFWJS
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const request = require('node-superfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const displayNames = {
|
||||
Drawing: 'SFW (Drawing)',
|
||||
Neutral: 'SFW',
|
||||
Porn: 'NSFW',
|
||||
Hentai: 'NSFW (Drawing)',
|
||||
Sexy: 'Suggestive'
|
||||
};
|
||||
|
||||
module.exports = class NsfwImageCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'nsfw-image',
|
||||
aliases: ['nsfw', 'nsfw-img', 'img-nsfw', 'image-nsfw'],
|
||||
group: 'analyze',
|
||||
description: 'Determines if an image is NSFW.',
|
||||
throttling: {
|
||||
usages: 2,
|
||||
duration: 30
|
||||
},
|
||||
args: [
|
||||
{
|
||||
key: 'image',
|
||||
type: 'image-or-avatar',
|
||||
avatarSize: 256
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { image }) {
|
||||
const { body } = await request.get(image);
|
||||
const predictions = await this.client.tensorflow.isImageNSFW(body, false);
|
||||
const formatted = predictions.map(result => {
|
||||
const percentage = Math.round(result.probability * 100);
|
||||
return `${percentage}% ${displayNames[result.className]}`;
|
||||
});
|
||||
return msg.reply(stripIndents`
|
||||
**This image gives the following results:**
|
||||
${formatted.join('\n')}
|
||||
`);
|
||||
}
|
||||
};
|
||||
@@ -39,10 +39,6 @@ module.exports = class ScreenshotCommand extends Command {
|
||||
if (nsfw) return msg.reply('This site is NSFW.');
|
||||
}
|
||||
const { body } = await request.get(`https://image.thum.io/get/width/1920/crop/675/noanimate/${url.href}`);
|
||||
if (!msg.channel.nsfw) {
|
||||
const aiDetect = await this.client.tensorflow.isImageNSFW(body);
|
||||
if (aiDetect) return msg.reply('This site isn\'t NSFW, but the resulting image was.');
|
||||
}
|
||||
return msg.say({ files: [{ attachment: body, name: 'screenshot.png' }] });
|
||||
} catch (err) {
|
||||
if (err.status === 404) return msg.say('Could not find any results. Invalid URL?');
|
||||
|
||||
@@ -46,12 +46,7 @@ module.exports = class WikipediaCommand extends Command {
|
||||
});
|
||||
const data = body.query.pages[0];
|
||||
if (data.missing) return msg.say('Could not find any results.');
|
||||
let thumbnail = data.thumbnail ? data.thumbnail.source : null;
|
||||
if (!msg.channel.nsfw && thumbnail) {
|
||||
const img = await request.get(thumbnail);
|
||||
const nsfw = await this.client.tensorflow.isImageNSFW(img.body);
|
||||
if (nsfw) thumbnail = null;
|
||||
}
|
||||
const thumbnail = data.thumbnail ? data.thumbnail.source : null;
|
||||
let fact = data.extract;
|
||||
if (fact.length > 200) {
|
||||
const facts = fact.split('.');
|
||||
|
||||
Reference in New Issue
Block a user