Fixed multiple-karma responses in the face of no results.

This commit is contained in:
Jeremy Fincher 2003-10-22 03:40:00 +00:00
parent 8ebef1ec6e
commit e189603220
2 changed files with 10 additions and 3 deletions

View File

@ -367,9 +367,13 @@ class ChannelDB(plugins.ChannelDBHandler, callbacks.PrivmsgCommandAndRegexp):
FROM karma WHERE %s FROM karma WHERE %s
ORDER BY added-subtracted DESC""" % criteria ORDER BY added-subtracted DESC""" % criteria
cursor.execute(sql, *args) cursor.execute(sql, *args)
s = utils.commaAndify(['%s: %s' % (n, t) if cursor.rowcount > 0:
for (n,t) in cursor.fetchall()]) s = utils.commaAndify(['%s: %s' % (n, t)
irc.reply(msg, s + '.') 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. else: # No name was given. Return the top/bottom 3 karmas.
cursor.execute("""SELECT name, added-subtracted cursor.execute("""SELECT name, added-subtracted
FROM karma FROM karma

View File

@ -80,6 +80,9 @@ if sqlite is not None:
self.assertRegexp('karma foobar', 'increased 1.*total.*1') self.assertRegexp('karma foobar', 'increased 1.*total.*1')
self.assertNoResponse('foobar--', 2) self.assertNoResponse('foobar--', 2)
self.assertRegexp('karma foobar', 'decreased 1.*total.*0') 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: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: