This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathscore.js
51 lines (48 loc) · 1.42 KB
/
score.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
const fetch = require('node-fetch');
require('dotenv').config();
function LiveMessage(hello) {
if (process.env.APIURL) {
var url = process.env.APIURL
var data = {
chat_id: process.env.TELEGRAM_CHATID,
parse_mode: 'html',
text: hello
};
fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then((response) => {
if (response.status === 200) {
console.log('Notification Send via Bot');
} else {
console.log('Failed to send');
}
})
.catch(error => {
if (!error.response) {
console.log('API URL is Missing');
} else {
console.log(error);
}
});
} else {
console.log('ENV Error: API URL and CHAT ID is Missing');
}
}
var url = process.env.MATCHURL;
async function fetchscore() {
try {
const response = await fetch(url);
const data = await response.json();
console.log(data.livescore.score);
LiveMessage(data.livescore.score);
} catch (exception) {
console.log('Connection Lost');
}
}
fetchscore();