reinicio: fix phase_2
Signed-off-by: Rodrigo Martins <rodrigo@martinsevieira.adv.br>
This commit is contained in:
1 parent
ba6e765107
commit
728437c7c3
1 file changed
+12
-12
+12
-12
@@ -8686,6 +8686,10 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
|
|
||||||
const serialEscaped = serial.replace(/_/g, '\\_');
|
const serialEscaped = serial.replace(/_/g, '\\_');
|
||||||
|
|
||||||
|
// Gerar ID curto para callback_data
|
||||||
|
const restartId = String(++this._restartIdCounter);
|
||||||
|
this.pendingRestarts.set(restartId, { serial, base, location });
|
||||||
|
|
||||||
await this.bot.sendMessage(chatId,
|
await this.bot.sendMessage(chatId,
|
||||||
`⚠️ *Confirmar Reinicialização de ONU*\n\n` +
|
`⚠️ *Confirmar Reinicialização de ONU*\n\n` +
|
||||||
`📦 *Serviço:* ${nome}\n` +
|
`📦 *Serviço:* ${nome}\n` +
|
||||||
@@ -8698,7 +8702,7 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
reply_markup: {
|
reply_markup: {
|
||||||
inline_keyboard: [
|
inline_keyboard: [
|
||||||
[
|
[
|
||||||
{ text: '✅ SIM, Reiniciar', callback_data: `confirm_restart_onu_${serial}_${base}_${location}` },
|
{ text: '✅ SIM, Reiniciar', callback_data: `confirm_restart_onu_${restartId}` },
|
||||||
{ text: '❌ Cancelar', callback_data: 'cancel_action' }
|
{ text: '❌ Cancelar', callback_data: 'cancel_action' }
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@@ -8758,21 +8762,17 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
const chatId = callbackQuery.message.chat.id;
|
const chatId = callbackQuery.message.chat.id;
|
||||||
await this.bot.answerCallbackQuery(callbackQuery.id);
|
await this.bot.answerCallbackQuery(callbackQuery.id);
|
||||||
|
|
||||||
// Formato: confirm_restart_onu_SERIAL_BASE_LOCATION
|
// Formato: confirm_restart_onu_ID
|
||||||
const rest = data.replace('confirm_restart_onu_', '');
|
const restartId = data.replace('confirm_restart_onu_', '');
|
||||||
// Serial é o primeiro token (12 chars alfanuméricos)
|
const pending = this.pendingRestarts.get(restartId);
|
||||||
const serialMatch = rest.match(/^([A-Za-z0-9]+)_(.*)$/);
|
if (!pending) {
|
||||||
if (!serialMatch) {
|
await this.bot.sendMessage(chatId, '❌ Dados de reinicialização expirados. Tente novamente.');
|
||||||
await this.bot.sendMessage(chatId, '❌ Erro ao processar dados de reinicialização.');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.pendingRestarts.delete(restartId);
|
||||||
|
|
||||||
const serial = serialMatch[1];
|
const { serial, base } = pending;
|
||||||
const remaining = serialMatch[2]; // BASE_LOCATION
|
|
||||||
const base = remaining; // usa o restante como base (pode conter location junto)
|
|
||||||
|
|
||||||
const oltHint = this._resolverOLTporBase(base);
|
const oltHint = this._resolverOLTporBase(base);
|
||||||
|
|
||||||
const serialEscaped = serial.replace(/_/g, '\\_');
|
const serialEscaped = serial.replace(/_/g, '\\_');
|
||||||
|
|
||||||
await this.bot.editMessageText(
|
await this.bot.editMessageText(
|
||||||
|
|||||||
Reference in new issue
Block a user