Catch errors
This commit is contained in:
36
src/index.js
36
src/index.js
@@ -42,12 +42,19 @@ const callWebhooks = async (title) => {
|
|||||||
if (title.includes(filter)) filterPass = false;
|
if (title.includes(filter)) filterPass = false;
|
||||||
})
|
})
|
||||||
|
|
||||||
if (filterPass) await axios.get(webhook.url);
|
try {
|
||||||
|
if (filterPass) axios.get(webhook.url);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
await axios.get(webhook.url);
|
try {
|
||||||
}
|
axios.get(webhook.url);
|
||||||
});
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let bot = null;
|
let bot = null;
|
||||||
@@ -56,7 +63,11 @@ const messageIDs = config.telegrammessageIDs || [];
|
|||||||
|
|
||||||
function sendMessage(msg, idList) {
|
function sendMessage(msg, idList) {
|
||||||
idList.forEach((id) => {
|
idList.forEach((id) => {
|
||||||
bot.sendMessage(id, msg);
|
try {
|
||||||
|
bot.sendMessage(id, msg);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +88,12 @@ if (config.activate_telegram) {
|
|||||||
|
|
||||||
|
|
||||||
switch (msg.text) {
|
switch (msg.text) {
|
||||||
case "/chatid":
|
case "/chatid": ,
|
||||||
bot.sendMessage(chatId, "Deine Chat ID ist: " + chatId);
|
try {
|
||||||
|
bot.sendMessage(chatId, "Deine Chat ID ist: " + chatId);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "/druckerliste":
|
case "/druckerliste":
|
||||||
let message = "";
|
let message = "";
|
||||||
@@ -88,7 +103,11 @@ if (config.activate_telegram) {
|
|||||||
message += printer.deviceId + "\n";
|
message += printer.deviceId + "\n";
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.sendMessage(chatId, "Drucker Liste:\n" + message);
|
try {
|
||||||
|
bot.sendMessage(chatId, "Drucker Liste:\n" + message);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
if (msg.text.includes("/testWebhook")) {
|
if (msg.text.includes("/testWebhook")) {
|
||||||
config?.triggerWebhooks?.forEach(async (webhook) => {
|
config?.triggerWebhooks?.forEach(async (webhook) => {
|
||||||
@@ -166,6 +185,7 @@ async function puppeteerGetImage(lat, lng) {
|
|||||||
|
|
||||||
async function main(data) {
|
async function main(data) {
|
||||||
if (config.activate_telegram) {
|
if (config.activate_telegram) {
|
||||||
|
|
||||||
sendMessage("[INFO]: Einsatdepesche wird Gedruckt - " + data.title, messageIDs);
|
sendMessage("[INFO]: Einsatdepesche wird Gedruckt - " + data.title, messageIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user