Added RFE #859119, configurable karma response.

This commit is contained in:
Jeremy Fincher 2003-12-16 13:06:21 +00:00
parent 54102ae5f7
commit 2ba68353dd
2 changed files with 14 additions and 1 deletions

View File

@ -39,6 +39,7 @@ import os
import sets
from itertools import imap
import conf
import utils
import plugins
import privmsgs
@ -67,7 +68,10 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
[('simple-output', configurable.BoolType, False,
"""Determines whether the bot will output shorter versions of the
karma output when requesting a single thing's karma. (example: 'foo:
1')""")]
1')"""),
('karma-response', configurable.BoolType, False,
"""Determines whether the bot will reply with a success message when
something's karma is increased or decreased."""),]
)
def __init__(self):
callbacks.PrivmsgCommandAndRegexp.__init__(self)
@ -219,6 +223,8 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
cursor.execute("""UPDATE karma
SET added=added+1
WHERE normalized=%s""", normalized)
if self.configurables.get('karma-response', msg.args[0]):
irc.reply(msg, conf.replySuccess)
def decreaseKarma(self, irc, msg, match):
r"^(\S+)--(|\s+)$"
@ -231,6 +237,8 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
cursor.execute("""UPDATE karma
SET subtracted=subtracted+1
WHERE normalized=%s""", normalized)
if self.configurables.get('karma-response', msg.args[0]):
irc.reply(msg, conf.replySuccess)
Class = Karma

View File

@ -95,6 +95,11 @@ if sqlite is not None:
self.assertResponse('karma foo', 'foo: 1')
self.assertNoResponse('bar--', 2)
self.assertResponse('karma bar', 'bar: -1')
def testKarmaOutputConfigurable(self):
self.assertNoResponse('foo++', 2)
self.assertNotError('karma config karma-response on')
self.assertNotError('foo++')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: