From 1cac4c6ed5911371595c699f4a626e7ef16c1c50 Mon Sep 17 00:00:00 2001 From: Dico200 Date: Tue, 28 Apr 2015 00:08:33 +0200 Subject: [PATCH] Added /tempadd command: temporary group membership Just a simpler way of writing /pex user group add * 604800 --- misc.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/misc.py b/misc.py index a530424..d2054a8 100644 --- a/misc.py +++ b/misc.py @@ -182,6 +182,7 @@ def eval_argument_thread(event): thread.exit() """ + @simplecommand("pyeval", usage = "[code..]", description = "Runs python [code..] and returns the result", @@ -192,6 +193,33 @@ def on_pyeval_command(sender, command, label, args): return None +@simplecommand("tempadd", + usage = " [duration]", + description = "Temporarily adds to for \n[duration] minutes. Defaults to 1 week.", + helpNoargs = True, + helpSubcmd = True, + amin = 2, + amax = 3) +def tempadd_command(sender, command, label, args): + if not sender.hasPermission("permissions.manage.membership." + args[1]): + return "&cYou do not have permission to manage that group!" + if len(args) == 3: + if not args[2].isdigit(): + return "&cThats not a number!" + duration = int(args[2]) * 60 + else: + duration = 604800 + if duration <= 0: + return "&cThats too short!" + cmd = "pex user %s group add %s * %s" % (args[0], args[1], duration) + runas(sender, cmd) + + m, s = divmod(duration, 60) + h, m = divmod(m, 60) + d, h = divmod(h, 24) + return "&aAdded to group for %dd%dh%dm" % (d, h, m) + + @hook.command("modules") def on_modules_command(sender, command, label, args): """