🚀 Auto-deploy: BotVPS atualizado em 29/04/2026 10:21:34
This commit is contained in:
@@ -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
|
||||
|
||||
6
main.py
6
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."}
|
||||
|
||||
Reference in New Issue
Block a user