-
Notifications
You must be signed in to change notification settings - Fork 57
/
gifted.js
36 lines (26 loc) · 797 Bytes
/
gifted.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const gifted = require('express');
const giftech = require('path');
const { spawn } = require('child_process');
const axios = require('axios')
const gift = gifted();
gift.use(gifted.static(giftech.join(__dirname, 'gifted')));
gift.get('/', (req, res) => {
res.sendFile(giftech.join(__dirname, 'gifted', 'gifted.html'));
});
const PORT = process.env.PORT || 3000;
gift.listen(PORT, () => {});
//startGifted function is taken from gifted-md whatsapp bot v4.0.0
function startGifted() {
const child = spawn("node", ["gift.js"], {
cwd: __dirname,
stdio: "inherit",
shell: true
});
child.on("close", (code) => {
if (code === 2) {
console.log("Restarting Gifted-Md...");
startGifted();
}
});
}
startGifted();