-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
57 lines (49 loc) · 1.92 KB
/
app.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const Twit = require('twit')
const config = require('./config.js')
const schedule = require('node-schedule')
const axios = require('axios')
const T = new Twit(config);
const jobIndonesia = schedule.scheduleJob('0 2,14 * * *', function(){
axios.get('https://api.kawalcorona.com/indonesia')
.then((response) => {
let positif = response.data[0].positif
let sembuh = response.data[0].sembuh
let meninggal = response.data[0].meninggal
let dirawat = response.data[0].dirawat
let tweet = `Update jumlah kasus Covid-19 Indonesia,\n\nTotal Kasus Positif ${positif}\nTotal Kasus Sembuh ${sembuh}\nTotal Meninggal ${meninggal}\nDalam Perawatan ${dirawat}`
return T.post('statuses/update', { status: tweet })
})
.then((response) => {
console.log("Berhasil ngetwit")
})
.catch((error) => {
console.log(error)
})
});
const jobWorld = schedule.scheduleJob('0 1,13 * * *', function(){
let positif = ""
let sembuh = ""
let meninggal = ""
axios.get('https://api.kawalcorona.com/positif')
.then((response) => {
positif = response.data.value
return axios.get('https://api.kawalcorona.com/sembuh')
})
.then((response) => {
sembuh = response.data.value
return axios.get('https://api.kawalcorona.com/meninggal')
})
.then((response) => {
meninggal = response.data.value
})
.then((response) => {
let tweet = `Update jumlah kasus Covid-19 Dunia,\n\nTotal Kasus Positif ${positif}\nTotal Kasus Sembuh ${sembuh}\nTotal Meninggal ${meninggal}`
return T.post('statuses/update', { status: tweet })
})
.then((response) => {
console.log("Berhasil ngetwit")
})
.catch((error) => {
console.log(error)
})
});