Преглед изворни кода

some cleanup; use command issuer's IRC nick as username if none is provided

tags/v0.1^2
Ben Kurtovic пре 13 година
родитељ
комит
7c8353530a
2 измењених фајлова са 15 додато и 16 уклоњено
  1. +7
    -8
      bot/commands/editcount.py
  2. +8
    -8
      bot/commands/rights.py

+ 7
- 8
bot/commands/editcount.py Прегледај датотеку

@@ -17,23 +17,22 @@ class Command(BaseCommand):

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

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

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

safe = quote_plus(user.name())
url = "http://toolserver.org/~soxred93/pcount/index.php?name={0}&lang=en&wiki=wikipedia"
url = url.format(quote_plus(user.name()))

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

+ 8
- 8
bot/commands/rights.py Прегледај датотеку

@@ -4,7 +4,7 @@ from classes import BaseCommand
import wiki

class Command(BaseCommand):
"""Retrieve a list of rights for a given username."""
"""Retrieve a list of rights for a given name."""
name = "rights"

def check(self, data):
@@ -15,19 +15,19 @@ class Command(BaseCommand):

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

username = ' '.join(data.args)
site = wiki.get_site()
site._maxlag = None
user = site.get_user(username)
user = site.get_user(name)
try:
rights = user.groups()
except wiki.UserNotFoundError:
msg = "the user \x0302{0}\x0301 does not exist."
self.connection.reply(data, msg.format(username))
self.connection.reply(data, msg.format(name))
return

try:
@@ -35,4 +35,4 @@ class Command(BaseCommand):
except ValueError:
pass
msg = "the rights for \x0302{0}\x0301 are {1}."
self.connection.reply(data, msg.format(username, ', '.join(rights)))
self.connection.reply(data, msg.format(name, ', '.join(rights)))

Loading…
Откажи
Сачувај