MCPcopy
hub / github.com/caronc/apprise / __init__

Method __init__

apprise/plugins/httpsms.py:123–164  ·  view source on GitHub ↗

Initialize HttpSMS Object.

(self, apikey=None, source=None, targets=None, **kwargs)

Source from the content-addressed store, hash-verified

121 )
122
123 def __init__(self, apikey=None, source=None, targets=None, **kwargs):
124 """Initialize HttpSMS Object."""
125 super().__init__(**kwargs)
126
127 self.apikey = validate_regex(apikey)
128 if not self.apikey:
129 msg = f"An invalid API Key ({apikey}) was specified."
130 self.logger.warning(msg)
131 raise TypeError(msg)
132
133 result = is_phone_no(source)
134 if not result:
135 msg = (
136 f"The Account (From) Phone # specified ({source}) is invalid."
137 )
138 self.logger.warning(msg)
139 raise TypeError(msg)
140
141 # Tidy source
142 self.source = result["full"]
143
144 # Parse our targets
145 self.targets = []
146
147 has_error = False
148 for target in parse_phone_no(targets):
149 # Parse each phone number we found
150 result = is_phone_no(target)
151 if result:
152 self.targets.append(result["full"])
153 continue
154
155 has_error = True
156 self.logger.warning(
157 f"Dropped invalid phone # ({target}) specified.",
158 )
159
160 if not targets and not has_error:
161 # Default the SMS Message to ourselves
162 self.targets.append(self.source)
163
164 return
165
166 def send(self, body, title="", notify_type=NotifyType.INFO, **kwargs):
167 """Perform HttpSMS Notification."""

Callers

nothing calls this directly

Calls 3

validate_regexFunction · 0.85
is_phone_noFunction · 0.85
parse_phone_noFunction · 0.85

Tested by

no test coverage detected