Karma: refactor _doKarma handling

This commit is contained in:
GLolol 2015-01-12 18:08:44 -08:00
parent 40310c4d5a
commit 4729213898

View File

@ -246,7 +246,7 @@ class Karma(callbacks.Plugin):
def _doKarma(self, irc, msg, channel, thing): def _doKarma(self, irc, msg, channel, thing):
inc = self.registryValue('incrementChars', channel) inc = self.registryValue('incrementChars', channel)
dec = self.registryValue('decrementChars', channel) dec = self.registryValue('decrementChars', channel)
if thing.endswith(tuple(inc + dec)): karma = ''
for s in inc: for s in inc:
if thing.endswith(s): if thing.endswith(s):
thing = thing[:-len(s)] thing = thing[:-len(s)]
@ -272,6 +272,7 @@ class Karma(callbacks.Plugin):
return return
self.db.decrement(channel, self._normalizeThing(thing)) self.db.decrement(channel, self._normalizeThing(thing))
karma = self.db.get(channel, self._normalizeThing(thing)) karma = self.db.get(channel, self._normalizeThing(thing))
if karma:
self._respond(irc, channel, thing, karma[0]-karma[1]) self._respond(irc, channel, thing, karma[0]-karma[1])
def invalidCommand(self, irc, msg, tokens): def invalidCommand(self, irc, msg, tokens):