diff --git a/maubot.yaml b/maubot.yaml index d6ecaba..6fe5d3e 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: org.fiftyfiftyonearizona.reports.producerstopicenet -version: 1.2.1 +version: 1.2.0 license: MIT modules: - producerstopicenet diff --git a/producerstopicenet.py b/producerstopicenet.py index 9e56d12..285b58b 100644 --- a/producerstopicenet.py +++ b/producerstopicenet.py @@ -48,9 +48,6 @@ 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() @@ -69,16 +66,10 @@ 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 + await self.poll() + # Sleep for n seconds + await asyncio.sleep(self.config["refresh_delay"]) def get_send_rooms(self, region_name): room_ids = set() @@ -117,10 +108,7 @@ 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_page = await self.http.get(alert_url) alert_soup = BeautifulSoup(await alert_page.text(), 'html.parser') # Get the address and body text strings @@ -138,13 +126,14 @@ 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_code_map[int(zip_code)//100] + if zip_code is not None: region_code = zip_to_region_map[int(zip_code)/100] if region_code is None: - self.log.debug(f"{alert_id}doesn't have a detectible region!") + self.log.debug(alert_id + "doesn't have a detectible region!") continue # Get state name from state code