-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcheck.js
More file actions
42 lines (37 loc) · 1.45 KB
/
Copy pathcheck.js
File metadata and controls
42 lines (37 loc) · 1.45 KB
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
const path = require('path');
const webuntis = require("webuntis");
function showConfig(fileName) {
const filePath = path.resolve(fileName);
console.log("checking config file ", filePath);
const contents = require(filePath);
contents.modules
.filter((m) => m.module === "MMM-Webuntis")
.forEach((m) => {
console.log("module config found:");
m.config.students
.forEach((s) => {
console.log("student config found:");
console.log(s);
const untis = new webuntis(s.school, s.username, s.password, s.server);
console.log("fetching timetable:");
untis
.login()
.then(() => {
return untis.getOwnTimetableForToday();
})
.then((timetable) => {
// console.log(JSON.stringify(timetable, null, 2));
timetable.forEach((e) => console.log("* ", e.date, e.startTime, "-", e.endTime, e.activityType));
})
.catch((error) => {
console.error(error);
})
})
});
}
const fileName = process.argv[2];
if (!fileName) {
console.error('specify a config file, usually config/config.js');
process.exit(1);
}
showConfig(fileName);