From 384d04f383c84942665089be20d9a1eeded8950b Mon Sep 17 00:00:00 2001 From: Rodrigo Bertoldo de Sousa Martins Date: Sun, 29 Mar 2026 16:55:35 -0300 Subject: [PATCH] =?UTF-8?q?suporte:=20fix=20fun=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rodrigo Bertoldo de Sousa Martins --- src/bot/handler.js | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/bot/handler.js b/src/bot/handler.js index dd3947f..d65d72d 100644 --- a/src/bot/handler.js +++ b/src/bot/handler.js @@ -6361,6 +6361,74 @@ Digite /help para ver todos os comandos disponíveis! 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;