From f9df9713db0b3325d5c5f386ac4c2f0d1a7f2ff6 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Wed, 29 Apr 2026 10:21:34 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Auto-deploy:=20BotVPS=20atualiza?= =?UTF-8?q?do=20em=2029/04/2026=2010:21:34?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bridge_telegram.py | 7 +++++-- main.py | 6 +++--- tools.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bridge_telegram.py b/bridge_telegram.py index c6d21f6..16d718d 100644 --- a/bridge_telegram.py +++ b/bridge_telegram.py @@ -16,6 +16,9 @@ ALLOWED_USER_ID = os.getenv("TELEGRAM_CHAT_ID") API_PORT = os.getenv("PORT", "8001") API_BASE_URL = f"http://localhost:{API_PORT}" +# Timeout aumentado para 300s para permitir que o Agente execute múltiplas ferramentas +GLOBAL_TIMEOUT = 300.0 + # O ID permitido deve ser comparado como string ou int, padronizando aqui if ALLOWED_USER_ID: ALLOWED_USER_ID = int(ALLOWED_USER_ID) @@ -32,7 +35,7 @@ chat_histories = {} async def call_antigravity_api(endpoint: str, payload: dict) -> str: """Faz a chamada para a API interna do BotVPS.""" - async with httpx.AsyncClient(timeout=120.0) as client: + async with httpx.AsyncClient(timeout=GLOBAL_TIMEOUT) as client: try: logger.info(f"Enviando payload para {endpoint}: {payload.get('text', payload.get('task'))}") response = await client.post(f"{API_BASE_URL}{endpoint}", json=payload) @@ -129,7 +132,7 @@ async def handle_voice(update: Update, context: ContextTypes.DEFAULT_TYPE): # 2. Envia para a API interna de áudio # Como o bridge e API estão na mesma máquina, compartilhamos o /tmp se necessário # Mas vamos usar multipart para ser fiel à API - async with httpx.AsyncClient(timeout=120.0) as client: + async with httpx.AsyncClient(timeout=GLOBAL_TIMEOUT) as client: try: with open(temp_path, "rb") as f: # O parâmetro history pode ser adicionado futuramente similar ao chat diff --git a/main.py b/main.py index 4b5b96f..dceb8cd 100644 --- a/main.py +++ b/main.py @@ -110,9 +110,9 @@ async def run_action(data: dict, is_auth: bool = Depends(verify_password)): if action_type == "ping": return {"status": "success", "message": "Pong! Servidor respondendo."} if action_type == "restart_bot": - # Simula reinício disparando sinal de término - o docker restart cuidará do resto - os.system("pkill -9 -f bot_logic.py") - return {"status": "success", "message": "Bot reiniciado."} + # Reinicia os serviços relevantes via PM2 + os.system("pm2 restart bridge-telegram") + return {"status": "success", "message": "Bot do Telegram reiniciado."} if action_type == "reboot_vps": return {"status": "error", "message": "Reboot bloqueado via Web por segurança."} return {"status": "error", "message": f"Ação {action_type} desconhecida."} diff --git a/tools.py b/tools.py index f808d4a..e18bbdb 100644 --- a/tools.py +++ b/tools.py @@ -23,7 +23,7 @@ def run_bash_command(command: str) -> str: shell=True, capture_output=True, text=True, - timeout=120, + timeout=60, env=custom_env )