02-ago: [proyecto] vigilancia - bot Telegram de la Pi (estado/temp/tv/alarma) + tv_api modo simple + deploy en Raspberry Pi minipc
This commit is contained in:
@@ -9,7 +9,7 @@ import sys
|
||||
sys.path.insert(0, sys_dir)
|
||||
|
||||
import config
|
||||
from voz import anuncio_en_teles
|
||||
from voz import anuncio_en_teles, anuncio_simple
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
@@ -19,9 +19,11 @@ class Handler(BaseHTTPRequestHandler):
|
||||
if not texto:
|
||||
self._resp(400, {"error": "falta parametro texto"})
|
||||
return
|
||||
threading.Thread(target=anuncio_en_teles, args=(texto,), daemon=True).start()
|
||||
print(f"[TV-API] Mensaje lanzado: {texto[:80]}")
|
||||
self._resp(200, {"ok": True, "mensaje": texto})
|
||||
simple = (q.get("simple") or ["0"])[0] == "1"
|
||||
fn = anuncio_simple if simple else anuncio_en_teles
|
||||
threading.Thread(target=fn, args=(texto,), daemon=True).start()
|
||||
print(f"[TV-API] Mensaje lanzado ({'simple' if simple else 'alarma'}): {texto[:80]}")
|
||||
self._resp(200, {"ok": True, "mensaje": texto, "modo": "simple" if simple else "alarma"})
|
||||
|
||||
def _resp(self, code, obj):
|
||||
body = json.dumps(obj).encode("utf-8")
|
||||
|
||||
Reference in New Issue
Block a user