diff --git a/plugins/FunDB.py b/plugins/FunDB.py index f169edd6a..4dfbd64ed 100755 --- a/plugins/FunDB.py +++ b/plugins/FunDB.py @@ -405,13 +405,13 @@ class FunDB(callbacks.Privmsg): id = 0 if not nick: raise callbacks.ArgumentError - + if nick == irc.nick: + nick = msg.nick try: (nick, reason) = imap(' '.join, utils.itersplit('for'.__eq__, nick.split(), 1)) except ValueError: reason = '' - cursor = self.db.cursor() if id: cursor.execute("""SELECT id, lart FROM larts WHERE id=%s""", id) @@ -456,13 +456,11 @@ class FunDB(callbacks.Privmsg): id = 0 if not nick: raise callbacks.ArgumentError - try: (nick, reason) = imap(' '.join, utils.itersplit('for'.__eq__, nick.split(), 1)) except ValueError: reason = '' - cursor = self.db.cursor() if id: cursor.execute("""SELECT id, praise FROM praises WHERE id=%s""",id) @@ -474,7 +472,6 @@ class FunDB(callbacks.Privmsg): WHERE praise NOTNULL ORDER BY random() LIMIT 1""") - if cursor.rowcount == 0: irc.error(msg, 'There are currently no available praises.') else: @@ -524,6 +521,7 @@ class FunDB(callbacks.Privmsg): else: irc.reply(msg, 'That word has no anagrams that I know of.') + Class = FunDB diff --git a/test/test_FunDB.py b/test/test_FunDB.py index 0e4dc2fb1..f7b0459bf 100644 --- a/test/test_FunDB.py +++ b/test/test_FunDB.py @@ -69,6 +69,7 @@ if sqlite is not None: self.assertResponse('lart 2 jemfinch for being dumb', '\x01ACTION shoots jemfinch for being dumb ' '(#2)\x01') + self.assertNotRegexp('lart %s' % self.irc.nick, self.irc.nick) self.assertNotError('remove lart 1') self.assertRegexp('num lart', 'currently 1 lart') self.assertResponse('lart jemfinch',