41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""SMS notification provider stubs."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
import os
|
|
|
|
from notifications.base import LoggingNotificationService, NotificationService
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class SmsNotificationService(LoggingNotificationService):
|
|
"""
|
|
SMS notification service.
|
|
|
|
Currently logs messages. Future providers (Twilio, Urmi, etc.) can be
|
|
plugged in without changing the monitoring engine.
|
|
"""
|
|
|
|
def __init__(self) -> None:
|
|
self.provider = os.environ.get("SMS_PROVIDER", "logging")
|
|
self.api_key = os.environ.get("SMS_API_KEY", "")
|
|
self.from_number = os.environ.get("SMS_FROM_NUMBER", "")
|
|
self.to_number = os.environ.get("SMS_TO_NUMBER", "")
|
|
|
|
def send_sms(self, message: str) -> bool:
|
|
if self.provider == "logging" or not self.api_key:
|
|
return super().send_sms(message)
|
|
|
|
# Placeholder for future provider integration
|
|
logger.warning(
|
|
"SMS provider '%s' is not yet implemented; logging instead",
|
|
self.provider,
|
|
)
|
|
return super().send_sms(message)
|
|
|
|
|
|
def create_sms_service() -> NotificationService:
|
|
"""Factory for SMS-capable notification service."""
|
|
return SmsNotificationService()
|