From 11e2c68b5f233577233c15aebcbe92d4ddbb7097 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Wed, 2 Jul 2014 01:44:38 -0400 Subject: [PATCH] Fixes for new Draft: namespace. --- commands/afc_report.py | 36 +++++++++++------------------------- tasks/afc_undated.py | 4 +++- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/commands/afc_report.py b/commands/afc_report.py index fa0f264..f56b228 100644 --- a/commands/afc_report.py +++ b/commands/afc_report.py @@ -45,34 +45,20 @@ class AFCReport(Command): self.reply(data, msg) return - title = " ".join(data.args) - title = title.replace("http://en.wikipedia.org/wiki/", "") - title = title.replace("http://enwp.org/", "").strip() - - # Given '!report Foo', first try [[Foo]]: - page = self.get_page(title) - if page: - return self.report(page) - - # Then try [[Wikipedia:Articles for creation/Foo]]: - newtitle = "/".join(("Wikipedia:Articles for creation", title)) - page = self.get_page(newtitle) - if page: - return self.report(page) - - # Then try [[Wikipedia talk:Articles for creation/Foo]]: - newtitle = "/".join(("Wikipedia talk:Articles for creation", title)) - page = self.get_page(newtitle) - if page: - return self.report(page) + title = " ".join(data.args).replace("http://en.wikipedia.org/wiki/", + "").replace("http://enwp.org/", "").strip() + titles = [ + title, "Draft:" + title, + "Wikipedia:Articles for creation/" + title, + "Wikipedia talk:Articles for creation/" + title + ] + for attempt in titles: + page = self.site.get_page(attempt, follow_redirects=False) + if page.exists == page.PAGE_EXISTS: + return self.report(page) self.reply(data, "Submission \x0302{0}\x0F not found.".format(title)) - def get_page(self, title): - page = self.site.get_page(title, follow_redirects=False) - if page.exists == page.PAGE_EXISTS: - return page - def report(self, page): url = page.url.encode("utf8") url = url.replace("en.wikipedia.org/wiki", "enwp.org") diff --git a/tasks/afc_undated.py b/tasks/afc_undated.py index 7957783..44de948 100644 --- a/tasks/afc_undated.py +++ b/tasks/afc_undated.py @@ -27,6 +27,8 @@ import mwparserfromhell from earwigbot.tasks import Task from earwigbot.wiki.constants import * +NS_DRAFT = 118 + class AFCUndated(Task): """A task to clear [[Category:Undated AfC submissions]].""" name = "afc_undated" @@ -38,7 +40,7 @@ class AFCUndated(Task): default_summary = "Adding timestamp to undated [[WP:AFC|Articles for creation]] submission." self.summary = self.make_summary(cfg.get("summary", default_summary)) self.namespaces = { - "submission": [NS_USER, NS_PROJECT, NS_PROJECT_TALK], + "submission": [NS_USER, NS_PROJECT, NS_PROJECT_TALK, NS_DRAFT], "talk": [NS_TALK, NS_FILE_TALK, NS_TEMPLATE_TALK, NS_HELP_TALK, NS_CATEGORY_TALK] }