Added !resetkarma in karma.py

This commit is contained in:
jesopo 2018-08-18 18:28:27 +01:00
parent dacf74e2b1
commit 054a98c0c8

View file

@ -13,6 +13,10 @@ class Module(object):
bot.events.on("received").on("command").on("karma").hook( bot.events.on("received").on("command").on("karma").hook(
self.karma, help="Get your or someone else's karma", self.karma, help="Get your or someone else's karma",
usage="[target]") usage="[target]")
bot.events.on("received").on("command").on("resetkarma").hook(
self.reset_karma, permission="resetkarma",
min_args=1, help="Reset a specified karma to 0",
usage="<target>")
bot.events.on("postboot").on("configure").on( bot.events.on("postboot").on("configure").on(
"channelset").call(setting="karma-verbose", "channelset").call(setting="karma-verbose",
@ -59,3 +63,14 @@ class Module(object):
target = event["user"].nickname target = event["user"].nickname
karma = event["server"].get_setting("karma-%s" % target, 0) karma = event["server"].get_setting("karma-%s" % target, 0)
event["stdout"].write("%s has %s karma" % (target, karma)) event["stdout"].write("%s has %s karma" % (target, karma))
def reset_karma(self, event):
setting = "karma-%s" % event["args_split"][0]
karma = event["server"].get_setting(setting, 0)
if karma == 0:
event["stderr"].write("%s already has 0 karma" % event[
"args_split"][0])
else:
event["server"].del_setting(setting)
event["stdout"].write("Reset karma for %s" % event[
"args_split"][0])