Bläddra i källkod

!editcount/!ec and fix

tags/v0.1^2
Ben Kurtovic 13 år sedan
förälder
incheckning
9125a610ea
2 ändrade filer med 35 tillägg och 1 borttagningar
  1. +34
    -0
      bot/commands/editcount.py
  2. +1
    -1
      bot/wiki/page.py

+ 34
- 0
bot/commands/editcount.py Visa fil

@@ -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 Visa fil

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

Laddar…
Avbryt
Spara