From e69349138bf18497014cca61144822012df754d2 Mon Sep 17 00:00:00 2001 From: Rodrigo Bertoldo de Sousa Martins Date: Thu, 25 Jun 2026 11:21:13 -0300 Subject: [PATCH] cidades: adicionar opcao de sair Signed-off-by: Rodrigo Bertoldo de Sousa Martins --- src/bot/handler.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/bot/handler.js b/src/bot/handler.js index da3205a..c040591 100644 --- a/src/bot/handler.js +++ b/src/bot/handler.js @@ -208,6 +208,10 @@ class BotHandler { await this.handleCidade(chatId, userId); break; + case 'sair': + await this.handleSairCidade(chatId, userId); + break; + case 'ssh': await this.handleSSH(chatId, target); break; @@ -448,6 +452,23 @@ Digite /help para ver todos os comandos disponíveis! await this.sendSiteSelectionMenu(chatId, siteIds); } + /** + * Comando /sair - sai da cidade/provedor ativo e exibe o menu de seleção novamente + */ + async handleSairCidade(chatId, userId) { + const siteIds = sites.getUserSiteIds(userId); + + if (siteIds.length <= 1) { + const site = sites.getSite(siteIds[0]) || this.getActiveSite(chatId); + await this.bot.sendMessage(chatId, `📍 Você só tem acesso a *${site.name}*, não há outra cidade para escolher.`, { parse_mode: 'Markdown' }); + return; + } + + this.activeSite.delete(chatId); + await this.bot.sendMessage(chatId, '👋 Você saiu da cidade/provedor ativo.'); + await this.sendSiteSelectionMenu(chatId, siteIds); + } + /** * Comando /help */ @@ -461,6 +482,8 @@ Digite /help para ver todos os comandos disponíveis! • /start - Inicia o bot • /help - Esta ajuda • /equipamentos - Lista equipamentos +• /cidade - Trocar cidade/provedor ativo +• /sair - Sair da cidade ativa e escolher outra 🏢 **GESTÃO DE CLIENTES:** • "buscar cliente João Silva"