From 4d8e8807b97bd5d83f5fc6c61651db84de74e0d2 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 4 Nov 2003 09:09:53 +0000 Subject: [PATCH] Fixed karma response in the case of absolutely no karma. --- plugins/Karma.py | 9 ++++++--- test/test_Karma.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/Karma.py b/plugins/Karma.py index 4cbc13f8c..dd0c4a385 100644 --- a/plugins/Karma.py +++ b/plugins/Karma.py @@ -131,9 +131,12 @@ class Karma(callbacks.PrivmsgCommandAndRegexp, plugins.ChannelDBHandler): ORDER BY added-subtracted ASC LIMIT 3""") lowest = ['%r (%s)' % (t[0], t[1]) for t in cursor.fetchall()] - s = 'Highest karma: %s. Lowest karma: %s.' % \ - (utils.commaAndify(highest), utils.commaAndify(lowest)) - irc.reply(msg, s) + if not (highest and lowest): + irc.error(msg, 'I have no karma for this channel.') + else: + s = 'Highest karma: %s. Lowest karma: %s.' % \ + (utils.commaAndify(highest), utils.commaAndify(lowest)) + irc.reply(msg, s) def increaseKarma(self, irc, msg, match): r"^(\S+)\+\+$" diff --git a/test/test_Karma.py b/test/test_Karma.py index 7e62d8d5d..7fa8231bc 100644 --- a/test/test_Karma.py +++ b/test/test_Karma.py @@ -42,6 +42,7 @@ if sqlite is not None: class KarmaTestCase(ChannelPluginTestCase, PluginDocumentation): plugins = ('Karma',) def testKarma(self): + self.assertError('karma') self.assertRegexp('karma foobar', 'no karma') try: conf.replyWhenNotCommand = True @@ -67,6 +68,5 @@ if sqlite is not None: '.*total.*1') - # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: