diff --git a/commands/afc_status.py b/commands/afc_status.py index c4f0f6b..dcb9d82 100644 --- a/commands/afc_status.py +++ b/commands/afc_status.py @@ -31,6 +31,16 @@ class AFCStatus(Command): commands = ["status", "count", "num", "number"] hooks = ["join", "msg"] + def setup(self): + try: + self.ignore_list = self.config.commands[self.name]["ignoreList"] + except KeyError: + try: + ignores = self.config.tasks["afc_statistics"]["ignoreList"] + self.ignore_list = ignores + except KeyError: + self.ignore_list = [] + def check(self, data): if data.is_command and data.command in self.commands: return True @@ -134,9 +144,8 @@ class AFCStatus(Command): def count_submissions(self): """Returns the number of open AFC submissions (count of CAT:PEND).""" - # Subtract two for [[Wikipedia:Articles for creation/Redirects]] and - # [[Wikipedia:Files for upload]], which aren't real submissions: - return self.site.get_category("Pending AfC submissions").pages - 2 + minus = len(ignore_list) + return self.site.get_category("Pending AfC submissions").pages - minus def count_redirects(self): """Returns the number of open redirect submissions. Calculated as the diff --git a/commands/afc_submissions.py b/commands/afc_submissions.py index 41632de..978cf65 100644 --- a/commands/afc_submissions.py +++ b/commands/afc_submissions.py @@ -20,6 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +from earwigbot import wiki from earwigbot.commands import Command class AFCSubmissions(Command): @@ -53,7 +54,13 @@ class AFCSubmissions(Command): site = self.bot.wiki.get_site() category = site.get_category("Pending AfC submissions") - members = category.get_members(limit=number + len(self.ignore_list)) - urls = [member.url.encode("utf8") for member in members if member.title not in self.ignore_list] + members = category.get_members(limit=50) + urls = [] + for member in members: + if member.title in self.ignore_list: + continue + if member.namespace == wiki.NS_CATEGORY: + continue + urls.append(member.url.encode("utf8")) pages = ", ".join(urls[:number]) self.reply(data, "{0} pending AfC subs: {1}".format(number, pages)) diff --git a/tasks/afc_statistics.py b/tasks/afc_statistics.py index cf3e120..216319a 100644 --- a/tasks/afc_statistics.py +++ b/tasks/afc_statistics.py @@ -280,10 +280,10 @@ class AFCStatistics(Task): for pageid, title, ns in cursor: title = title.decode("utf8").replace("_", " ") - ns = self.site.namespace_id_to_name(ns) - if ns: - title = u":".join((ns, title)) - if title in self.ignore_list: + ns_name = self.site.namespace_id_to_name(ns) + if ns_name: + title = u":".join((ns_name, title)) + if title in self.ignore_list or ns == wiki.NS_CATEGORY: continue msg = u"Tracking page [[{0}]] (id: {1})".format(title, pageid) self.logger.debug(msg)