-
Notifications
You must be signed in to change notification settings - Fork 8
/
printScreen.js
66 lines (59 loc) · 1.69 KB
/
printScreen.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
55
56
57
58
59
60
61
62
63
64
65
66
const printScreen = async (client, message, screen) => {
screen.messages.forEach(async m => {
switch (m.type) {
case "text":
try {
await client.sendText(message.from, m.data);
} catch (error) {
console.error("Error al envir mensaje");
}
break;
case "image":
try {
await client.sendFile(message.from, m.data, "", "");
} catch (error) {
console.error("Error al envir imágen");
}
break;
case "location":
try {
await client.sendLocation(message.from, m.lat, m.lon, "");
} catch (error) {
console.error("Error al enviar ubicación");
}
break;
default:
break;
}
});
if (screen.type === "menu" || screen.type === "submenu") {
var currentMessage = "";
Object.entries(screen.childrens).forEach(([key, value], index) => {
let letter = key.toUpperCase();
let title = value.title;
currentMessage = currentMessage + `*${letter}*. ${title}\n`;
});
if (screen.type === "menu") {
currentMessage = currentMessage.trim();
} else {
currentMessage = currentMessage + "*X*. Realizar otra consulta";
}
try {
await client.sendText(message.from, currentMessage);
} catch (error) {
console.error("Error al envir mensaje");
}
} else {
setTimeout(async () => {
try {
await client.sendText(
message.from,
"🤖 Gracias por la consulta, envia cualquier mensaje para volver al inicio."
);
} catch (error) {
console.error("Error al envir mensaje");
}
}, 4000);
}
};
module.exports = printScreen;