-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (36 loc) · 1015 Bytes
/
index.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
import {findTimeZone, getZonedTime} from 'timezone-support';
import * as dotenv from 'dotenv';
import {initBot, sendStatus} from './bot.js';
import {searchBookings} from './camping-api.js';
import {updateStore} from './store.js';
dotenv.config();
initBot({
token: process.env.TELEGRAM_BOT_TOKEN,
newChatId: process.env.CHAT_ID,
});
const anreise = '16.08.2021';
const abreise = '23.08.2021';
const tage = '7';
updateStore({
anreise,
abreise,
tage,
});
const checkCampingSite = async () => {
const nativeDate = new Date();
const berlin = findTimeZone('Europe/Berlin');
const dt = getZonedTime(nativeDate, berlin);
console.log(
`[${dt.day}.${dt.month}-${dt.hours}:${dt.minutes}:${dt.seconds}] Check new Data`,
);
const data = await searchBookings();
const result = updateStore(data);
if (result) {
sendStatus();
}
};
await checkCampingSite();
sendStatus();
setInterval(async () => {
await checkCampingSite();
}, 1000 * 1 * 60);