refactor: Update credential synchronization to async Gitea fetch and simplify root HTML serving.

This commit is contained in:
2026-03-24 02:26:23 +00:00
parent cb729809a9
commit 2480846e31
3 changed files with 27 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
import os
import asyncio
import re
import logging
from telegram import Update
from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes
from orchestrator import (
@@ -12,6 +13,13 @@ import speech_recognition as sr
from pydub import AudioSegment
from gtts import gTTS
# Configuração de logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO
)
logger = logging.getLogger(__name__)
TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
ALLOWED_CHAT_ID = os.getenv("TELEGRAM_CHAT_ID")
@@ -74,8 +82,9 @@ async def handle_text(update: Update, context: ContextTypes.DEFAULT_TYPE):
else:
# Fallback AI Agent
from config import get_config
from ai_agent import query_agent_async
cfg = get_config()
reply = query_agent(user_msg, override_provider=cfg.get("active_provider"))
reply = await query_agent_async(user_msg, override_provider=cfg.get("active_provider"))
await update.message.reply_text(reply)
async def handle_voice(update: Update, context: ContextTypes.DEFAULT_TYPE):
@@ -94,6 +103,10 @@ def get_telegram_app():
return app
if __name__ == "__main__":
app = get_telegram_app()
print("Bot iniciando...")
app.run_polling(drop_pending_updates=True)
logger.info("Bot começando a inicialização...")
try:
app = get_telegram_app()
logger.info("Bot online. Iniciando polling...")
app.run_polling(drop_pending_updates=True)
except Exception as e:
logger.error(f"Erro fatal ao iniciar bot: {e}")