Update Telegramm version and Delete Wrong command
This commit is contained in:
1133
package-lock.json
generated
1133
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@
|
||||
"https": "^1.0.0",
|
||||
"joi": "^17.9.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",
|
||||
"pdf-to-printer": "^5.6.0",
|
||||
"puppeteer": "^19.9.0"
|
||||
|
||||
30
src/index.js
30
src/index.js
@@ -34,22 +34,12 @@ const credentials = {
|
||||
cert: certificate,
|
||||
};
|
||||
|
||||
const callWebhooks = async (title) => {
|
||||
const callWebhooks = async (ucr_addressed) => {
|
||||
config?.triggerWebhooks?.forEach(async (webhook) => {
|
||||
if (webhook?.filter?.length > 0) {
|
||||
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 {
|
||||
if (ucr_addressed.find((x) => x == webhook?.DiveraUCR) != undefined) {
|
||||
try {
|
||||
axios.get(webhook.url);
|
||||
if (webhook.telegrammID) sendMessage("🚨 EINSATZ FÜR DIE FEUERWEHR AURICH 🚨", [webhook.telegrammID]);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
@@ -72,14 +62,13 @@ function sendMessage(msg, idList) {
|
||||
}
|
||||
|
||||
if (config.activate_telegram) {
|
||||
const token = "6150769224:AAGhBagPEi23QtBJl65YNuwEBBXwHguDV0E";
|
||||
const token = "8483944836:AAFC0lqdertqrZw4KcNC9BKs8C1vKuWGZ-E";
|
||||
|
||||
bot = new TelegramBot(token, { polling: true });
|
||||
|
||||
bot.setMyCommands([
|
||||
{ command: "/chatid", description: "Zeigt deine Chat ID" },
|
||||
{ command: "/druckerliste", description: "Zeigt alle Drucker" },
|
||||
{ command: "/testWebhook [label]", description: "Test Webhook" },
|
||||
]);
|
||||
|
||||
bot.on("message", async (msg) => {
|
||||
@@ -180,14 +169,15 @@ async function puppeteerGetImage(lat, lng) {
|
||||
async function main(data) {
|
||||
if (config.activate_telegram) {
|
||||
sendMessage(
|
||||
`[INFO]: Einsatz\nStichwort: ${data.title}\nMeldung: ${data.text}\nAdresse: ${
|
||||
data.address
|
||||
}\nhttps://www.google.com/maps/search/${data.address.replaceAll(" ", "+")}`,
|
||||
`[INFO]: Einsatz\nStichwort: ${data.title}\nMeldung: ${data.text}\n${
|
||||
data?.address &&
|
||||
`Adresse: ${data.address}\nhttps://www.google.com/maps/search/${data.address.replaceAll(" ", "+")}`
|
||||
}`,
|
||||
messageIDs
|
||||
);
|
||||
}
|
||||
|
||||
await callWebhooks(data.title);
|
||||
await callWebhooks(data.ucr_addressed);
|
||||
|
||||
if (
|
||||
data.title.includes("Probealarm") ||
|
||||
@@ -226,7 +216,7 @@ app.get("/depesche", async (req, res) => {
|
||||
fs.writeFileSync(cacheFolder + "data.json", JSON.stringify(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) {
|
||||
if (config.activate_telegram) {
|
||||
|
||||
Reference in New Issue
Block a user