karma: option to ignore targets
This commit is contained in:
parent
fd7feeccdc
commit
ac3e71c32a
|
@ -157,6 +157,10 @@ IRCBOT_XMLRPC_PORT = 13132
|
||||||
|
|
||||||
# IRC module stuff
|
# IRC module stuff
|
||||||
|
|
||||||
|
# karma
|
||||||
|
|
||||||
|
KARMA_IGNORED_CHATTER_TARGETS = []
|
||||||
|
|
||||||
# storycraft
|
# storycraft
|
||||||
|
|
||||||
STORYCRAFT_MASTER_CHANNEL = '#dr.botzo'
|
STORYCRAFT_MASTER_CHANNEL = '#dr.botzo'
|
||||||
|
|
|
@ -7,6 +7,8 @@ import re
|
||||||
|
|
||||||
import irc.client
|
import irc.client
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from ircbot.lib import Plugin
|
from ircbot.lib import Plugin
|
||||||
from karma.models import KarmaKey, KarmaLogEntry
|
from karma.models import KarmaKey, KarmaLogEntry
|
||||||
|
|
||||||
|
@ -55,6 +57,11 @@ class Karma(Plugin):
|
||||||
what = event.arguments[0].lower()
|
what = event.arguments[0].lower()
|
||||||
karma_pattern = r'(?:\((.+?)\)|(\S+))(\+\+|--|\+-|-\+)(\s+|$)'
|
karma_pattern = r'(?:\((.+?)\)|(\S+))(\+\+|--|\+-|-\+)(\s+|$)'
|
||||||
|
|
||||||
|
where = event.target
|
||||||
|
if where in settings.KARMA_IGNORED_CHATTER_TARGETS:
|
||||||
|
log.debug("ignoring chatter in {0:s}".format(where))
|
||||||
|
return
|
||||||
|
|
||||||
# check the line for karma
|
# check the line for karma
|
||||||
log.debug(u"searching '%s' for karma", what)
|
log.debug(u"searching '%s' for karma", what)
|
||||||
matches = re.findall(karma_pattern, what, re.IGNORECASE)
|
matches = re.findall(karma_pattern, what, re.IGNORECASE)
|
||||||
|
|
Loading…
Reference in New Issue