06-sep: [menu] seccion Domotica (aspiradora+termo), tablets Ines+Carolina en parental, fin-accion limpia chat + vuelve a /menu
This commit is contained in:
@@ -69,9 +69,12 @@ def teclado_principal():
|
||||
[
|
||||
_btn("📺 TV", PREFIJO + "cat:tv"),
|
||||
_btn("👪 Control parental", PREFIJO + "cat:parental"),
|
||||
_btn("🛠️ Sistema", PREFIJO + "cat:sistema"),
|
||||
_btn("🏠 Domótica", PREFIJO + "cat:domotica"),
|
||||
],
|
||||
[
|
||||
_btn("🛠️ Sistema", PREFIJO + "cat:sistema"),
|
||||
_btn("📚 Ayuda (texto)", PREFIJO + "acc:ayuda"),
|
||||
],
|
||||
[_btn("📚 Ayuda (texto)", PREFIJO + "acc:ayuda")],
|
||||
])
|
||||
|
||||
|
||||
@@ -103,6 +106,20 @@ def teclado_nas():
|
||||
_btn("📥 Panel descargas", PREFIJO + "acc:descargas"),
|
||||
_btn("➕ Añadir enlace", PREFIJO + "txt:descargar"),
|
||||
],
|
||||
FILA_VOLVER,
|
||||
])
|
||||
|
||||
|
||||
def teclado_domotica():
|
||||
return _mk([
|
||||
[
|
||||
_btn("🤖 Aspiradora estado", PREFIJO + "acc:aspiradora:estado"),
|
||||
_btn("🧹 Aspirar", PREFIJO + "acc:aspiradora:start"),
|
||||
],
|
||||
[
|
||||
_btn("⏸️ Pausar", PREFIJO + "acc:aspiradora:pause"),
|
||||
_btn("🏠 A la base", PREFIJO + "acc:aspiradora:home"),
|
||||
],
|
||||
[
|
||||
_btn("🔌 Termo ON", PREFIJO + "acc:termo:on"),
|
||||
_btn("🔌 Termo OFF", PREFIJO + "acc:termo:off"),
|
||||
@@ -125,6 +142,10 @@ def teclado_tv():
|
||||
|
||||
def teclado_parental():
|
||||
return _mk([
|
||||
[
|
||||
_btn("🔒 Bloquear tablets", PREFIJO + "acc:tablets:bloquear"),
|
||||
_btn("🔓 Desbloquear tablets", PREFIJO + "acc:tablets:desbloquear"),
|
||||
],
|
||||
[_btn("📋 Listar estado", PREFIJO + "acc:parental_listar")],
|
||||
[
|
||||
_btn("🔒 Desactivar…", PREFIJO + "sub:desactivar"),
|
||||
@@ -261,6 +282,19 @@ def _disp(chat_id, message_id, comando):
|
||||
_cerrar_menu(chat_id, message_id)
|
||||
|
||||
|
||||
def _fin_accion(chat_id):
|
||||
"""Tras una accion: deja ver el resultado, limpia toda la pantalla
|
||||
y deja el mensaje para volver al menu."""
|
||||
import time as _time
|
||||
import pi_bot
|
||||
_time.sleep(4)
|
||||
try:
|
||||
pi_bot.limpiar_pantalla(chat_id)
|
||||
except Exception:
|
||||
pass
|
||||
_enviar_nuevo(chat_id, "✅ Hecho. Pulsa /menu para volver al menú.", None)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------- menu ----
|
||||
|
||||
def enviar_menu(chat_id):
|
||||
@@ -277,6 +311,7 @@ def _header(categoria):
|
||||
"nas": "📥 <b>NAS / Descargas</b>",
|
||||
"tv": "📺 <b>TV</b>",
|
||||
"parental": "👪 <b>Control parental</b>",
|
||||
"domotica": "🏠 <b>Domótica</b>",
|
||||
"sistema": "🛠️ <b>Sistema</b>",
|
||||
"router": "📡 <b>Router ASUS</b>",
|
||||
}
|
||||
@@ -289,6 +324,7 @@ def _abrir_categoria(chat_id, message_id, categoria):
|
||||
"nas": teclado_nas,
|
||||
"tv": teclado_tv,
|
||||
"parental": teclado_parental,
|
||||
"domotica": teclado_domotica,
|
||||
"sistema": teclado_sistema,
|
||||
"router": teclado_router,
|
||||
}
|
||||
@@ -432,6 +468,20 @@ def _ejecutar_accion(chat_id, message_id, partes):
|
||||
if accion == "termo":
|
||||
_disp(chat_id, message_id, f"termo {sub}")
|
||||
return
|
||||
if accion == "aspiradora":
|
||||
if sub in ("estado", "start", "stop", "home", "pause", "locate"):
|
||||
_disp(chat_id, message_id, f"aspiradora {sub}")
|
||||
if sub != "estado":
|
||||
_fin_accion(chat_id)
|
||||
return
|
||||
if accion == "tablets":
|
||||
if sub in ("bloquear", "desbloquear"):
|
||||
verbo = "desactivar" if sub == "bloquear" else "activar"
|
||||
pi_bot.procesar(f"parental {verbo} Inés", chat_id)
|
||||
pi_bot.procesar(f"parental {verbo} Carolina", chat_id)
|
||||
_cerrar_menu(chat_id, message_id)
|
||||
_fin_accion(chat_id)
|
||||
return
|
||||
if accion == "router":
|
||||
mapeo = {
|
||||
"estado": "router estado",
|
||||
|
||||
@@ -348,6 +348,20 @@ def _ejecutar_borrado(chat_id, numero):
|
||||
enviar(f"🗑️ Tarea borrada: <b>{titulo[:80]}</b>", chat_id)
|
||||
else:
|
||||
enviar(f"❌ No se pudo borrar <b>{titulo[:60]}</b>: {detalle}", chat_id)
|
||||
# Cierra el panel de descargas, limpia toda la pantalla y deja
|
||||
# el mensaje para volver al menu.
|
||||
try:
|
||||
estado_panel = panel_descargas.pop(chat_id, None)
|
||||
if estado_panel and estado_panel.get("message_id"):
|
||||
borrar(chat_id, estado_panel["message_id"])
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(4)
|
||||
try:
|
||||
limpiar_pantalla(chat_id)
|
||||
except Exception:
|
||||
pass
|
||||
enviar("✅ Hecho. Pulsa /menu para volver al menú.", chat_id)
|
||||
return True
|
||||
|
||||
|
||||
@@ -791,6 +805,9 @@ def procesar(texto, chat_id):
|
||||
" ✏️ Ej: <code>/descargar magnet:?xt=urn:btih:...</code>\n"
|
||||
"<b>10.</b> <code>termo on|off|estado</code> — controla el enchufe Tapo\n"
|
||||
" ✏️ Ej: <code>/termo estado</code>\n\n"
|
||||
"━━━ 🏠 DOMÓTICA ━━━\n"
|
||||
"<b>10b.</b> <code>aspiradora estado|start|stop|home|pause|locate</code> — Dreame D10 Plus\n"
|
||||
" ✏️ Ej: <code>/aspiradora estado</code>\n\n"
|
||||
"━━━ 📺 TV ━━━\n"
|
||||
"<b>11.</b> <code>tv <mensaje></code> — mensaje rápido a la tele\n"
|
||||
" ✏️ Ej: <code>/tv la cena está lista</code>\n"
|
||||
|
||||
Reference in New Issue
Block a user