Files
telegram_new_socias/main.py
google-labs-jules[bot] fec578bd7c feat: Dockerize application and add MySQL logging
This commit introduces Docker and Docker Compose to containerize the application and orchestrate it with a MySQL database.

Key changes include:
- Added a `Dockerfile` to create a container for the Python bot.
- Created a `docker-compose.yml` file to manage the bot and MySQL services.
- Added a `modules/database.py` module to handle database connections and logging with SQLAlchemy.
- Integrated request logging into all command handlers.
- Updated `requirements.txt` with necessary dependencies for MySQL.
- Updated `.env` and `.gitignore` to manage database credentials securely.
- Updated `Readme.md` with instructions on how to run the application using Docker Compose.
2025-12-14 03:28:56 +00:00

57 lines
2.1 KiB
Python

import os
import logging
from dotenv import load_dotenv
from telegram import Update
from telegram.constants import ParseMode
from telegram.ext import Application, Defaults, CommandHandler, ContextTypes
# --- IMPORTAR HABILIDADES ---
from modules.onboarding import onboarding_handler
from modules.printer import print_handler
from modules.rh_requests import vacaciones_handler, permiso_handler
from modules.database import log_request
# from modules.finder import finder_handler (Si lo creas después)
load_dotenv()
TOKEN = os.getenv("TELEGRAM_TOKEN")
logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO)
async def menu_principal(update: Update, context: ContextTypes.DEFAULT_TYPE):
"""Muestra el menú de opciones de Vanessa"""
user = update.effective_user
log_request(user.id, user.username, "start", update.message.text)
texto = (
"👩‍💼 **Hola, soy Vanessa. ¿En qué puedo ayudarte hoy?**\n\n"
"📝 `/welcome` - Iniciar onboarding/contrato\n"
"🖨️ `/print` - Imprimir o enviar archivo\n"
"🌴 `/vacaciones` - Solicitar días libres\n"
"⏱️ `/permiso` - Solicitar permiso por horas\n"
"🔍 `/socia_finder` - Buscar datos de una compañera\n\n"
"Selecciona un comando para empezar."
)
await update.message.reply_text(texto)
def main():
# Configuración Global
defaults = Defaults(parse_mode=ParseMode.MARKDOWN)
app = Application.builder().token(TOKEN).defaults(defaults).build()
# --- REGISTRO DE HABILIDADES ---
# 1. Comando de Ayuda / Menú
app.add_handler(CommandHandler("start", menu_principal))
app.add_handler(CommandHandler("help", menu_principal))
# 2. Habilidades Complejas (Conversaciones)
app.add_handler(onboarding_handler)
app.add_handler(print_handler)
app.add_handler(vacaciones_handler)
app.add_handler(permiso_handler)
# app.add_handler(finder_handler)
print("🧠 Vanessa Bot Brain iniciada y lista para trabajar en todos los módulos.")
app.run_polling()
if __name__ == "__main__":
main()