From c9148700940af2ed7e7f3c1b3d6299d8e9756920 Mon Sep 17 00:00:00 2001 From: jesopo Date: Sat, 7 Sep 2019 17:39:24 +0100 Subject: [PATCH] only strip "nick: " prefix from karma when the nickname is known --- modules/karma.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/karma.py b/modules/karma.py index b034e23b..27743218 100644 --- a/modules/karma.py +++ b/modules/karma.py @@ -8,7 +8,7 @@ from src import EventManager, ModuleManager, utils WORD_STOP = [",", ":"] KARMA_DELAY_SECONDS = 3 -REGEX_KARMA = re.compile(r"^(?:\S+[:,] )?(.*)(\+{2}|\-{2})$") +REGEX_KARMA = re.compile(r"^(?:(\S+:) )?(.*)(\+{2}|\-{2})$") @utils.export("channelset", utils.BoolSetting("karma-verbose", "Enable/disable automatically responding to karma changes")) @@ -78,8 +78,13 @@ class Module(ModuleManager.BaseModule): @utils.kwarg("pattern", REGEX_KARMA) def channel_message(self, event): verbose = event["target"].get_setting("karma-verbose", False) - positive = event["match"].group(2)[0] == "+" - target = event["match"].group(1).strip().rstrip("".join(WORD_STOP)) + positive = event["match"].group(3)[0] == "+" + + target = event["match"].group(2).strip().rstrip("".join(WORD_STOP)) + if event["match"].group(1): + if not event["server"].has_user(event["match"].group(1)[:-1]): + target = "%s %s" % (event["match"].group(1), target) + if target: success, message = self._karma(event["server"], event["user"], target, positive)