-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtelegram.js
33 lines (30 loc) · 894 Bytes
/
telegram.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
var jobName_telegram = "sendStatus";
var kue = require('kue-scheduler');
var Queue = kue.createQueue();
function checkStatus(job, done){
Parse.Cloud.httpRequest({
method: 'POST',
url: 'https://api.telegram.org/botYOUR_API_BOT/sendMessage?chat_id=YOUR_CHAT_ID',
params: {
text : 'Server is running.'
},
headers: {
'Content-Type': 'application/json;charset=utf-8'
}
}).then(function(httpResponse) {
done();
}, function(httpResponse) {
done(new Error(httpResponse.status));
});
}
function initCheckStatus(){
Queue.clear(function(error, response) {
var job = Queue
.createJob(jobName_telegram)
.priority('normal')
.removeOnComplete(true);
Queue.every('3 hours', job);
Queue.process(jobName_telegram, checkStatus);
});
}
exports.initCheckStatus = initCheckStatus;