02-ago: [proyecto] vigilancia - integra middleware Alexa (alexa_notify.js/VoiceMonkey) + .env con credenciales de Telegram y VoiceMonkey + tests 18/18
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import requests
|
||||
|
||||
import config
|
||||
@@ -24,6 +27,23 @@ def enviar_telegram(ruta_imagen: str, texto: str):
|
||||
|
||||
|
||||
def disparar_webhook_alexa(texto: str):
|
||||
if config.ALEXA_NOTIFY_SCRIPT:
|
||||
env = os.environ.copy()
|
||||
if config.VOICEMONKEY_TOKEN:
|
||||
env["VOICEMONKEY_TOKEN"] = config.VOICEMONKEY_TOKEN
|
||||
if config.VOICEMONKEY_DEVICE:
|
||||
env["VOICEMONKEY_DEVICE"] = config.VOICEMONKEY_DEVICE
|
||||
try:
|
||||
r = subprocess.run(
|
||||
[config.ALEXA_NODE, config.ALEXA_NOTIFY_SCRIPT, texto],
|
||||
env=env, timeout=15, capture_output=True, text=True,
|
||||
)
|
||||
if r.returncode != 0:
|
||||
print(f"[Alexa] Error middleware: {r.stderr[:200]}")
|
||||
except Exception as e:
|
||||
print(f"[Alexa] Excepción lanzando middleware: {e}")
|
||||
return
|
||||
|
||||
if not config.WEBHOOK_ALEXA:
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user