lots of stuff
This commit is contained in:
parent
16fd7d9c27
commit
afbde77edc
7 changed files with 95 additions and 50 deletions
|
@ -1,19 +1,24 @@
|
|||
var express = require('express');
|
||||
var api = express.Router();
|
||||
var config = require('../../config');
|
||||
var vars = require('../../vars');
|
||||
var utils = require('../../utils');
|
||||
const os = require('os');
|
||||
let Bot = require('../server')
|
||||
|
||||
api.get('/', (req, res) => {
|
||||
res.status(200).jsonp({
|
||||
name: config.name,
|
||||
version: config.version
|
||||
res: 'uwu'
|
||||
});
|
||||
});
|
||||
|
||||
api.get('/ints/:kind/:user1?/:user2?', (req, res) => {
|
||||
if (utils.int[req.params.kind] === undefined) return res.status(404).jsonp({ error: `This does not exist` });
|
||||
if (!req.params.user1 || !req.params.user2) return res.status(400).jsonp({ error: `I need two users to work` });
|
||||
if (utils.int[req.params.kind] === undefined) return res.status(404).jsonp({
|
||||
error: `This does not exist`
|
||||
});
|
||||
if (!req.params.user1 || !req.params.user2) return res.status(400).jsonp({
|
||||
error: `I need two users to work`
|
||||
});
|
||||
let LineFromUtils = utils.int[req.params.kind][parseInt(Math.random() * utils.int[req.params.kind].length)];
|
||||
let Line = LineFromUtils.replace(/0/g, utils.format.bold(req.params.user1)).replace(
|
||||
/1/g,
|
||||
|
@ -26,21 +31,32 @@ api.get('/ints/:kind/:user1?/:user2?', (req, res) => {
|
|||
});
|
||||
});
|
||||
|
||||
function format(seconds) {
|
||||
function pad(s) {
|
||||
return (s < 10 ? '0' : '') + s;
|
||||
}
|
||||
var hours = Math.floor(seconds / (60 * 60));
|
||||
var minutes = Math.floor((seconds % (60 * 60)) / 60);
|
||||
var seconds = Math.floor(seconds % 60);
|
||||
api.get(['/SourceFynnder', '/sourcefynnder', '/sauce'], async (req, res) => {
|
||||
let REPLY;
|
||||
let URLS = req.headers.images || req.query.images.split(',')
|
||||
console.log(URLS)
|
||||
await utils.SourceFynnder.APIFind(URLS).then(r => {
|
||||
console.log(r)
|
||||
res.status(200).jsonp({
|
||||
success: true,
|
||||
sources: r
|
||||
})
|
||||
}).catch(err => {
|
||||
res.status(400).jsonp({
|
||||
success: false,
|
||||
error: err.message
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
return pad(hours) + 'h ' + pad(minutes) + 'm ' + pad(seconds) + 's';
|
||||
}
|
||||
|
||||
api.get('/system', (req, res) => {
|
||||
res.jsonp({
|
||||
name: vars.name,
|
||||
version: vars.version,
|
||||
hostname: os.hostname(),
|
||||
uptime: `${format(process.uptime())}`
|
||||
uptime: `${utils.format.uptime(process.uptime())}`
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -54,9 +54,10 @@ app.use(
|
|||
})
|
||||
);
|
||||
|
||||
app.use('/api', require('./routes/api'));
|
||||
let support = 'https://discord.gg/' + Backend.get('Info.invite');
|
||||
app.use('/api', require('./routes/api'));
|
||||
module.exports = (client) => {
|
||||
clientInfo: client,
|
||||
app.get('/', async (req, res) => {
|
||||
res.status(200).render('index', {
|
||||
layout: 'main',
|
||||
|
|
|
@ -3,7 +3,9 @@ const {
|
|||
db
|
||||
} = require("../utils/index");
|
||||
const {
|
||||
SourceFynnder,
|
||||
SourceFynnder: {
|
||||
SourceFynnder
|
||||
},
|
||||
topic
|
||||
} = require("../utils");
|
||||
const {
|
||||
|
@ -13,6 +15,7 @@ const Servers = new table("servers");
|
|||
const Users = new table("users");
|
||||
const Backend = new table("backend");
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: "message",
|
||||
run: async (client, Message) => {
|
||||
|
|
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -122,12 +122,11 @@
|
|||
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg=="
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.19.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
|
||||
"integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
|
||||
"version": "0.19.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.1.tgz",
|
||||
"integrity": "sha512-Yl+7nfreYKaLRvAvjNPkvfjnQHJM1yLBY3zhqAwcJSwR/6ETkanUgylgtIvkvz0xJ+p/vZuNw8X7Hnb7Whsbpw==",
|
||||
"requires": {
|
||||
"follow-redirects": "1.5.10",
|
||||
"is-buffer": "^2.0.2"
|
||||
"follow-redirects": "1.5.10"
|
||||
}
|
||||
},
|
||||
"balanced-match": {
|
||||
|
@ -1813,11 +1812,6 @@
|
|||
"binary-extensions": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-buffer": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
|
||||
"integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
|
||||
},
|
||||
"is-ci": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz",
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"license": "MIT",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"axios": "^0.19.0",
|
||||
"axios": "^0.19.1",
|
||||
"blapi": "^1.2.3",
|
||||
"chalk": "^2.4.2",
|
||||
"compression": "*",
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
module.exports = {
|
||||
bold: function(str) {
|
||||
bold: function (str) {
|
||||
return `**${str}**`;
|
||||
},
|
||||
italic: function(str) {
|
||||
italic: function (str) {
|
||||
return `*${str}*`;
|
||||
},
|
||||
code: function(str) {
|
||||
code: function (str) {
|
||||
return `\`${str}\``;
|
||||
},
|
||||
uptime: function (seconds) {
|
||||
function pad(s) {
|
||||
return (s < 10 ? '0' : '') + s;
|
||||
}
|
||||
var hours = Math.floor(seconds / (60 * 60));
|
||||
var minutes = Math.floor((seconds % (60 * 60)) / 60);
|
||||
var seconds = Math.floor(seconds % 60);
|
||||
|
||||
return pad(hours) + 'h ' + pad(minutes) + 'm ' + pad(seconds) + 's';
|
||||
}
|
||||
|
||||
};
|
|
@ -13,7 +13,7 @@ let e9 = 'https://e926.net/post/show/';
|
|||
|
||||
const version = '0.1.0';
|
||||
|
||||
module.exports = async function SourceFynnder(enabled, msg) {
|
||||
async function SourceFynnderBot(enabled, msg) {
|
||||
if (!enabled || enabled === null || enabled === undefined) return;
|
||||
res = msg.content.match(md5);
|
||||
if (!res) return;
|
||||
|
@ -23,8 +23,12 @@ module.exports = async function SourceFynnder(enabled, msg) {
|
|||
let URL = res[m];
|
||||
let hash = URL.split(md5)[2];
|
||||
|
||||
let { data } = await axios.get(search_md5 + hash, {
|
||||
headers: { 'user-agent': `SourceFynnder/${version} (ry / codepupper)` }
|
||||
let {
|
||||
data
|
||||
} = await axios.get(search_md5 + hash, {
|
||||
headers: {
|
||||
'user-agent': `SourceFynnder/${version} (ry / codepupper)`
|
||||
}
|
||||
});
|
||||
if (data.rating === 's') {
|
||||
Source = e9 + data.id;
|
||||
|
@ -35,24 +39,40 @@ module.exports = async function SourceFynnder(enabled, msg) {
|
|||
}
|
||||
msg.channel.send(Sources);
|
||||
await backend.add('SourceFynnder.found', Sources.length);
|
||||
await backend.add('SourceFynnder.foundBot', Sources.length);
|
||||
await Servers.add(`${msg.guild.id}.foundSources`, Sources.length);
|
||||
};
|
||||
/* url = msg.content.split(md5);
|
||||
hash = url[2];
|
||||
|
||||
if (hash === undefined) return;
|
||||
async function SourceFynnderAPI(url) {
|
||||
url = url.toString().replace(/\,/g, ' ')
|
||||
res = url.match(md5);
|
||||
if (!res) throw new Error('Not a Valid e621/e926 URL');
|
||||
|
||||
let res = await axios.get(search_md5 + hash);
|
||||
let Sources = [];
|
||||
for (const m in res) {
|
||||
let URL = res[m];
|
||||
let hash = URL.split(md5)[2];
|
||||
|
||||
let data = res.data;
|
||||
let Source;
|
||||
if (data.rating === "s") {
|
||||
let {
|
||||
data
|
||||
} = await axios.get(search_md5 + hash, {
|
||||
headers: {
|
||||
'user-agent': `SourceFynnder/${version} (ry / codepupper)`
|
||||
}
|
||||
});
|
||||
if (data.rating === 's') {
|
||||
Source = e9 + data.id;
|
||||
} else {
|
||||
Source = e6 + data.id;
|
||||
}
|
||||
Sources.push(`${Source}`);
|
||||
}
|
||||
await backend.add('SourceFynnder.found', Sources.length);
|
||||
await backend.add('SourceFynnder.foundAPI', Sources.length);
|
||||
return Sources
|
||||
};
|
||||
|
||||
|
||||
|
||||
console.log(Source);
|
||||
return msg.channel.send(Source); */
|
||||
module.exports = {
|
||||
SourceFynnder: SourceFynnderBot,
|
||||
APIFind: SourceFynnderAPI
|
||||
}
|
Loading…
Reference in a new issue