06-sep: [videoclub] flujo unificado torrents/bajar en novedades+pelicula+serie, sin URLs, /limpiar borra todo el chat (IDD+OpenCode), parental CAROLINA con fallback MAC en vivo

This commit is contained in:
juanjo
2026-09-06 12:21:19 +02:00
parent c82737cb13
commit bdc6cf8f48
7 changed files with 591 additions and 26 deletions

View File

@@ -53,6 +53,7 @@ bloqueos = {} # chat_id -> True (procesando mensaje)
sesiones = {} # chat_id -> {'repo': slug, 'session': id, 'model': obj|None}
repos_cache = [] # lista de {'slug','dir'}
sentidos = {} # chat_id -> [message_id...] enviados por el bot (para /limpiar)
entrantes = {} # chat_id -> [message_id...] enviados por el usuario (para /limpiar)
menu_msg = {} # chat_id -> message_id del menu abierto
@@ -560,8 +561,10 @@ def cmd_salir(chat):
def cmd_limpiar(chat):
"""Borra los mensajes que el bot ha enviado en este chat."""
"""Borra TODO el chat visible: mensajes del bot y del usuario.
Limite de Telegram: solo mensajes de menos de 48h se pueden borrar."""
lista = sentidos.get(str(chat)) or []
lista += entrantes.get(str(chat)) or []
borrados = 0
for mid in reversed(lista):
try:
@@ -573,7 +576,8 @@ def cmd_limpiar(chat):
except Exception:
pass
sentidos[str(chat)] = []
enviar(chat, f"🧹 Pantalla limpia ({borrados} mensajes borrados).")
entrantes[str(chat)] = []
enviar(chat, f"🧹 Chat limpio ({borrados} mensajes borrados).")
# borra tambien este aviso al cabo de unos segundos
threading.Timer(6.0, _autolimpia, args=(chat,)).start()
@@ -887,6 +891,11 @@ def main():
log(f"Bloqueado chat {chat}")
continue
texto = msg.get("text")
if msg.get("message_id"):
lista = entrantes.setdefault(chat, [])
lista.append(msg["message_id"])
if len(lista) > 300:
entrantes[chat] = lista[-300:]
if texto:
threading.Thread(target=procesar, args=(texto, chat),
daemon=True).start()