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