From 75a865287fb10d0586866567ae8e002fda384751 Mon Sep 17 00:00:00 2001 From: Frisk Date: Tue, 8 Sep 2020 21:13:42 +0200 Subject: [PATCH] Moved error handling for one thing since I want to handle it separately --- src/bot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/bot.py b/src/bot.py index 1e48162..f5e76bf 100644 --- a/src/bot.py +++ b/src/bot.py @@ -227,8 +227,6 @@ async def scan_group(group: str): await local_wiki.fail_add(queued_wiki.url, 410) continue raise WikiError - recent_changes = recent_changes_resp['query']['recentchanges'] - recent_changes.reverse() except aiohttp.ContentTypeError: logger.exception("Wiki seems to be resulting in non-json content.") await local_wiki.fail_add(queued_wiki.url, 410) @@ -236,6 +234,12 @@ async def scan_group(group: str): except: logger.exception("On loading json of response.") continue + try: + recent_changes = recent_changes_resp['query']['recentchanges'] + recent_changes.reverse() + except KeyError: + logger.error("recent_changes_resp returned KeyError. skipping this check. (usually this happens when the wiki doesn't respond properly, it's pretty normal)") + continue if extended: await process_mwmsgs(recent_changes_resp, local_wiki, mw_msgs) if local_wiki.rc_active in (0, None, -1): # new wiki, just get the last rc to not spam the channel, -1 for -1 to NULL changes