From e189603220e30c80ac987ac753714d0a7b601a50 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 22 Oct 2003 03:40:00 +0000 Subject: [PATCH] Fixed multiple-karma responses in the face of no results. --- plugins/ChannelDB.py | 10 +++++++--- test/test_ChannelDB.py | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/ChannelDB.py b/plugins/ChannelDB.py index da55e96ca..d78527300 100644 --- a/plugins/ChannelDB.py +++ b/plugins/ChannelDB.py @@ -367,9 +367,13 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp): FROM karma WHERE %s ORDER BY added-subtracted DESC""" % criteria cursor.execute(sql, *args) - s = utils.commaAndify(['%s: %s' % (n, t) - for (n,t) in cursor.fetchall()]) - irc.reply(msg, s + '.') + if cursor.rowcount > 0: + s = utils.commaAndify(['%s: %s' % (n, t) + for (n,t) in cursor.fetchall()]) + irc.reply(msg, s + '.') + else: + irc.reply(msg, 'I didn\'t know the karma for any ' + 'of those things.') else: # No name was given. Return the top/bottom 3 karmas. cursor.execute("""SELECT name, added-subtracted FROM karma diff --git a/test/test_ChannelDB.py b/test/test_ChannelDB.py index 2c5fac51a..efa6eba5b 100644 --- a/test/test_ChannelDB.py +++ b/test/test_ChannelDB.py @@ -80,6 +80,9 @@ if sqlite is not None: self.assertRegexp('karma foobar', 'increased 1.*total.*1') self.assertNoResponse('foobar--', 2) self.assertRegexp('karma foobar', 'decreased 1.*total.*0') + self.assertNoResponse('foo++', 2) + self.assertNoResponse('bar--', 2) + self.assertRegexp('karma foo bar foobar', '.*foo.*foobar.*bar.*') # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: