fix channel_access spec arg indexes
This commit is contained in:
parent
a6c2d80075
commit
223fe9fc7c
1 changed files with 13 additions and 12 deletions
|
@ -46,37 +46,38 @@ class Module(ModuleManager.BaseModule):
|
||||||
@utils.spec("!<#channel>r~channel !'add,remove,set !<nickname>ouser "
|
@utils.spec("!<#channel>r~channel !'add,remove,set !<nickname>ouser "
|
||||||
"!<permissions>string")
|
"!<permissions>string")
|
||||||
def access(self, event):
|
def access(self, event):
|
||||||
subcommand = event["spec"][0].lower()
|
channel = event["spec"][0]
|
||||||
target = event["spec"][1]
|
subcommand = event["spec"][1].lower()
|
||||||
access = event["target"].get_user_setting(target.get_id(), "access", [])
|
target = event["spec"][2]
|
||||||
|
access = channel.get_user_setting(target.get_id(), "access", [])
|
||||||
|
|
||||||
if subcommand == "list":
|
if subcommand == "list":
|
||||||
event["stdout"].write("Access for %s: %s" % (target.nickname,
|
event["stdout"].write("Access for %s: %s" % (target.nickname,
|
||||||
" ".join(access)))
|
" ".join(access)))
|
||||||
elif subcommand == "set":
|
elif subcommand == "set":
|
||||||
event["target"].set_user_setting(target.get_id(), "access",
|
channel.set_user_setting(target.get_id(), "access",
|
||||||
event["spec"][2])
|
event["spec"][3])
|
||||||
elif subcommand == "add":
|
elif subcommand == "add":
|
||||||
for acc in event["spec"][2].split(" "):
|
for acc in event["spec"][3].split(" "):
|
||||||
if acc in access:
|
if acc in access:
|
||||||
raise utils.EventError("%s already has '%s' permission" % (
|
raise utils.EventError("%s already has '%s' permission" % (
|
||||||
target.nickname, acc))
|
target.nickname, acc))
|
||||||
access.append(acc)
|
access.append(acc)
|
||||||
event["target"].set_user_setting(target.get_id(), "access", access)
|
channel.set_user_setting(target.get_id(), "access", access)
|
||||||
event["stdout"].write("Added permission to %s: %s" % (
|
event["stdout"].write("Added permission to %s: %s" % (
|
||||||
target.nickname, event["spec"][2]))
|
target.nickname, event["spec"][3]))
|
||||||
elif subcommand == "remove":
|
elif subcommand == "remove":
|
||||||
for acc in event["spec"][2].split(" "):
|
for acc in event["spec"][3].split(" "):
|
||||||
if not acc in access:
|
if not acc in access:
|
||||||
raise utils.EventError("%s does not have '%s' permission" %
|
raise utils.EventError("%s does not have '%s' permission" %
|
||||||
(target.nickname, acc))
|
(target.nickname, acc))
|
||||||
access.remove(acc)
|
access.remove(acc)
|
||||||
if access:
|
if access:
|
||||||
event["target"].set_user_setting(target.get_id(), "access",
|
channel.set_user_setting(target.get_id(), "access",
|
||||||
access)
|
access)
|
||||||
else:
|
else:
|
||||||
event["target"].del_user_setting(target.get_id(), "access")
|
channel.del_user_setting(target.get_id(), "access")
|
||||||
event["stdout"].write("Removed permission from %s: %s" % (
|
event["stdout"].write("Removed permission from %s: %s" % (
|
||||||
target.nickname, event["spec"][2]))
|
target.nickname, event["spec"][3]))
|
||||||
else:
|
else:
|
||||||
event["stderr"].write("Unknown command '%s'" % subcommand)
|
event["stderr"].write("Unknown command '%s'" % subcommand)
|
||||||
|
|
Loading…
Reference in a new issue