mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 15:44:06 +01:00
Added RFE #859119, configurable karma response.
This commit is contained in:
parent
54102ae5f7
commit
2ba68353dd
@ -39,6 +39,7 @@ import os
|
|||||||
import sets
|
import sets
|
||||||
from itertools import imap
|
from itertools import imap
|
||||||
|
|
||||||
|
import conf
|
||||||
import utils
|
import utils
|
||||||
import plugins
|
import plugins
|
||||||
import privmsgs
|
import privmsgs
|
||||||
@ -67,7 +68,10 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
|
|||||||
[('simple-output', configurable.BoolType, False,
|
[('simple-output', configurable.BoolType, False,
|
||||||
"""Determines whether the bot will output shorter versions of the
|
"""Determines whether the bot will output shorter versions of the
|
||||||
karma output when requesting a single thing's karma. (example: 'foo:
|
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):
|
def __init__(self):
|
||||||
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
||||||
@ -219,6 +223,8 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
|
|||||||
cursor.execute("""UPDATE karma
|
cursor.execute("""UPDATE karma
|
||||||
SET added=added+1
|
SET added=added+1
|
||||||
WHERE normalized=%s""", normalized)
|
WHERE normalized=%s""", normalized)
|
||||||
|
if self.configurables.get('karma-response', msg.args[0]):
|
||||||
|
irc.reply(msg, conf.replySuccess)
|
||||||
|
|
||||||
def decreaseKarma(self, irc, msg, match):
|
def decreaseKarma(self, irc, msg, match):
|
||||||
r"^(\S+)--(|\s+)$"
|
r"^(\S+)--(|\s+)$"
|
||||||
@ -231,6 +237,8 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
|
|||||||
cursor.execute("""UPDATE karma
|
cursor.execute("""UPDATE karma
|
||||||
SET subtracted=subtracted+1
|
SET subtracted=subtracted+1
|
||||||
WHERE normalized=%s""", normalized)
|
WHERE normalized=%s""", normalized)
|
||||||
|
if self.configurables.get('karma-response', msg.args[0]):
|
||||||
|
irc.reply(msg, conf.replySuccess)
|
||||||
|
|
||||||
|
|
||||||
Class = Karma
|
Class = Karma
|
||||||
|
@ -95,6 +95,11 @@ if sqlite is not None:
|
|||||||
self.assertResponse('karma foo', 'foo: 1')
|
self.assertResponse('karma foo', 'foo: 1')
|
||||||
self.assertNoResponse('bar--', 2)
|
self.assertNoResponse('bar--', 2)
|
||||||
self.assertResponse('karma bar', 'bar: -1')
|
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:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user