'karma-verbose' -> 'karma-pattern'. don't even parse when false

This commit is contained in:
jesopo 2019-09-12 12:09:16 +01:00
parent 8081a014ce
commit e68c5575d1

View file

@ -10,8 +10,8 @@ KARMA_DELAY_SECONDS = 3
REGEX_KARMA = re.compile(r"^(?:(\S+:) )?(.*)(\+{2}|\-{2})$")
@utils.export("channelset", utils.BoolSetting("karma-verbose",
"Enable/disable automatically responding to karma changes"))
@utils.export("channelset", utils.BoolSetting("karma-pattern",
"Enable/disable parsing ++/-- karma format"))
@utils.export("serverset", utils.BoolSetting("karma-nickname-only",
"Enable/disable karma being for nicknames only"))
class Module(ModuleManager.BaseModule):
@ -77,7 +77,8 @@ class Module(ModuleManager.BaseModule):
@utils.kwarg("command", "karma")
@utils.kwarg("pattern", REGEX_KARMA)
def channel_message(self, event):
verbose = event["target"].get_setting("karma-verbose", False)
pattern = event["target"].get_setting("karma-pattern", False)
if pattern:
positive = event["match"].group(3)[0] == "+"
target = event["match"].group(2).strip().rstrip("".join(WORD_STOP))
@ -88,7 +89,6 @@ class Module(ModuleManager.BaseModule):
if target:
success, message = self._karma(event["server"], event["user"],
target, positive)
if verbose:
event["stdout" if success else "stderr"].write(message)
@utils.hook("received.command.addpoint")