mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 10:19:11 +02:00
Safe URL Command
This commit is contained in:
@@ -206,6 +206,7 @@ API. All are free unless otherwise stated.
|
|||||||
- [Maps Static API](https://console.developers.google.com/apis/library/static-maps-backend.googleapis.com)
|
- [Maps Static API](https://console.developers.google.com/apis/library/static-maps-backend.googleapis.com)
|
||||||
- [Google Calendar API](https://console.developers.google.com/apis/library/calendar-json.googleapis.com)
|
- [Google Calendar API](https://console.developers.google.com/apis/library/calendar-json.googleapis.com)
|
||||||
- [Books API](https://console.developers.google.com/apis/library/books.googleapis.com)
|
- [Books API](https://console.developers.google.com/apis/library/books.googleapis.com)
|
||||||
|
- [Safe Browsing API](https://console.developers.google.com/apis/library/safebrowsing.googleapis.com)
|
||||||
- Go to the [Perspective API website](https://www.perspectiveapi.com/#/home) to set up the Perspective API.
|
- Go to the [Perspective API website](https://www.perspectiveapi.com/#/home) to set up the Perspective API.
|
||||||
* `GOV_KEY` can be obtained at the [NASA Open APIs portal](https://api.nasa.gov/).
|
* `GOV_KEY` can be obtained at the [NASA Open APIs portal](https://api.nasa.gov/).
|
||||||
* `IDIOT_PAGE_ID` is the ID of a Wikipedia article for use in the `idiot` command. Not required, and defaults to `Donald_Trump`. If this offends you, I don't care.
|
* `IDIOT_PAGE_ID` is the ID of a Wikipedia article for use in the `idiot` command. Not required, and defaults to `Donald_Trump`. If this offends you, I don't care.
|
||||||
@@ -252,7 +253,7 @@ in the appropriate channel's topic to use it.
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Total: 532
|
Total: 533
|
||||||
|
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
@@ -522,6 +523,7 @@ Total: 532
|
|||||||
* **has-transparency:** Determines if an image has transparency in it.
|
* **has-transparency:** Determines if an image has transparency in it.
|
||||||
* **image-size:** Determines the size of an image.
|
* **image-size:** Determines the size of an image.
|
||||||
* **read-qr-code:** Reads a QR Code.
|
* **read-qr-code:** Reads a QR Code.
|
||||||
|
* **safe-url:** Determines if a URL is safe or not.
|
||||||
* **scrabble-score:** Responds with the scrabble score of a word.
|
* **scrabble-score:** Responds with the scrabble score of a word.
|
||||||
* **severe-toxicity:** Determines the toxicity of text, but less sensitive to milder language.
|
* **severe-toxicity:** Determines the toxicity of text, but less sensitive to milder language.
|
||||||
* **toxicity:** Determines the toxicity of text.
|
* **toxicity:** Determines the toxicity of text.
|
||||||
@@ -1117,6 +1119,7 @@ here.
|
|||||||
* phoebe-teaching-joey ([Noto Font](https://www.google.com/get/noto/))
|
* phoebe-teaching-joey ([Noto Font](https://www.google.com/get/noto/))
|
||||||
* pills ([Noto Font](https://www.google.com/get/noto/))
|
* pills ([Noto Font](https://www.google.com/get/noto/))
|
||||||
* plankton-plan ([Noto Font](https://www.google.com/get/noto/))
|
* plankton-plan ([Noto Font](https://www.google.com/get/noto/))
|
||||||
|
* safe-url ([Safe Browsing API](https://developers.google.com/safe-browsing/))
|
||||||
* scroll-of-truth ([Noto Font](https://www.google.com/get/noto/))
|
* scroll-of-truth ([Noto Font](https://www.google.com/get/noto/))
|
||||||
* sonic-says ([Noto Font](https://www.google.com/get/noto/))
|
* sonic-says ([Noto Font](https://www.google.com/get/noto/))
|
||||||
* sos ([Noto Font](https://www.google.com/get/noto/))
|
* sos ([Noto Font](https://www.google.com/get/noto/))
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const request = require('node-superfetch');
|
||||||
|
const { version } = require('../../package');
|
||||||
|
const { GOOGLE_KEY } = process.env;
|
||||||
|
|
||||||
|
module.exports = class SafeUrlCommand extends Command {
|
||||||
|
constructor(client) {
|
||||||
|
super(client, {
|
||||||
|
name: 'safe-url',
|
||||||
|
aliases: ['check-url', 'safe-browsing', 'virus', 'safe-link', 'check-link'],
|
||||||
|
group: 'analyze',
|
||||||
|
memberName: 'safe-url',
|
||||||
|
description: 'Determines if a URL is safe or not.',
|
||||||
|
credit: [
|
||||||
|
{
|
||||||
|
name: 'Google',
|
||||||
|
url: 'https://www.google.com/',
|
||||||
|
reason: 'Safe Browsing API',
|
||||||
|
reasonURL: 'https://developers.google.com/safe-browsing/'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
key: 'url',
|
||||||
|
prompt: 'What URL do you want to test?',
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(msg, { url }) {
|
||||||
|
try {
|
||||||
|
const { body } = await request
|
||||||
|
.post('https://safebrowsing.googleapis.com/v4/threatMatches:find')
|
||||||
|
.query({ key: GOOGLE_KEY })
|
||||||
|
.send({
|
||||||
|
client: {
|
||||||
|
clientId: 'xiao-discord',
|
||||||
|
clientVersion: version
|
||||||
|
},
|
||||||
|
threatInfo: {
|
||||||
|
threatTypes: ['MALWARE', 'SOCIAL_ENGINEERING'],
|
||||||
|
platformTypes: ['ANY_PLATFORM'],
|
||||||
|
threatEntryTypes: ['URL'],
|
||||||
|
threatEntries: [{ url }]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (body.matches.length) return msg.reply('⚠️ This link is unsafe! **Do not click it!** ⚠️');
|
||||||
|
return msg.reply(`👍 Good to go! This link is safe!`);
|
||||||
|
} catch (err) {
|
||||||
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "119.13.0",
|
"version": "119.14.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user