Update Telegramm version and Delete Wrong command

This commit is contained in:
Stefan
2025-07-26 11:19:03 +02:00
parent 8c271c9fe5
commit 4460958c40
3 changed files with 906 additions and 259 deletions

1133
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,7 @@
"https": "^1.0.0", "https": "^1.0.0",
"joi": "^17.9.1", "joi": "^17.9.1",
"jspdf": "^2.5.1", "jspdf": "^2.5.1",
"node-telegram-bot-api": "^0.61.0", "node-telegram-bot-api": "github:yagop/node-telegram-bot-api#6d7adc3",
"path": "^0.12.7", "path": "^0.12.7",
"pdf-to-printer": "^5.6.0", "pdf-to-printer": "^5.6.0",
"puppeteer": "^19.9.0" "puppeteer": "^19.9.0"

View File

@@ -34,22 +34,12 @@ const credentials = {
cert: certificate, cert: certificate,
}; };
const callWebhooks = async (title) => { const callWebhooks = async (ucr_addressed) => {
config?.triggerWebhooks?.forEach(async (webhook) => { config?.triggerWebhooks?.forEach(async (webhook) => {
if (webhook?.filter?.length > 0) { if (ucr_addressed.find((x) => x == webhook?.DiveraUCR) != undefined) {
let filterPass = true;
webhook?.filter?.forEach((filter) => {
if (title.includes(filter)) filterPass = false;
});
try {
if (filterPass) axios.get(webhook.url);
} catch (err) {
console.error(err);
}
} else {
try { try {
axios.get(webhook.url); axios.get(webhook.url);
if (webhook.telegrammID) sendMessage("🚨 EINSATZ FÜR DIE FEUERWEHR AURICH 🚨", [webhook.telegrammID]);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }
@@ -72,14 +62,13 @@ function sendMessage(msg, idList) {
} }
if (config.activate_telegram) { if (config.activate_telegram) {
const token = "6150769224:AAGhBagPEi23QtBJl65YNuwEBBXwHguDV0E"; const token = "8483944836:AAFC0lqdertqrZw4KcNC9BKs8C1vKuWGZ-E";
bot = new TelegramBot(token, { polling: true }); bot = new TelegramBot(token, { polling: true });
bot.setMyCommands([ bot.setMyCommands([
{ command: "/chatid", description: "Zeigt deine Chat ID" }, { command: "/chatid", description: "Zeigt deine Chat ID" },
{ command: "/druckerliste", description: "Zeigt alle Drucker" }, { command: "/druckerliste", description: "Zeigt alle Drucker" },
{ command: "/testWebhook [label]", description: "Test Webhook" },
]); ]);
bot.on("message", async (msg) => { bot.on("message", async (msg) => {
@@ -180,14 +169,15 @@ async function puppeteerGetImage(lat, lng) {
async function main(data) { async function main(data) {
if (config.activate_telegram) { if (config.activate_telegram) {
sendMessage( sendMessage(
`[INFO]: Einsatz\nStichwort: ${data.title}\nMeldung: ${data.text}\nAdresse: ${ `[INFO]: Einsatz\nStichwort: ${data.title}\nMeldung: ${data.text}\n${
data.address data?.address &&
}\nhttps://www.google.com/maps/search/${data.address.replaceAll(" ", "+")}`, `Adresse: ${data.address}\nhttps://www.google.com/maps/search/${data.address.replaceAll(" ", "+")}`
}`,
messageIDs messageIDs
); );
} }
await callWebhooks(data.title); await callWebhooks(data.ucr_addressed);
if ( if (
data.title.includes("Probealarm") || data.title.includes("Probealarm") ||
@@ -226,7 +216,7 @@ app.get("/depesche", async (req, res) => {
fs.writeFileSync(cacheFolder + "data.json", JSON.stringify(res.data)); fs.writeFileSync(cacheFolder + "data.json", JSON.stringify(res.data));
} }
console.log(res.data); console.log(res.data);
value = res.data.data.items[res.data.data.sorting[0]]; value = res.data.data.items[res.data.data.sorting[2]];
}); });
} catch (error) { } catch (error) {
if (config.activate_telegram) { if (config.activate_telegram) {