mirror of
https://github.com/marcogll/telegram_new_socias.git
synced 2026-01-13 13:15:16 +00:00
feat: add .gitignore with common patterns for Python projects, virtual environments, logs, and editor configurations.
This commit is contained in:
61
.gitignore
vendored
Normal file
61
.gitignore
vendored
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# =========================
|
||||||
|
# Secrets & Environment
|
||||||
|
# =========================
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
*.env
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# Python
|
||||||
|
# =========================
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*.pyo
|
||||||
|
*.pyd
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
venv/
|
||||||
|
.venv/
|
||||||
|
env/
|
||||||
|
ENV/
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# Logs & Runtime
|
||||||
|
# =========================
|
||||||
|
*.log
|
||||||
|
logs/
|
||||||
|
*.sqlite
|
||||||
|
*.db
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# OS & Editors
|
||||||
|
# =========================
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# VS Code
|
||||||
|
.vscode/
|
||||||
|
*.code-workspace
|
||||||
|
|
||||||
|
# JetBrains
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# Build / Distribution
|
||||||
|
# =========================
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
*.egg-info/
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# Systemd / Deploy Artifacts
|
||||||
|
# =========================
|
||||||
|
*.service
|
||||||
|
*.pid
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# Temp / Downloads
|
||||||
|
# =========================
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
|
downloads/
|
||||||
@@ -341,3 +341,10 @@ def main():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
# ... todo el código del contrato ...
|
||||||
|
# Al final:
|
||||||
|
onboarding_handler = ConversationHandler(
|
||||||
|
entry_points=[CommandHandler("welcome", start)], # Cambiado a /welcome
|
||||||
|
states=states, # Tu diccionario de estados
|
||||||
|
fallbacks=[CommandHandler("cancelar", cancelar)]
|
||||||
|
)
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import os
|
||||||
|
import requests
|
||||||
|
from telegram import Update
|
||||||
|
from telegram.ext import ContextTypes, ConversationHandler, CommandHandler, MessageHandler, filters
|
||||||
|
|
||||||
|
# Estado
|
||||||
|
ESPERANDO_ARCHIVO = 1
|
||||||
|
|
||||||
|
async def start_print(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
|
||||||
|
await update.message.reply_text("🖨️ **Servicio de Impresión**\n\nPor favor, envíame el archivo (PDF, DOCX o Imagen) que deseas imprimir/enviar.")
|
||||||
|
return ESPERANDO_ARCHIVO
|
||||||
|
|
||||||
|
async def recibir_archivo(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
|
||||||
|
user = update.effective_user
|
||||||
|
archivo = update.message.document or update.message.photo[-1] # Toma documento o la foto más grande
|
||||||
|
|
||||||
|
file_id = archivo.file_id
|
||||||
|
file_name = getattr(archivo, 'file_name', f"foto_{file_id}.jpg")
|
||||||
|
|
||||||
|
# Obtenemos el link de descarga directo de Telegram
|
||||||
|
file_info = await context.bot.get_file(file_id)
|
||||||
|
file_url = file_info.file_path
|
||||||
|
|
||||||
|
# Enviamos a n8n
|
||||||
|
webhook = os.getenv("WEBHOOK_PRINT")
|
||||||
|
payload = {
|
||||||
|
"user": user.full_name,
|
||||||
|
"email_user": f"{user.username}@telegram.org", # O pedir el mail antes
|
||||||
|
"file_url": file_url,
|
||||||
|
"file_name": file_name,
|
||||||
|
"tipo": "impresion"
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
requests.post(webhook, json=payload)
|
||||||
|
await update.message.reply_text(f"✅ Archivo *{file_name}* enviado a cola de impresión.")
|
||||||
|
except:
|
||||||
|
await update.message.reply_text("❌ Error al conectar con el servidor de impresión.")
|
||||||
|
|
||||||
|
return ConversationHandler.END
|
||||||
|
|
||||||
|
async def cancelar(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int:
|
||||||
|
await update.message.reply_text("Operación cancelada.")
|
||||||
|
return ConversationHandler.END
|
||||||
|
|
||||||
|
# Exportamos el handler
|
||||||
|
print_handler = ConversationHandler(
|
||||||
|
entry_points=[CommandHandler("print", start_print)],
|
||||||
|
states={ESPERANDO_ARCHIVO: [MessageHandler(filters.Document.ALL | filters.PHOTO, recibir_archivo)]},
|
||||||
|
fallbacks=[CommandHandler("cancelar", cancelar)]
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user