From f6e7f0698a82cca84c38cce8244dbf577c37795d Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 21 Jun 2020 20:58:33 -0400 Subject: [PATCH] Fix nsfw site filter matching in screenshot --- commands/other/screenshot.js | 13 ++++++++----- package.json | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/commands/other/screenshot.js b/commands/other/screenshot.js index a1bc9871..fd3f797d 100644 --- a/commands/other/screenshot.js +++ b/commands/other/screenshot.js @@ -1,5 +1,6 @@ const Command = require('../../structures/Command'); const request = require('node-superfetch'); +const url = require('url'); module.exports = class ScreenshotCommand extends Command { constructor(client) { @@ -30,9 +31,10 @@ module.exports = class ScreenshotCommand extends Command { ], args: [ { - key: 'url', + key: 'site', prompt: 'What webpage do you want to take a screenshot of?', - type: 'string' + type: 'string', + parse: site => /^(https?:\/\/)/i.test(site) ? site : `http://${site}` } ] }); @@ -40,13 +42,14 @@ module.exports = class ScreenshotCommand extends Command { this.pornList = null; } - async run(msg, { url }) { + async run(msg, { site }) { try { if (!this.pornList) await this.fetchPornList(); - if (this.pornList.some(pornURL => url.includes(pornURL)) && !msg.channel.nsfw) { + const parsed = url.parse(site); + if (this.pornList.some(pornURL => parsed.host === 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}`); + const { body } = await request.get(`https://image.thum.io/get/width/1920/crop/675/noanimate/${site}`); 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?'); diff --git a/package.json b/package.json index b8d096c7..59e5b157 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "116.37.1", + "version": "116.37.2", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {