소스 검색

Better ignore list support.

pull/15/head
Ben Kurtovic 11 년 전
부모
커밋
332eb088a0
3개의 변경된 파일25개의 추가작업 그리고 9개의 파일을 삭제
  1. +12
    -3
      commands/afc_status.py
  2. +9
    -2
      commands/afc_submissions.py
  3. +4
    -4
      tasks/afc_statistics.py

+ 12
- 3
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


+ 9
- 2
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))

+ 4
- 4
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)


불러오는 중...
취소
저장