From 46b51034bf00a05474c3e41951f5c85aeb76aab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Consultor=C3=ADa=20AS?= Date: Tue, 3 Feb 2026 23:11:21 +0000 Subject: [PATCH] feat: Send Threads posts to Telegram for easy copy-paste When generating manual Threads posts, now sends each post directly to Telegram with: - Content wrapped in backticks (easy to copy) - Quality score and category info - Direct link to open Threads - Character count This enables a workflow where posts are generated automatically and the user just needs to copy from Telegram and paste in Threads. Co-Authored-By: Claude Opus 4.5 --- worker/tasks/generate_content.py | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/worker/tasks/generate_content.py b/worker/tasks/generate_content.py index 7a05cfa..fb23b61 100644 --- a/worker/tasks/generate_content.py +++ b/worker/tasks/generate_content.py @@ -554,12 +554,15 @@ def generate_threads_manual_posts(count: int = 2): """ Generar posts para Threads que se publicarán manualmente. - Genera tips de tecnología variados optimizados para Threads - y los guarda con status 'draft' para copiar y publicar manualmente. + Genera tips de tecnología variados optimizados para Threads, + los guarda con status 'draft' y envía notificación a Telegram + con el contenido listo para copiar. Args: count: Número de posts a generar (default 2) """ + from app.services.notifications import telegram_notify + db = SessionLocal() try: @@ -606,16 +609,35 @@ def generate_threads_manual_posts(count: int = 2): ) db.add(post) - created.append(category) + db.flush() # Para obtener el ID + created.append({"category": category, "post_id": post.id, "content": content}) + + # Enviar notificación a Telegram con el contenido + quality_score = result.get("quality_score", "N/A") + telegram_message = ( + f"🧵 *Nuevo post para Threads*\n" + f"📂 Categoría: {category}\n" + f"⭐ Calidad: {quality_score}/100\n\n" + f"━━━━━━━━━━━━━━━━━━━━━\n" + f"📋 *COPIAR Y PUBLICAR:*\n" + f"━━━━━━━━━━━━━━━━━━━━━\n\n" + f"`{content}`\n\n" + f"━━━━━━━━━━━━━━━━━━━━━\n" + f"🔗 [Abrir Threads](https://threads.net)\n" + f"📱 Post #{post.id} | {len(content)} caracteres" + ) + + run_async(telegram_notify(telegram_message, parse_mode="Markdown")) db.commit() - logger.info(f"Generados {len(created)} posts para Threads (manual): categorías={created}") + logger.info(f"Generados {len(created)} posts para Threads (manual): categorías={[c['category'] for c in created]}") return { "status": "success", "generated": len(created), - "categories": created + "categories": [c["category"] for c in created], + "post_ids": [c["post_id"] for c in created] } except Exception as e: