mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-08 15:19:14 +02:00
Screenshot NSFW Filter
This commit is contained in:
@@ -20,6 +20,12 @@ module.exports = class ScreenshotCommand extends Command {
|
||||
name: 'AzuraApple',
|
||||
url: 'https://github.com/AzuraApple',
|
||||
reason: 'Concept'
|
||||
},
|
||||
{
|
||||
name: 'Block List Project',
|
||||
url: 'https://blocklist.site/',
|
||||
reason: 'NSFW Site List',
|
||||
reasonURL: 'https://raw.githubusercontent.com/blocklistproject/Lists/master/porn.txt'
|
||||
}
|
||||
],
|
||||
args: [
|
||||
@@ -30,10 +36,16 @@ module.exports = class ScreenshotCommand extends Command {
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.pornList = null;
|
||||
}
|
||||
|
||||
async run(msg, { url }) {
|
||||
try {
|
||||
if (!this.pornList) await this.fetchPornList();
|
||||
if (this.pornList.some(pornURL => url.includes(pornURL)) && !msg.channel.nsfw) {
|
||||
return msg.reply('This site is NSFW.');
|
||||
}
|
||||
const { body } = await request.get(`https://image.thum.io/get/width/1920/crop/675/noanimate/${url}`);
|
||||
return msg.say({ files: [{ attachment: body, name: 'screenshot.png' }] });
|
||||
} catch (err) {
|
||||
@@ -41,4 +53,11 @@ 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(url => !url.startsWith('#')).map(url => url.replace(/^(0.0.0.0 )/, ''));
|
||||
return this.postList;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user