Hotfix for ZIP code lookup issue
This commit is contained in:
parent
d3d57d7e0a
commit
c949228aae
2 changed files with 19 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
|||
maubot: 0.1.0
|
||||
id: org.fiftyfiftyonearizona.reports.producerstopicenet
|
||||
version: 1.2.0
|
||||
version: 1.2.1
|
||||
license: MIT
|
||||
modules:
|
||||
- producerstopicenet
|
||||
|
|
|
@ -48,6 +48,9 @@ class Config(BaseProxyConfig):
|
|||
helper.copy("sendto")
|
||||
|
||||
class ProducerStopIceNet(Plugin):
|
||||
http: aiohttp.ClientSession
|
||||
poll_task: asyncio.Future
|
||||
|
||||
# Runs on start to ceate polling "thread"
|
||||
async def start(self) -> None:
|
||||
await super().start()
|
||||
|
@ -66,10 +69,16 @@ class ProducerStopIceNet(Plugin):
|
|||
return upgrade_table
|
||||
|
||||
async def poll_loop(self):
|
||||
await asyncio.sleep(10) # Delay to avoid consumers from missing messages
|
||||
self.log.debug("Started poll loop after startup delay")
|
||||
while True:
|
||||
try:
|
||||
await self.poll()
|
||||
# Sleep for n seconds
|
||||
await asyncio.sleep(self.config["refresh_delay"])
|
||||
except Exception as error:
|
||||
self.log.fatal( f"An error occurred: {error}")
|
||||
await asyncio.sleep(120) # For posterity
|
||||
|
||||
def get_send_rooms(self, region_name):
|
||||
room_ids = set()
|
||||
|
@ -108,7 +117,10 @@ class ProducerStopIceNet(Plugin):
|
|||
# Get page
|
||||
alert_url = "https://stopice.net/login/?alert=" + alert_id
|
||||
alert_id = alert_url.split('=')[-1]
|
||||
try:
|
||||
alert_page = await self.http.get(alert_url)
|
||||
except:
|
||||
continue
|
||||
alert_soup = BeautifulSoup(await alert_page.text(), 'html.parser')
|
||||
|
||||
# Get the address and body text strings
|
||||
|
@ -126,14 +138,13 @@ class ProducerStopIceNet(Plugin):
|
|||
zip_code = regex.findall(pattern_zip_code, alert_address)
|
||||
if len(zip_code) >= 1: zip_code = zip_code[-1]
|
||||
else: zip_code = None
|
||||
self.log.debug(zip_code)
|
||||
|
||||
# Get state code from zip if not extracted otherwise
|
||||
if region_code is None:
|
||||
if zip_code is not None: region_code = zip_to_region_map[int(zip_code)/100]
|
||||
if zip_code is not None: region_code = zip_to_region_code_map[int(zip_code)//100]
|
||||
|
||||
if region_code is None:
|
||||
self.log.debug(alert_id + "doesn't have a detectible region!")
|
||||
self.log.debug(f"{alert_id}doesn't have a detectible region!")
|
||||
continue
|
||||
|
||||
# Get state name from state code
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue