03-sep: [videoclub] Fix formateo para Telegram (troceado en mensajes + formatear_novedades)
This commit is contained in:
@@ -362,38 +362,13 @@ def procesar_novedades(chat_id):
|
||||
enviar("🎬 Consultando ultimas novedades...", chat_id)
|
||||
try:
|
||||
items = vcb.generar_novedades()
|
||||
mensajes = vcb.formatear_novedades(items)
|
||||
except Exception as e:
|
||||
log(f"novedades error: {e}")
|
||||
enviar(f"❌ Error consultando el catálogo: {e}", chat_id)
|
||||
return
|
||||
if not items:
|
||||
enviar("No hay novedades recientes.", chat_id)
|
||||
return
|
||||
lineas = [f"🎬 <b>Ultimas novedades ({len(items)}):</b>", ""]
|
||||
for i, it in enumerate(items, 1):
|
||||
y = f" ({it['year']})" if it["year"] else ""
|
||||
tipo = "📺" if it["tipo"] == "serie" else "🎬"
|
||||
idioma = "cast." if it.get("castellano") else ""
|
||||
enlace = it.get("enlace") or ""
|
||||
lineas.append(f"{tipo} <b>{i}.</b> {it['clean']}{y} {idioma}")
|
||||
if enlace:
|
||||
lineas.append(f" <code>descargar {enlace}</code>")
|
||||
texto = "\n".join(lineas)
|
||||
# Trocear si es muy largo
|
||||
CHUNK = 3500
|
||||
partes = []
|
||||
actual = []
|
||||
long = 0
|
||||
for linea in lineas:
|
||||
if actual and long + len(linea) + 1 > CHUNK:
|
||||
partes.append("\n".join(actual))
|
||||
actual, long = [], 0
|
||||
actual.append(linea)
|
||||
long += len(linea) + 1
|
||||
if actual:
|
||||
partes.append("\n".join(actual))
|
||||
for parte in partes:
|
||||
enviar(parte, chat_id)
|
||||
for m in mensajes:
|
||||
enviar(m, chat_id)
|
||||
|
||||
|
||||
def monitor_temperatura():
|
||||
|
||||
Reference in New Issue
Block a user