From 720aec9c6a3a88d585a4f8481341df3cccec4903 Mon Sep 17 00:00:00 2001 From: Stefan080106 Date: Mon, 17 Apr 2023 19:58:46 +0200 Subject: [PATCH] Fix(telegram) global functions --- config.json | 2 +- src/index.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/config.json b/config.json index cdfbc83..ad4f5c1 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { - "activate_telegram": false, + "activate_telegram": true, "printer_device_id": "Microsoft Print to PDF", "debug": true } \ No newline at end of file diff --git a/src/index.js b/src/index.js index 51f4e97..3e4248b 100644 --- a/src/index.js +++ b/src/index.js @@ -23,12 +23,21 @@ const printerName = config.printer_device_id; const PORT = config.port || 2000; const cacheFolder = "./cache/" +let bot = null; + +const messageIDs = [1034133487] + +function sendMessage(msg, idList) { + idList.forEach((id) => { + bot.sendMessage(id, msg); + }) +} + if (config.activate_telegram) { const token = '6150769224:AAGhBagPEi23QtBJl65YNuwEBBXwHguDV0E'; - const messageIDs = [1034133487] - const bot = new TelegramBot(token, { polling: true }); + bot = new TelegramBot(token, { polling: true }); bot.setMyCommands([ { command: '/chatid', description: 'Zeigt deine Chat ID' }, @@ -56,11 +65,7 @@ if (config.activate_telegram) { }); - function sendMessage(msg, idList) { - idList.forEach((id) => { - bot.sendMessage(id, msg); - }) - } + sendMessage("[INFO]: Drucker Service wird gestartet", messageIDs) }