mirror of
https://github.com/marcogll/telegram_new_socias.git
synced 2026-01-13 13:15:16 +00:00
feat: Configure environment variables, refactor onboarding conversation states, and expose database port in Docker Compose.
This commit is contained in:
25
.env
25
.env
@@ -1,6 +1,27 @@
|
||||
# Configuración de Telegram
|
||||
TELEGRAM_TOKEN=TU_TOKEN_NUEVO_AQUI
|
||||
TELEGRAM_TOKEN=8549319557:AAFI6hOU_EC30sKPfRVSlKylxN7SeDvjzhg
|
||||
|
||||
# Webhooks de n8n (puedes agregar más aquí en el futuro)
|
||||
WEBHOOK_CONTRATO=https://flows.soul23.cloud/webhook/DuXh9Oi7SCAMf9
|
||||
# WEBHOOK_VACACIONES=https://... (futuro)
|
||||
WEBHOOK_PRINT=
|
||||
WEBHOOK_VACACIONES=
|
||||
|
||||
# --- DATABASE ---
|
||||
# Usado por el servicio de la base de datos en docker-compose.yml
|
||||
MYSQL_DATABASE=vanessa_logs
|
||||
MYSQL_USER=marcogll
|
||||
MYSQL_PASSWORD=#yamakasi111#
|
||||
MYSQL_ROOT_PASSWORD=#knoxville369#
|
||||
|
||||
# --- SMTP ---
|
||||
# Usado por el módulo de impresión para enviar correos
|
||||
SMTP_SERVER=smtp.hostinger.com
|
||||
SMTP_PORT=465
|
||||
SMTP_USER=print.service@vanityexperience.mx
|
||||
SMTP_PASSWORD=#Yamakasi111#
|
||||
SMTP_RECIPIENT=Print Service print.service@vanityexperience.mx
|
||||
IMAP_SERVER=imap.hostinger.com
|
||||
IMAP_PORT=993
|
||||
IMAP_USER=print.service@vanityexperience.mx
|
||||
IMAP_PASSWORD=#Yamakasi111#
|
||||
DATABASE_URL=mysql+mysqlconnector://marcogll:#yamakasi111#@localhost:3306/vanessa_logs
|
||||
|
||||
@@ -19,4 +19,8 @@ SMTP_SERVER=smtp.hostinger.com
|
||||
SMTP_PORT=465
|
||||
SMTP_USER=your_email@example.com
|
||||
SMTP_PASSWORD=your_password
|
||||
SMTP_RECIPIENT=your_email@example.com
|
||||
IMAP_SERVER=imap.hostinger.com
|
||||
IMAP_PORT=993
|
||||
IMAP_USER=your_email@example.com
|
||||
IMAP_PASSWORD=your_password
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version: '3.8'
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
bot:
|
||||
@@ -25,6 +25,8 @@ services:
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
ports:
|
||||
- "3306:3306"
|
||||
|
||||
volumes:
|
||||
mysql_data:
|
||||
|
||||
6
main.py
6
main.py
@@ -1,6 +1,10 @@
|
||||
import os
|
||||
import logging
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Cargar variables de entorno antes de importar módulos que las usan
|
||||
load_dotenv()
|
||||
|
||||
from telegram import Update
|
||||
from telegram.constants import ParseMode
|
||||
from telegram.ext import Application, Defaults, CommandHandler, ContextTypes
|
||||
@@ -12,7 +16,7 @@ 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)
|
||||
|
||||
@@ -325,12 +325,7 @@ def main():
|
||||
defaults = Defaults(parse_mode=ParseMode.MARKDOWN)
|
||||
application = Application.builder().token(TOKEN).defaults(defaults).build()
|
||||
|
||||
states = {}
|
||||
for i in range(34):
|
||||
callback = partial(manejar_flujo, estado_actual=i)
|
||||
states[i] = [MessageHandler(filters.TEXT & ~filters.COMMAND, callback)]
|
||||
|
||||
states[34] = [MessageHandler(filters.TEXT & ~filters.COMMAND, finalizar)]
|
||||
# states definition moved to global scope
|
||||
|
||||
conv_handler = ConversationHandler(
|
||||
entry_points=[CommandHandler("contrato", start)],
|
||||
@@ -345,6 +340,15 @@ def main():
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
# ... todo el código del contrato ...
|
||||
|
||||
# Definición de estados para el ConversationHandler
|
||||
states = {}
|
||||
for i in range(34):
|
||||
callback = partial(manejar_flujo, estado_actual=i)
|
||||
states[i] = [MessageHandler(filters.TEXT & ~filters.COMMAND, callback)]
|
||||
|
||||
states[34] = [MessageHandler(filters.TEXT & ~filters.COMMAND, finalizar)]
|
||||
|
||||
# Al final:
|
||||
onboarding_handler = ConversationHandler(
|
||||
entry_points=[CommandHandler("welcome", start)], # Cambiado a /welcome
|
||||
|
||||
Reference in New Issue
Block a user