Update server.js
Browse files
server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
const express = require('express');
|
| 2 |
const axios = require('axios');
|
| 3 |
|
|
@@ -10,14 +11,14 @@ const list = (obj) =>
|
|
| 10 |
Object.entries(obj || {})
|
| 11 |
.filter(([, v]) => +v)
|
| 12 |
.sort()
|
| 13 |
-
.map(([k, v]) => `${k}
|
| 14 |
|
| 15 |
const build = (d) => {
|
| 16 |
const seeds = list(d.seeds);
|
| 17 |
const gears = list(d.gear);
|
| 18 |
const eggs = (d.eggs || []).filter(e => e.quantity)
|
| 19 |
.sort((a, b) => a.name.localeCompare(b.name))
|
| 20 |
-
.map(e => `${e.name} x${e.quantity}
|
| 21 |
|
| 22 |
const snap = JSON.stringify([seeds, gears, eggs]);
|
| 23 |
if (snap === lastSnap) return;
|
|
@@ -58,4 +59,10 @@ setInterval(async () => {
|
|
| 58 |
await axios.post(WEBHOOK, payload);
|
| 59 |
lastMinute = m;
|
| 60 |
console.log('Sent at', now.toLocaleTimeString());
|
| 61 |
-
} catch (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
require('dotenv').config();
|
| 2 |
const express = require('express');
|
| 3 |
const axios = require('axios');
|
| 4 |
|
|
|
|
| 11 |
Object.entries(obj || {})
|
| 12 |
.filter(([, v]) => +v)
|
| 13 |
.sort()
|
| 14 |
+
.map(([k, v]) => `${k} x${v}`);
|
| 15 |
|
| 16 |
const build = (d) => {
|
| 17 |
const seeds = list(d.seeds);
|
| 18 |
const gears = list(d.gear);
|
| 19 |
const eggs = (d.eggs || []).filter(e => e.quantity)
|
| 20 |
.sort((a, b) => a.name.localeCompare(b.name))
|
| 21 |
+
.map(e => `${e.name} **x${e.quantity}**`);
|
| 22 |
|
| 23 |
const snap = JSON.stringify([seeds, gears, eggs]);
|
| 24 |
if (snap === lastSnap) return;
|
|
|
|
| 59 |
await axios.post(WEBHOOK, payload);
|
| 60 |
lastMinute = m;
|
| 61 |
console.log('Sent at', now.toLocaleTimeString());
|
| 62 |
+
} catch (e) {
|
| 63 |
+
console.error('[ERROR]', e.message);
|
| 64 |
+
}
|
| 65 |
+
}, 2500);
|
| 66 |
+
|
| 67 |
+
app.get('/', (_, res) => res.send('✅ Stock bot running'));
|
| 68 |
+
app.listen(7860, () => console.log('✅ Listening on port 7860'));
|