35 lines
947 B
JavaScript
35 lines
947 B
JavaScript
|
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
|
||
|
|
||
|
/** LineNotify */
|
||
|
class LineNotifyClass {
|
||
|
Send(message) {
|
||
|
const data = `message=\n${message}`;
|
||
|
|
||
|
const xhr = new XMLHttpRequest();
|
||
|
|
||
|
xhr.addEventListener("readystatechange", function () {
|
||
|
if (this.readyState === 4) {
|
||
|
// console.log(this.responseText);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
xhr.open("POST", "https://notify-api.line.me/api/notify");
|
||
|
xhr.setRequestHeader("Authorization", "Bearer Dkv8Yh1Li3XsKFqZkmFMNP5o0JDSvan7qfcDmSv9GJr");
|
||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||
|
|
||
|
xhr.send(data);
|
||
|
}
|
||
|
|
||
|
SendBadmintonNotify() {
|
||
|
const xhr = new XMLHttpRequest();
|
||
|
xhr.addEventListener("readystatechange", function () {
|
||
|
if (this.readyState === 4) {
|
||
|
// console.log(this.responseText);
|
||
|
}
|
||
|
});
|
||
|
xhr.open("POST", "http://jianmiau.tk:1880/BadmintonNotify");
|
||
|
xhr.send();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = LineNotifyClass
|