-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·54 lines (50 loc) · 1.86 KB
/
main.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
52
53
54
function send_telegram(user_to_send, text, keyboard, one_time = true) {
if (keyboard == null) {
sendTo('telegram', {
user: user_to_send,
text: text,
parse_mode: "HTML"
});
} else {
sendTo('telegram', {
user: user_to_send,
text: text,
parse_mode: "HTML",
reply_markup: {
keyboard: keyboard,
resize_keyboard: true,
one_time_keyboard: one_time
}
});
}
}
on({ id: 'telegram.0.communicate.request', change: 'any' }, function (obj) {
var main_menu_commands = ["übersicht", "start", "anfang", "info", "main", "man"];
var windows_commands = ["fenster",];
var stateval = getState('telegram.0.communicate.request').val;
var user_to_send = stateval.substring(1, stateval.indexOf("]"));
var command = stateval.substring(stateval.indexOf("]") + 1, stateval.length).toLowerCase();
var output = "";
if (main_menu_commands.indexOf(command) != -1) {
send_telegram(user_to_send, "Ich bin Heathcliff dein Buttler.",
[["Heitzung", "Fenster","Wetter"],
["Tanken","Licht","Miss_Fine"],
["Einkaufsliste","Musik","Schichtplan"]], false);
} else if (windows_commands.indexOf(command) != -1) {
var count = 0;
var windows = getObject("enum.functions.fenster").common.members;
for (let i = 0; i < windows.length; i++) {
if (getState(windows[i] + ".isOpen").val) {
count++;
output += to_sting(windows[i], true) + "\n";
}
}
if (count == 0) {
output += "Alle Fenster sind zu ";
output += String.fromCharCode(0x2705);
} else {
output += String.fromCharCode(0x274C);
}
send_telegram(user_to_send, output, null);
}
});