Fixed karma response in the case of absolutely no karma.

This commit is contained in:
Jeremy Fincher 2003-11-04 09:09:53 +00:00
parent afa0cb8f41
commit 4d8e8807b9
2 changed files with 7 additions and 4 deletions

View File

@ -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+)\+\+$"

View File

@ -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: