Selaa lähdekoodia

Fixes for new Draft: namespace.

pull/15/head
Ben Kurtovic 10 vuotta sitten
vanhempi
commit
11e2c68b5f
2 muutettua tiedostoa jossa 14 lisäystä ja 26 poistoa
  1. +11
    -25
      commands/afc_report.py
  2. +3
    -1
      tasks/afc_undated.py

+ 11
- 25
commands/afc_report.py Näytä tiedosto

@@ -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")


+ 3
- 1
tasks/afc_undated.py Näytä tiedosto

@@ -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]
}


Ladataan…
Peruuta
Tallenna