tweaked karma.py.

This commit is contained in:
jesopo 2016-06-24 13:10:36 +01:00
parent 64474b261a
commit 6a3b9b28b4
No known key found for this signature in database
GPG key ID: 0BBDEB2AEFCFFCB3

View file

@ -26,12 +26,12 @@ class Module(object):
def channel_message(self, event): def channel_message(self, event):
match = re.match(REGEX_KARMA, event["message"].strip()) match = re.match(REGEX_KARMA, event["message"].strip())
if match: if match and not event["action"]:
verbose = event["channel"].get_setting("karma-verbose", False) verbose = event["channel"].get_setting("karma-verbose", False)
if not event["user"].last_karma or (time.time()-event["user" if not event["user"].last_karma or (time.time()-event["user"
].last_karma) >= KARMA_DELAY_SECONDS: ].last_karma) >= KARMA_DELAY_SECONDS:
target = match.group(1).lower().strip() target = match.group(1).lower().strip()
if not target == event["user"].name: if not target == event["user"].name and target:
positive = match.group(2)[0] == "+" positive = match.group(2)[0] == "+"
setting = "karma-%s" % target setting = "karma-%s" % target
karma = event["server"].get_setting(setting, 0) karma = event["server"].get_setting(setting, 0)
@ -49,8 +49,9 @@ class Module(object):
message="%s now has %d karma" % (target, karma)) message="%s now has %d karma" % (target, karma))
event["user"].last_karma = time.time() event["user"].last_karma = time.time()
elif verbose: elif verbose:
self.bot.events.on("send").on("stderr").call(module_name="Karma", if target:
target=event["channel"], message="You cannot change your own karma") self.bot.events.on("send").on("stderr").call(module_name="Karma",
target=event["channel"], message="You cannot change your own karma")
elif verbose: elif verbose:
event["stderr"].write("Try again in a couple of seconds") event["stderr"].write("Try again in a couple of seconds")
def karma(self, event): def karma(self, event):