Aggiunto collegamento al server
This commit is contained in:
67
plugin/telegram/callbacks/status.js
Normal file
67
plugin/telegram/callbacks/status.js
Normal file
@@ -0,0 +1,67 @@
|
||||
const realtime = require('../../realtime/core.js');
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
id: 'session-weather-toggle',
|
||||
execute: async ({ bot, chatId, app, msg }) => {
|
||||
if (!app.mebPlugin) {
|
||||
return bot.answerCallbackQuery(msg.id, { text: "Errore: Plugin Meteo non caricato" });
|
||||
}
|
||||
|
||||
let isActive = app.mebPlugin.isPollingActive();
|
||||
|
||||
if (isActive) {
|
||||
app.mebPlugin.stopPolling();
|
||||
} else {
|
||||
app.mebPlugin.startPolling();
|
||||
}
|
||||
|
||||
const sessionCmd = require('../commands/status.js');
|
||||
const newMarkup = sessionCmd.createSessionMenu(app);
|
||||
|
||||
await bot.editMessageReplyMarkup(newMarkup.reply_markup, {
|
||||
chat_id: chatId,
|
||||
message_id: msg.message_id
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'session-realtime-info',
|
||||
execute: async ({ bot, chatId, msg }) => {
|
||||
const stats = realtime.getStats();
|
||||
|
||||
let text = `📡 *Stato Realtime*\n\n`;
|
||||
text += `Stato: *${stats.status}*\n`;
|
||||
text += `Sensore: \`${stats.sensorID}\`\n`;
|
||||
text += `Messaggi inviati: *${stats.sent}*\n`;
|
||||
text += `Buffer: ${stats.buffered} msg\n`;
|
||||
text += `Riconnessioni: ${stats.reconnections}\n`;
|
||||
text += `\n_I dati vengono inviati automaticamente ogni ${stats.sentEveryMLS / 1000}s_`;
|
||||
|
||||
await bot.answerCallbackQuery(msg.id, { text: `Realtime: ${stats.status} | ${stats.sent} msg inviati` });
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'session-refresh',
|
||||
execute: async ({ bot, chatId, app, msg }) => {
|
||||
const sessionCmd = require('../commands/status.js');
|
||||
const newMarkup = sessionCmd.createSessionMenu(app);
|
||||
|
||||
const now = new Date().toLocaleTimeString('it-IT');
|
||||
const newText = `*Servizi*\n\n_(Ultimo aggiornamento: ${now})_`;
|
||||
|
||||
try {
|
||||
await bot.editMessageText(newText, {
|
||||
chat_id: chatId,
|
||||
message_id: msg.message_id,
|
||||
parse_mode: 'Markdown',
|
||||
reply_markup: newMarkup.reply_markup
|
||||
});
|
||||
} catch (e) {
|
||||
if (!e.message.includes('message is not modified')) {
|
||||
console.error("Errore nel refresh session:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
Reference in New Issue
Block a user