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 <noreply@anthropic.com>
This commit is contained in:
@@ -554,12 +554,15 @@ def generate_threads_manual_posts(count: int = 2):
|
|||||||
"""
|
"""
|
||||||
Generar posts para Threads que se publicarán manualmente.
|
Generar posts para Threads que se publicarán manualmente.
|
||||||
|
|
||||||
Genera tips de tecnología variados optimizados para Threads
|
Genera tips de tecnología variados optimizados para Threads,
|
||||||
y los guarda con status 'draft' para copiar y publicar manualmente.
|
los guarda con status 'draft' y envía notificación a Telegram
|
||||||
|
con el contenido listo para copiar.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
count: Número de posts a generar (default 2)
|
count: Número de posts a generar (default 2)
|
||||||
"""
|
"""
|
||||||
|
from app.services.notifications import telegram_notify
|
||||||
|
|
||||||
db = SessionLocal()
|
db = SessionLocal()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -606,16 +609,35 @@ def generate_threads_manual_posts(count: int = 2):
|
|||||||
)
|
)
|
||||||
|
|
||||||
db.add(post)
|
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()
|
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 {
|
return {
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"generated": len(created),
|
"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:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user