Aggiunto collegamento al server
This commit is contained in:
80
plugin/telegram/callbacks/settings.js
Normal file
80
plugin/telegram/callbacks/settings.js
Normal file
@@ -0,0 +1,80 @@
|
||||
module.exports = [
|
||||
{
|
||||
id: 'set-meteo',
|
||||
execute: async ({ bot, chatId, app }) => {
|
||||
const config = app.mebConfig;
|
||||
const currentFreqMin = config.forecast_current_frequency / 60000;
|
||||
const hourlyFreqMin = config.forecast_hourly_frequency / 60000;
|
||||
|
||||
const msg = `*Configura Aggiornamenti Meteo*\n\n` +
|
||||
`Aggiorno il meteo (attuale) ogni *${currentFreqMin} minuti*\n` +
|
||||
`Registro le previsioni future (prossimi 7 giorni) ogni *${hourlyFreqMin} minuti*`;
|
||||
|
||||
await bot.sendMessage(chatId, msg, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_markup: {
|
||||
inline_keyboard: [
|
||||
[
|
||||
{ text: "1 sec", callback_data: 'set-meteo-curr-1' },
|
||||
{ text: "10 sec", callback_data: 'set-meteo-curr-10' },
|
||||
],
|
||||
[
|
||||
{ text: "1 min", callback_data: 'set-meteo-curr-60' },
|
||||
{ text: "10 min", callback_data: 'set-meteo-curr-600' }
|
||||
],
|
||||
[
|
||||
{ text: "30m", callback_data: 'set-meteo-hour-1800' }
|
||||
],
|
||||
[
|
||||
{ text: "⬅️ Indietro", callback_data: 'session-refresh' }
|
||||
]
|
||||
]
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
match: (data) => data.startsWith('set-meteo-curr-'),
|
||||
execute: async ({ bot, chatId, app, data, msg }) => {
|
||||
const val = parseInt(data.replace('set-meteo-curr-', ''), 10);
|
||||
if (app.mebPlugin && app.mebPlugin.setConfig) {
|
||||
app.mebPlugin.setConfig('forecast_current_frequency', val);
|
||||
await bot.editMessageText(`✅ Frequenza Aggiornamenti meteo aggiornata a *${val / 60} minuti*.\n_Ritorno al menu..._`, {
|
||||
chat_id: chatId,
|
||||
message_id: msg.message_id,
|
||||
parse_mode: 'Markdown'
|
||||
});
|
||||
setTimeout(() => {
|
||||
const sessionCmd = require('../commands/status.js');
|
||||
bot.editMessageText("*Servizi*\n\n", {
|
||||
chat_id: chatId, message_id: msg.message_id, parse_mode: 'Markdown', reply_markup: sessionCmd.createSessionMenu(app).reply_markup
|
||||
}).catch(() => { });
|
||||
}, 3000);
|
||||
} else {
|
||||
await bot.sendMessage(chatId, "Errore: il plugin non è accessibile per salvare la configurazione.");
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
match: (data) => data.startsWith('set-meteo-hour-'),
|
||||
execute: async ({ bot, chatId, app, data, msg }) => {
|
||||
const val = parseInt(data.replace('set-meteo-hour-', ''), 10);
|
||||
if (app.mebPlugin && app.mebPlugin.setConfig) {
|
||||
app.mebPlugin.setConfig('forecast_hourly_frequency', val);
|
||||
await bot.editMessageText(`✅ Frequenza previsioni future aggiornata a *${val / 60} minuti*.\n_Ritorno al menu..._`, {
|
||||
chat_id: chatId,
|
||||
message_id: msg.message_id,
|
||||
parse_mode: 'Markdown'
|
||||
});
|
||||
setTimeout(() => {
|
||||
const sessionCmd = require('../commands/status.js');
|
||||
bot.editMessageText("*Servizi*\n\n", {
|
||||
chat_id: chatId, message_id: msg.message_id, parse_mode: 'Markdown', reply_markup: sessionCmd.createSessionMenu(app).reply_markup
|
||||
}).catch(() => { });
|
||||
}, 3000);
|
||||
} else {
|
||||
await bot.sendMessage(chatId, "Errore: il plugin non è accessibile per salvare la configurazione.");
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
Reference in New Issue
Block a user