From e8b078d4d06309409590db8b596069eb4a8241da Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 5 Jul 2012 04:28:36 -0400 Subject: [PATCH] More bugfixes and cleanup. --- earwigbot/commands/afc_report.py | 2 +- earwigbot/commands/crypt.py | 8 ++++---- earwigbot/commands/help.py | 2 +- earwigbot/wiki/site.py | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/earwigbot/commands/afc_report.py b/earwigbot/commands/afc_report.py index c4ecf79..803f1e4 100644 --- a/earwigbot/commands/afc_report.py +++ b/earwigbot/commands/afc_report.py @@ -79,7 +79,7 @@ class AFCReport(Command): url = page.url.replace("en.wikipedia.org/wiki", "enwp.org") short = self.statistics.get_short_title(page.title) status = self.get_status(page) - user = self.site.get_user(page.creator()) + user = self.site.get_user(page.get_creator()) user_name = user.name user_url = user.get_talkpage().url diff --git a/earwigbot/commands/crypt.py b/earwigbot/commands/crypt.py index cd64787..ff0c07a 100644 --- a/earwigbot/commands/crypt.py +++ b/earwigbot/commands/crypt.py @@ -30,7 +30,7 @@ __all__ = ["Crypt"] class Crypt(Command): """Provides hash functions with !hash (!hash list for supported algorithms) - and blowfish encryption with !encrypt and !decrypt.""" + and Blowfish encryption with !encrypt and !decrypt.""" name = "crypt" commands = ["crypt", "hash", "encrypt", "decrypt"] @@ -68,11 +68,11 @@ class Crypt(Command): self.reply(data, msg.format(data.command)) return - cipher = Blowfish.new(hashlib.sha256(key)) + cipher = Blowfish.new(hashlib.sha256(key).digest()) try: if data.command == "encrypt": - self.reply(data, cipher.encrypt(text)) + self.reply(data, cipher.encrypt(text).encode("hex")) else: - self.reply(data, cipher.decrypt(text)) + self.reply(data, cipher.decrypt(text.decode("hex"))) except ValueError as error: self.reply(data, error.message) diff --git a/earwigbot/commands/help.py b/earwigbot/commands/help.py index 463b910..80b92a0 100644 --- a/earwigbot/commands/help.py +++ b/earwigbot/commands/help.py @@ -62,7 +62,7 @@ class Help(Command): if command.__doc__: doc = command.__doc__.replace("\n", "") doc = re.sub("\s\s+", " ", doc) - msg = "help for command \x0303{0}\x0301: \"{1}\"" + msg = 'help for command \x0303{0}\x0301: "{1}"' self.reply(data, msg.format(target, doc)) return diff --git a/earwigbot/wiki/site.py b/earwigbot/wiki/site.py index b6e4c4a..2f9bc2b 100644 --- a/earwigbot/wiki/site.py +++ b/earwigbot/wiki/site.py @@ -734,7 +734,8 @@ class Site(object): :py:class:`~earwigbot.wiki.user.User` object representing the currently logged-in (or anonymous!) user is returned. """ - username = self._unicodeify(username) - if not username: + if username: + username = self._unicodeify(username) + else: username = self._get_username() return User(self, username)