summaryrefslogtreecommitdiff
path: root/misc.py
diff options
context:
space:
mode:
authorDico200 <dico.karssiens@gmail.com>2015-04-28 00:08:33 +0200
committerDico200 <dico.karssiens@gmail.com>2015-04-28 00:08:33 +0200
commit1cac4c6ed5911371595c699f4a626e7ef16c1c50 (patch)
tree6136014700188a566421f8e21010ba30a5f69e8d /misc.py
parent62569c736148aae34c9bafbfceb1033b88871daf (diff)
Added /tempadd command: temporary group membership
Just a simpler way of writing /pex user <user> group add <group> * 604800
Diffstat (limited to 'misc.py')
-rw-r--r--misc.py28
1 files changed, 28 insertions, 0 deletions
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 = "<user> <group> [duration]",
+ description = "Temporarily adds <user> to <group> 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):
"""