add self check.command, change !config to use new yields

This commit is contained in:
jesopo 2019-06-14 12:09:42 +01:00
parent f05fc209b0
commit f614d1fc14
3 changed files with 17 additions and 1 deletions

View file

@ -604,3 +604,11 @@ class Module(ModuleManager.BaseModule):
del aliases[alias]
self._set_aliases(event["server"], aliases)
event["stdout"].write("Removed '%s' alias" % alias)
@utils.hook("check.command.self")
def check_command_self(self, event):
if event["server"].irc_lower(event["request_args"][0]
) == event["user"].name:
return utils.consts.PERMISSION_FORCE_SUCCESS
else:
return "You do not have permission to do this"

View file

@ -281,7 +281,6 @@ class Module(ModuleManager.BaseModule):
"""
:help: Change config options
:usage: <context>[:name] [-][setting [value]]
:permission: config
"""
arg_count = len(event["args_split"])
@ -297,12 +296,17 @@ class Module(ModuleManager.BaseModule):
target, context = self._to_context(event["server"],
event["target"], event["user"], context_desc)
permission_check = utils.Check("permission", "config")
if context == "set":
if name:
yield utils.Check("self", name)|permission_check
target = event["server"].get_user(name)
else:
target = event["user"]
elif context == "channelset":
yield utils.Check("channel-mode", "o")|permission_check
if name:
if name in event["server"].channels:
target = event["server"].channels.get(name)
@ -316,6 +320,8 @@ class Module(ModuleManager.BaseModule):
raise utils.EventError(
"Cannot change config for current channel when in "
"private message")
elif context == "serverset" or context == "botset":
yield utils.Check("permission", "config")
export_settings = self._get_export_setting(context)
if not setting == None:

View file

@ -31,6 +31,8 @@ class Module(ModuleManager.BaseModule):
"""
:help: Show my network/channel/user stats
"""
yield utils.Check("channel-mode", "o")|utils.Check("permission", "asd")
networks, channels, users = self._stats()
response = "I currently have %d network" % networks