suporte: fix função
Signed-off-by: Rodrigo Bertoldo de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
7aad2f17b6
commit
384d04f383
1 file changed
+68
@@ -6361,6 +6361,74 @@ Digite /help para ver todos os comandos disponíveis!
|
|||||||
this.userSessions.delete(userId);
|
this.userSessions.delete(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback: Seleção de cliente via botão inline no fluxo de suporte
|
||||||
|
*/
|
||||||
|
async handleSuporteClienteCallback(callbackQuery, data) {
|
||||||
|
const chatId = callbackQuery.message.chat.id;
|
||||||
|
const userId = callbackQuery.from.id;
|
||||||
|
|
||||||
|
await this.bot.answerCallbackQuery(callbackQuery.id);
|
||||||
|
|
||||||
|
const index = parseInt(data.replace('suporte_cliente_', ''));
|
||||||
|
|
||||||
|
const sessaoAtiva = Array.from(this.suporteSessions.values()).find(
|
||||||
|
session => session.chatId === chatId && session.userId === userId
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!sessaoAtiva) {
|
||||||
|
await this.bot.sendMessage(chatId,
|
||||||
|
`❌ **Sessão expirada**\n\nUse o comando "abrir suporte" para iniciar novamente.`,
|
||||||
|
{ parse_mode: 'Markdown' }
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const clientes = sessaoAtiva.dados.clientesEncontrados;
|
||||||
|
if (!clientes || index < 0 || index >= clientes.length) {
|
||||||
|
await this.bot.sendMessage(chatId, `❌ **Cliente inválido.** Por favor, tente novamente.`, { parse_mode: 'Markdown' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sessaoAtiva.dados.clienteSelecionado = clientes[index];
|
||||||
|
sessaoAtiva.etapa = 'selecionar_servico';
|
||||||
|
await this.processarEtapaSelecionarServico(sessaoAtiva.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback: Seleção de serviço via botão inline no fluxo de suporte
|
||||||
|
*/
|
||||||
|
async handleSuporteServicoCallback(callbackQuery, data) {
|
||||||
|
const chatId = callbackQuery.message.chat.id;
|
||||||
|
const userId = callbackQuery.from.id;
|
||||||
|
|
||||||
|
await this.bot.answerCallbackQuery(callbackQuery.id);
|
||||||
|
|
||||||
|
const index = parseInt(data.replace('suporte_servico_', ''));
|
||||||
|
|
||||||
|
const sessaoAtiva = Array.from(this.suporteSessions.values()).find(
|
||||||
|
session => session.chatId === chatId && session.userId === userId
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!sessaoAtiva) {
|
||||||
|
await this.bot.sendMessage(chatId,
|
||||||
|
`❌ **Sessão expirada**\n\nUse o comando "abrir suporte" para iniciar novamente.`,
|
||||||
|
{ parse_mode: 'Markdown' }
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const servicos = sessaoAtiva.dados.servicos;
|
||||||
|
if (!servicos || index < 0 || index >= servicos.length) {
|
||||||
|
await this.bot.sendMessage(chatId, `❌ **Serviço inválido.** Por favor, tente novamente.`, { parse_mode: 'Markdown' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sessaoAtiva.dados.servicoSelecionado = servicos[index];
|
||||||
|
sessaoAtiva.etapa = 'selecionar_categoria';
|
||||||
|
await this.processarEtapaSelecionarCategoria(sessaoAtiva.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = BotHandler;
|
module.exports = BotHandler;
|
||||||
Reference in new issue
Block a user