fast72 commited on
Commit
2bf50e5
·
verified ·
1 Parent(s): 53bff16

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +7 -8
server.js CHANGED
@@ -4,7 +4,7 @@ const axios = require('axios');
4
  const app = express();
5
  const WEBHOOK = process.env.WHOOK;
6
 
7
- let lastMinute = -1, lastSnap = '';
8
 
9
  const list = (obj) =>
10
  Object.entries(obj || {})
@@ -15,7 +15,6 @@ const build = (d) => {
15
  const seeds = list(d.seeds);
16
  const gears = list(d.gear);
17
  const eggs = (d.eggs || []).filter(e => e.quantity)
18
- .sort((a, b) => a.name.localeCompare(b.name))
19
  .map(e => `${e.name} **x${e.quantity}**`);
20
 
21
  const snap = JSON.stringify([seeds, gears, eggs]);
@@ -55,11 +54,11 @@ setInterval(async () => {
55
 
56
  await axios.post(WEBHOOK, payload);
57
  lastMinute = m;
58
- console.log('Sent at', now.toLocaleTimeString());
59
- } catch (e) {
60
- console.error('[ERROR]', e.message);
61
- }
62
  }, 1000);
63
 
64
- app.get('/', (_, res) => res.send('✅ Stock bot running'));
65
- app.listen(7860, () => console.log('✅ Listening on port 7860'));
 
4
  const app = express();
5
  const WEBHOOK = process.env.WHOOK;
6
 
7
+ let lastMinute = -1, lastSnap = '', lastSent = '';
8
 
9
  const list = (obj) =>
10
  Object.entries(obj || {})
 
15
  const seeds = list(d.seeds);
16
  const gears = list(d.gear);
17
  const eggs = (d.eggs || []).filter(e => e.quantity)
 
18
  .map(e => `${e.name} **x${e.quantity}**`);
19
 
20
  const snap = JSON.stringify([seeds, gears, eggs]);
 
54
 
55
  await axios.post(WEBHOOK, payload);
56
  lastMinute = m;
57
+
58
+ const time = new Date().toLocaleString('en-US', { timeZone: 'Asia/Jakarta' });
59
+ lastSent = new Date(time).toLocaleTimeString('id-ID', { hour12: false });
60
+ } catch (e) {}
61
  }, 1000);
62
 
63
+ app.get('/', (_, res) => res.send(`Sent at ${lastSent || '-'}`));
64
+ app.listen(7860);