const skFlow = require('../../config/skFlow'); const { liveMarkup } = require('../utility/live'); const logsPaths = [ "navigation.position", "navigation.headingTrue", "navigation.speedOverGround", "propulsion.p1.temperature" ]; module.exports = { command: 'data', handler: (bot, msg) => { const chatId = msg.chat.id; let text = ''; // Telemetria const logs = skFlow.getFrom(logsPaths); text += '*Telemetria di Bordo*\n\n'; if (logs && Object.keys(logs).length > 0) { for (const [path, value] of Object.entries(logs)) { const displayValue = typeof value === 'object' ? JSON.stringify(value) : value; text += `*${path}*: ${displayValue}\n`; } } else { text += 'Nessun dato disponibile.\n'; } // Meteo const weather = skFlow.getWithFilter('meb.forecast'); text += '\n*Dati Meteo*\n\n'; if (weather && Object.keys(weather).length > 0) { for (const [path, value] of Object.entries(weather)) { const displayValue = typeof value === 'object' ? JSON.stringify(value) : value; text += `*${path}*: ${displayValue}\n`; } } else { text += 'Nessun dato disponibile.\n'; } // Mare const marine = skFlow.getWithFilter('meb.marine'); text += '\n*Dati Meteo del mare*\n\n'; if (marine && Object.keys(marine).length > 0) { for (const [path, value] of Object.entries(marine)) { const displayValue = typeof value === 'object' ? JSON.stringify(value) : value; text += `*${path}*: ${displayValue}\n`; } } else { text += 'Nessun dato disponibile.\n'; } bot.sendMessage(chatId, text, { parse_mode: 'Markdown', reply_to_message_id: msg.message_id, reply_markup: liveMarkup(msg.message_id, 'data') }); } };