Karma: make onlyNicks a config option

Conflicts:
	plugins/Karma/plugin.py
This commit is contained in:
James Lu 2015-01-14 21:26:50 -05:00
parent 4729213898
commit bc7430cce4
2 changed files with 6 additions and 2 deletions

View File

@ -66,5 +66,8 @@ conf.registerChannelValue(Karma, 'allowSelfRating',
conf.registerChannelValue(Karma, 'allowUnaddressedKarma',
registry.Boolean(True, _("""Determines whether the bot will
increase/decrease karma without being addressed.""")))
conf.registerChannelValue(Karma, 'onlyNicks',
registry.Boolean(False, _("""Determines whether the bot will
only increase/decrease karma for nicks in the current channel.""")))
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -246,12 +246,13 @@ class Karma(callbacks.Plugin):
def _doKarma(self, irc, msg, channel, thing):
inc = self.registryValue('incrementChars', channel)
dec = self.registryValue('decrementChars', channel)
onlynicks = self.registryValue('onlyNicks', channel)
karma = ''
for s in inc:
if thing.endswith(s):
thing = thing[:-len(s)]
# Don't reply if the target isn't a nick
if thing.lower() not in map(ircutils.toLower,
if onlynicks and thing.lower() not in map(ircutils.toLower,
irc.state.channels[channel].users):
return
if ircutils.strEqual(thing, msg.nick) and \
@ -263,7 +264,7 @@ class Karma(callbacks.Plugin):
for s in dec:
if thing.endswith(s):
thing = thing[:-len(s)]
if thing.lower() not in map(ircutils.toLower,
if onlynicks and thing.lower() not in map(ircutils.toLower,
irc.state.channels[channel].users):
return
if ircutils.strEqual(thing, msg.nick) and \