thaldrin/Dashboard/routes/api.js

62 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-11-11 15:34:04 +00:00
var express = require('express');
var api = express.Router();
2019-11-11 19:57:16 +00:00
var config = require('../../config');
2020-01-18 14:45:03 +00:00
var vars = require('../../vars');
2019-11-11 21:52:28 +00:00
var utils = require('../../utils');
2019-11-16 17:52:47 +00:00
const os = require('os');
2020-01-18 14:45:03 +00:00
let Bot = require('../server')
2019-11-11 15:34:04 +00:00
api.get('/', (req, res) => {
2019-11-11 19:57:16 +00:00
res.status(200).jsonp({
2020-01-18 14:45:03 +00:00
res: 'uwu'
2019-11-11 19:57:16 +00:00
});
2019-11-11 15:34:04 +00:00
});
2019-11-11 21:52:28 +00:00
api.get('/ints/:kind/:user1?/:user2?', (req, res) => {
2020-01-18 14:45:03 +00:00
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`
});
2019-11-11 21:52:28 +00:00
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,
utils.format.bold(req.params.user2)
);
let respo = LineFromUtils.replace(/0/g, req.params.user1).replace(/1/g, req.params.user2);
res.status(200).jsonp({
Line: respo,
MarkdownLine: Line
});
});
2020-01-18 14:45:03 +00:00
api.get(['/SourceFynnder', '/sourcefynnder', '/sauce'], async (req, res) => {
let REPLY;
let URLS = req.headers.images || req.query.images.split(',')
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
})
})
})
2019-11-16 17:52:47 +00:00
api.get('/system', (req, res) => {
res.jsonp({
2020-01-18 14:45:03 +00:00
name: vars.name,
version: vars.version,
2019-11-16 17:52:47 +00:00
hostname: os.hostname(),
2020-01-18 14:45:03 +00:00
uptime: `${utils.format.uptime(process.uptime())}`
2019-11-16 17:52:47 +00:00
});
});
2020-01-18 14:45:03 +00:00
module.exports = api;