From 2ba68353ddc03635b58169f70b94eef6d2a84528 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 16 Dec 2003 13:06:21 +0000 Subject: [PATCH] Added RFE #859119, configurable karma response. --- plugins/Karma.py | 10 +++++++++- test/test_Karma.py | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/Karma.py b/plugins/Karma.py index 765e26f74..c5e0e39f7 100644 --- a/plugins/Karma.py +++ b/plugins/Karma.py @@ -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 diff --git a/test/test_Karma.py b/test/test_Karma.py index b6c1c35db..56ac9c158 100644 --- a/test/test_Karma.py +++ b/test/test_Karma.py @@ -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: