Add setcoins command for admins, for people that abuse the coin game, or rewards and such.
This commit is contained in:
parent
bb15f8b8e2
commit
0cb2c43ee3
1 changed files with 21 additions and 2 deletions
|
@ -26,6 +26,7 @@ THIRD_COLUMN = list(range(1, 37))[2::3]
|
|||
REGEX_STREET = re.compile("street([1-9]|1[0-2])$")
|
||||
|
||||
class Module(object):
|
||||
|
||||
def __init__(self, bot, events, exports):
|
||||
self.bot = bot
|
||||
events.on("received.command.coins").hook(self.coins,
|
||||
|
@ -57,6 +58,12 @@ class Module(object):
|
|||
self.send, min_args=2, help="Send coins to a user",
|
||||
usage="<nickname> <amount>", authenticated=True)
|
||||
|
||||
events.on("received.command.setcoins").hook(
|
||||
self.set_coins, min_args=2,
|
||||
help="Set a users coins. Do not abuse.",
|
||||
usage="<nickname> <amount>", permission="setcoins",
|
||||
authenticated=True)
|
||||
|
||||
now = datetime.datetime.now()
|
||||
until_next_hour = 60-now.second
|
||||
until_next_hour += ((60-(now.minute+1))*60)
|
||||
|
@ -84,6 +91,18 @@ class Module(object):
|
|||
target.del_setting("coins")
|
||||
event["stdout"].write("Reset coins for %s" % target.nickname)
|
||||
|
||||
def set_coins(self, event):
|
||||
target = event["server"].get_user(event["args_split"][0])
|
||||
coins = event["args_split"][1]
|
||||
|
||||
if not coins.isdigit():
|
||||
event["stderr"].write("Cannot set coins for %s, coins must be a " \
|
||||
+ "whole number." % target.nickname)
|
||||
return
|
||||
|
||||
target.set_setting("coins", "%s.0" % coins)
|
||||
event["stdout"].write("Set %s's coins to %s" % (target.nickname, coins))
|
||||
|
||||
def give_coins(self, event):
|
||||
target = event["server"].get_user(event["args_split"][0])
|
||||
coins = event["args_split"][1]
|
||||
|
@ -107,8 +126,8 @@ class Module(object):
|
|||
|
||||
top_10 = sorted(all_coins.keys())
|
||||
top_10 = sorted(top_10, key=all_coins.get, reverse=True)[:10]
|
||||
top_10 = ", ".join("%s (%s)" % (Utils.prevent_highlight(event[
|
||||
"server"].get_user(nickname).nickname), "{0:.2f}".format(
|
||||
top_10 = ", ".join("%s (%s)" % (Utils.bold(Utils.prevent_highlight(
|
||||
event["server"].get_user(nickname).nickname)), "{0:.2f}".format(
|
||||
all_coins[nickname])) for nickname in top_10)
|
||||
event["stdout"].write("Richest users: %s" % top_10)
|
||||
|
||||
|
|
Loading…
Reference in a new issue