-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
32 lines (28 loc) · 932 Bytes
/
main.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
const http = require('http')
const dontsleep = require('./heroku/dontsleep.js')
const tgBot = require('./spasinfo_bot.js')
const Subscriber = require('./subscribers')
setInterval(function () {
console.log('interval')
dontsleep.preventSleepHeroku()
.then(res => {
console.log(res)
})
.catch(e => {
console.log(e)
})
}, 10 * 60000)
const server = http.createServer(function (request, response) {
Subscriber.find()
.then(subscribers => {
response.writeHead(200, { 'Content-Type': 'text/plain' })
response.end('Dontgotoschool bot: ' + request.url + '\n subscribers count = ' + subscribers.length)
})
.catch(e => {
console.log('error: ' + e)
response.writeHead(200, { 'Content-Type': 'text/plain' })
response.end('Dontgotoschool bot: ' + request.url + '\n subscribers count = ?')
})
})
server.listen(process.env.PORT || 8000)
tgBot.startMonitorSpas74()