diff --git a/CHANGELOG b/CHANGELOG index 5d3af6d..e2b82d2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,8 @@ v0.3 (unreleased): - Added various new features to the WikiProjectTagger task. -- Copyvio detector: improved sentence splitting algorithm. +- Copyvio detector: improved sentence splitting algorithm; many performance + improvements. - Improved config file command/task exclusion logic. - IRC > !cidr: Added; new command for calculating range blocks. - IRC > !notes: Improved help and added aliases. @@ -13,6 +14,8 @@ v0.3 (unreleased): - IRC: Try not to join channels before NickServ auth has completed. - IRC: Improved detection of maximum IRC message length. - IRC: Improved some help commands. +- Wiki: Added logging for warnings. +- Wiki: Updated some deprecated API calls. - Wiki: Fixed Page.toggle_talk() behavior on mainspace titles with colons. v0.2 (released November 8, 2015): diff --git a/earwigbot/wiki/page.py b/earwigbot/wiki/page.py index b05f9ff..302188f 100644 --- a/earwigbot/wiki/page.py +++ b/earwigbot/wiki/page.py @@ -264,13 +264,15 @@ class Page(CopyvioMixIn): if not result: query = self.site.api_query result = query(action="query", prop="revisions", rvlimit=1, - rvprop="content|timestamp", titles=self._title) + rvprop="content|timestamp", rvslots="main", + titles=self._title) res = result["query"]["pages"].values()[0] try: - self._content = res["revisions"][0]["*"] - self._basetimestamp = res["revisions"][0]["timestamp"] - except KeyError: + revision = res["revisions"][0] + self._content = revision["slots"]["main"]["*"] + self._basetimestamp = revision["timestamp"] + except (KeyError, IndexError): # This can only happen if the page was deleted since we last called # self._load_attributes(). In that case, some of our attributes are # outdated, so force another self._load_attributes(): @@ -582,7 +584,7 @@ class Page(CopyvioMixIn): query = self.site.api_query result = query(action="query", rvlimit=1, titles=self._title, prop="info|revisions", inprop="protection|url", - rvprop="content|timestamp") + rvprop="content|timestamp", rvslots="main") self._load_attributes(result=result) self._assert_existence() self._load_content(result=result) diff --git a/earwigbot/wiki/site.py b/earwigbot/wiki/site.py index 63c4fee..c93d940 100644 --- a/earwigbot/wiki/site.py +++ b/earwigbot/wiki/site.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2009-2017 Ben Kurtovic +# Copyright (C) 2009-2019 Ben Kurtovic # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -298,6 +298,17 @@ class Site(object): e = "API query failed: JSON could not be decoded." raise exceptions.APIError(e) + if "warnings" in res: + for name, value in res["warnings"].items(): + try: + warning = value["warnings"] + except KeyError: + try: + warning = value["*"] + except KeyError: + warning = value + self._logger.warning("API warning: %s: %s", name, warning) + try: code = res["error"]["code"] info = res["error"]["info"]