Initial commit
This commit is contained in:
commit
1aba2be026
|
@ -0,0 +1,2 @@
|
|||
# Project exclude paths
|
||||
/node_modules/
|
|
@ -0,0 +1,38 @@
|
|||
const { Webhook } = require('discord-webhook-node');
|
||||
const rp = require('request-promise');
|
||||
require('dotenv').config()
|
||||
|
||||
const hook = new Webhook(`${process.env.WEBHOOK}`);
|
||||
const IMAGE_URL = 'https://tun-chemnitz.de/media/images/IMG_20220827_135030.max-640x480.jpg';
|
||||
|
||||
hook.setUsername('ChChHook');
|
||||
hook.setAvatar(IMAGE_URL);
|
||||
|
||||
let currentStatus = false;
|
||||
|
||||
function currentStatusRead(currentStatus) {
|
||||
if (currentStatus === false) {
|
||||
return 'geschlossen';
|
||||
} else {
|
||||
return 'offen';
|
||||
}
|
||||
}
|
||||
|
||||
const options = {
|
||||
url: 'https://chch.it/chch.json',
|
||||
};
|
||||
|
||||
setInterval(function() {
|
||||
rp(options)
|
||||
.then((body) => {
|
||||
const json = JSON.parse(body);
|
||||
if (currentStatus !== json.state.open) {
|
||||
currentStatus = json.state.open;
|
||||
hook.send(`<@286015596875874305> ChCh ist jetzt ${currentStatusRead(currentStatus)}`);
|
||||
console.log(json.state.open);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}, 60 * 1000);
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "chchbot",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"discord-webhook-node": "^1.1.8",
|
||||
"dotenv": "^16.0.3",
|
||||
"request": "^2.88.2",
|
||||
"request-promise": "^4.2.6"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue