diff --git a/founderlessnotify/founderlessnotify.py b/founderlessnotify/founderlessnotify.py index b6acc82..5c1eb0a 100644 --- a/founderlessnotify/founderlessnotify.py +++ b/founderlessnotify/founderlessnotify.py @@ -18,18 +18,18 @@ def canonicalize(in_str): def get_founderless_regions(): """Return the list of founderless regions.""" + time.sleep(RATE_LIMIT) r = requests.get('https://www.nationstates.net/cgi-bin/api.cgi?q=regionsbytag;tags=founderless', headers=R_HEADERS) - time.sleep(RATE_LIMIT) tree = et.fromstring(r.text) return tree[0].text.split(',') def download_region_dump(): """Download the latest region dump from the NS API.""" + time.sleep(RATE_LIMIT) r = requests.get('https://www.nationstates.net/pages/regions.xml.gz', headers=R_HEADERS) - time.sleep(RATE_LIMIT) with open('regions.xml.gz', 'wb') as f: f.write(r.content) with gzip.open('regions.xml.gz', 'rb') as f_in: @@ -104,14 +104,12 @@ class FounderlessNotify(commands.Cog): # Get the region endos for both lists # now_foundered_endos = get_region_endos(now_foundered) now_founderless_endos = get_region_endos(now_founderless) - message_content = '' - await channel.send('The following regions are now **Founderless**:') + message_content = "The following regions are now **Founderless**:\n" for region in now_founderless: message_content += f"https://www.nationstates.net/region={canonicalize(region)} " \ - f"({now_founderless_endos[region]})" + f"({now_founderless_endos[region]})\n" for page in pagify(message_content): await channel.send(page) - await self.config.previous_founderless.set(new_founderless_regions) async def bg_loop(self):