"""signal_alert.""" from __future__ import annotations import logging from os import getenv from apprise import Apprise logger = logging.getLogger(__name__) def signal_alert(body: str, title: str = "") -> None: """Send a signal alert. Args: body (str): The body of the alert. title (str, optional): The title of the alert. Defaults to "". """ apprise_client = Apprise() from_phone = getenv("SIGNAL_ALERT_FROM_PHONE") to_phone = getenv("SIGNAL_ALERT_TO_PHONE") if not from_phone or not to_phone: logger.info("SIGNAL_ALERT_FROM_PHONE or SIGNAL_ALERT_TO_PHONE not set") return apprise_client.add(f"signal://localhost:8989/{from_phone}/{to_phone}") apprise_client.notify(title=title, body=body)