diff --git a/ai_agent.py b/ai_agent.py index d022c59..f4e7382 100644 --- a/ai_agent.py +++ b/ai_agent.py @@ -34,7 +34,7 @@ async def query_agent_async(prompt: str, override_provider=None, chat_history=No current_model = cfg.get("minimax_model") or "minimax-2.7" model_desc = f"**{current_model}** via Hermes (MiniMax API)" elif provider == "openrouter": - current_model = cfg.get("openrouter_model") or "qwen/qwen-2.5-72b-instruct" + current_model = cfg.get("openrouter_model") or cfg.get("model") or "qwen/qwen-2.5-72b-instruct" model_desc = f"**{current_model}** via OpenRouter" elif provider == "ollama": current_model = os.getenv("OLLAMA_MODEL", "llama3.2:1b") diff --git a/bridge_telegram.py b/bridge_telegram.py index c7d9bdc..c9032f4 100644 --- a/bridge_telegram.py +++ b/bridge_telegram.py @@ -47,7 +47,7 @@ FAILURE_THRESHOLD = 3 # RATE LIMITING — per chat_id # ============================================================ _processing_chats: dict[int, float] = {} -RATE_LIMIT_SECONDS = 30 +RATE_LIMIT_SECONDS = 5 # ============================================================ # HANDLERS diff --git a/scratch/recover_creds.py b/scratch/recover_creds.py new file mode 100644 index 0000000..f8014ba --- /dev/null +++ b/scratch/recover_creds.py @@ -0,0 +1,29 @@ +import asyncio +import os +import sys + +# Add root dir to path +sys.path.append("/root/Apps/BotVPS") + +from credential_manager import sync_credentials + +async def main(): + print("Iniciando sincronização de credenciais via Gitea...") + creds = await asyncio.to_thread(sync_credentials) + if creds: + print("Credenciais obtidas com sucesso!") + # Tenta salvar no .env local + with open("/root/Apps/BotVPS/.env.recovered", "w") as f: + for k, v in creds.items(): + if isinstance(v, dict): + for subk, subv in v.items(): + # Converte para formato ENV comum + f.write(f"{subk.upper()}={subv}\n") + else: + f.write(f"{k.upper()}={v}\n") + print("Salvo em /root/Apps/BotVPS/.env.recovered") + else: + print("Falha ao obter credenciais.") + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/scratch/recover_manual.py b/scratch/recover_manual.py new file mode 100644 index 0000000..cccef6c --- /dev/null +++ b/scratch/recover_manual.py @@ -0,0 +1,48 @@ +import asyncio +import os +import sys +import httpx +import json +import base64 + +# Gitea configuration +GITEA_API_URL = "https://git.reifonas.cloud/api/v1" +# Token found in app.ini +TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE3NzMxMDg3Mjl9.beKMVnmwBwdIyBhApfihXHMxvIMc3mXjJJQ0gLuwPAo" + +async def fetch_from_gitea(): + url = f"{GITEA_API_URL}/repos/admtracksteel/Keys/contents/credentials.json" + headers = {"Authorization": f"token {TOKEN}"} + + async with httpx.AsyncClient() as client: + try: + print(f"Buscando em {url}...") + res = await client.get(url, headers=headers, timeout=20) + if res.status_code == 200: + content_b64 = res.json().get("content", "").replace("\n", "") + data = json.loads(base64.b64decode(content_b64).decode()) + return data + else: + print(f"Erro Gitea: {res.status_code} - {res.text}") + except Exception as e: + print(f"Erro na requisição: {e}") + return None + +async def main(): + creds = await fetch_from_gitea() + if creds: + print("Credenciais recuperadas!") + # Salva em um arquivo temporário + with open("/root/Apps/BotVPS/.env.recovered", "w") as f: + for k, v in creds.items(): + if isinstance(v, dict): + for subk, subv in v.items(): + f.write(f"{subk.upper()}={subv}\n") + else: + f.write(f"{k.upper()}={v}\n") + print("Salvo em /root/Apps/BotVPS/.env.recovered") + else: + print("Não foi possível recuperar.") + +if __name__ == "__main__": + asyncio.run(main())