Putting ZIP code in front of message

This commit is contained in:
Ben 2025-06-28 13:53:57 -07:00
parent 94186bde4e
commit 25a7368798
Signed by: webmaster
GPG key ID: A5FCBAF34E6E8B50
2 changed files with 15 additions and 7 deletions

View file

@ -1,6 +1,6 @@
maubot: 0.1.0
id: org.fiftyfiftyonearizona.reports.producerstopicenet
version: 1.1.0
version: 1.1.1
license: MIT
modules:
- producerstopicenet

View file

@ -39651,18 +39651,26 @@ class ProducerStopIceNet(Plugin):
state_code = regex.findall(pattern_state_code, alert_address)
if len(state_code) >= 1: state_code = state_code[-1].upper()
else: state_code = None
if state_code is None:
# Get ZIP code
pattern_zip_code = r'\b[0-9]{5}\b'
pattern_zip_code = r'[0-9]{5}'
zip_code = regex.findall(pattern_zip_code, alert_address)
if len(zip_code) >= 1: zip_code = zip_code[-1]
else: zip_code = None
# Get state code from zip if not extracted otherwise
if state_code is None:
if zip_code is not None: state_code = zip_to_state_map[int(zip_code)]
# Get state name from state code
if state_code is None: continue
state_name = state_code_to_name_map[state_code.upper()]
# Only proceed if state name is specified
if state_name is not None and state_name.lower() in self.config["send_configs"]:
message = "!" + self.config["command_prefix"] + " " + state_name + " " + alert_body
message = "!" + self.config["command_prefix"] + " " + state_name + " "
message += (zip_code if zip_code is not None else "") + " "
message += alert_body
for room_id in self.config["send_configs"][state_name.lower()]:
await self.client.send_text(room_id, message)