2021-01-18 23:54:18 -03:00
|
|
|
let cache = {}
|
2021-07-07 20:58:31 -04:00
|
|
|
let gauntletNames = ["Fire", "Ice", "Poison", "Shadow", "Lava", "Bonus", "Chaos", "Demon", "Time", "Crystal", "Magic", "Spike", "Monster", "Doom", "Death"]
|
2021-01-15 12:29:46 -03:00
|
|
|
|
|
|
|
module.exports = async (app, req, res) => {
|
|
|
|
|
2021-01-18 23:54:18 -03:00
|
|
|
if (req.offline) return res.send("-1")
|
|
|
|
|
|
|
|
let cached = cache[req.id]
|
|
|
|
if (app.config.cacheGauntlets && cached && cached.data && cached.indexed + 2000000 > Date.now()) return res.send(cached.data) // half hour cache
|
2021-01-15 12:29:46 -03:00
|
|
|
|
2021-01-18 23:54:18 -03:00
|
|
|
req.gdRequest('getGJGauntlets21', {}, function (err, resp, body) {
|
2021-01-15 12:29:46 -03:00
|
|
|
|
2021-08-18 20:10:35 -04:00
|
|
|
if (err) return res.send("-1")
|
2021-01-23 00:28:26 -03:00
|
|
|
let gauntlets = body.split('#')[0].split('|').map(x => app.parseResponse(x)).filter(x => x[3])
|
2021-07-07 20:58:31 -04:00
|
|
|
let gauntletList = gauntlets.map(x => ({ id: +x[1], name: gauntletNames[+x[1] - 1] || "Unknown", levels: x[3].split(",") }))
|
2021-01-15 12:29:46 -03:00
|
|
|
|
2021-01-18 23:54:18 -03:00
|
|
|
if (app.config.cacheGauntlets) cache[req.id] = {data: gauntletList, indexed: Date.now()}
|
2021-01-15 12:29:46 -03:00
|
|
|
res.send(gauntletList)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2021-01-18 23:54:18 -03:00
|
|
|
}
|