Aggiunge 2 nuove variabili d'ambiente:
- SIGNALK_FILES, per specificare dove verranno salvati i file generati dal plugin - HOST_NAME, per specificare il nome del dispositivo che sta hostando il plugin. Inoltre, migliora il codice e lo adatta al nuovo path variabile SIGNALK_FILES
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { paths } = require("../config.js");
|
||||
const {
|
||||
encrypt,
|
||||
decrypt,
|
||||
@@ -64,9 +65,9 @@ const CONFIG = {
|
||||
fileExpirationTime: 10
|
||||
};
|
||||
|
||||
const telegram_users_file = path.join(__dirname, "..", "telegram_users.json");
|
||||
const logs_references_file = path.join(__dirname, "..", "datasetModels/logs_references.json");
|
||||
const authorized_admins_file = path.join(__dirname, "..", "authorized_admins.txt");
|
||||
const telegram_users_file = paths.telegramUsers;
|
||||
const logs_references_file = paths.logsReferences;
|
||||
const authorized_admins_file = paths.authorizedAdmins;
|
||||
|
||||
let app = null;
|
||||
|
||||
@@ -287,13 +288,24 @@ function getCurrentPosition() {
|
||||
}
|
||||
|
||||
async function send(message) {
|
||||
if (!bot) return;
|
||||
if (!bot) {
|
||||
console.warn('[Telegram] send() chiamato ma bot non inizializzato');
|
||||
return;
|
||||
}
|
||||
const users = loadUsers();
|
||||
const loggedUsers = users.filter(u => u.hasLoggedYet && u.chatID);
|
||||
|
||||
console.log(`[Telegram] send() - Utenti totali: ${users.length}, Utenti loggati: ${loggedUsers.length}`);
|
||||
|
||||
if (loggedUsers.length === 0) {
|
||||
console.warn('[Telegram] Nessun utente loggato a cui inviare il messaggio');
|
||||
return;
|
||||
}
|
||||
|
||||
for (const user of loggedUsers) {
|
||||
try {
|
||||
await bot.sendMessage(user.chatID, message);
|
||||
console.log(`[Telegram] Messaggio inviato a ${user.chatID}`);
|
||||
} catch (error) {
|
||||
console.error(`[Telegram] Send error to ${user.chatID}:`, error.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user