浏览代码

!editcount/!ec and fix

tags/v0.1^2
Ben Kurtovic 13 年前
父节点
当前提交
9125a610ea
共有 2 个文件被更改,包括 35 次插入1 次删除
  1. +34
    -0
      bot/commands/editcount.py
  2. +1
    -1
      bot/wiki/page.py

+ 34
- 0
bot/commands/editcount.py 查看文件

@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

from classes import BaseCommand
import wiki

class Command(BaseCommand):
"""Return a user's edit count."""
name = "editcount"

def check(self, data):
commands = ["ec", "editcount"]
if data.is_command and data.command in commands:
return True
return False

def process(self, data):
if not data.args:
self.connection.reply(data, "who do you want me to look up?")
return

username = ' '.join(data.args)
site = wiki.get_site()
site._maxlag = None
user = site.get_user(username)

try:
count = user.editcount()
except wiki.UserNotFoundError:
msg = "the user \x0302{0}\x0301 does not exist."
self.connection.reply(data, msg.format(username))
return

msg = "\x0302{0}\x0301 has {1} edits."
self.connection.reply(data, msg.format(username, count))

+ 1
- 1
bot/wiki/page.py 查看文件

@@ -514,4 +514,4 @@ class Page(object):
def add_section(self, text, title, minor=False, bot=True):
"""
"""
pass
pass

正在加载...
取消
保存