Switch all 'hook.kwargs.get(' calls to 'hook.get_kwarg('

This commit is contained in:
jesopo 2019-06-26 10:59:52 +01:00
parent 6667f49ee3
commit 29b15da179
3 changed files with 10 additions and 8 deletions

View file

@ -109,9 +109,11 @@ class Module(ModuleManager.BaseModule):
"'%s' is an alias of unknown command '%s'" "'%s' is an alias of unknown command '%s'"
% (command.lower(), alias_of.lower())) % (command.lower(), alias_of.lower()))
if not is_channel and potential_hook.kwargs.get("channel_only"): if not is_channel and potential_hook.get_kwarg("channel_only",
False):
continue continue
if is_channel and potential_hook.kwargs.get("private_only"): if is_channel and potential_hook.get_kwarg("private_only",
False):
continue continue
hook = potential_hook hook = potential_hook
@ -161,7 +163,7 @@ class Module(ModuleManager.BaseModule):
def command(self, server, target, target_str, is_channel, user, command, def command(self, server, target, target_str, is_channel, user, command,
args_split, tags, hook, **kwargs): args_split, tags, hook, **kwargs):
message_tags = server.has_capability(MESSAGE_TAGS_CAP) message_tags = server.has_capability(MESSAGE_TAGS_CAP)
expect_output = hook.kwargs.get("expect_output", True) expect_output = hook.get_kwarg("expect_output", True)
module_name = self._get_prefix(hook) or "" module_name = self._get_prefix(hook) or ""
if not module_name and hasattr(hook.function, "__self__"): if not module_name and hasattr(hook.function, "__self__"):
@ -184,10 +186,10 @@ class Module(ModuleManager.BaseModule):
ret = False ret = False
had_out = False had_out = False
if hook.kwargs.get("remove_empty", True): if hook.get_kwarg("remove_empty", True):
args_split = list(filter(None, args_split)) args_split = list(filter(None, args_split))
min_args = hook.kwargs.get("min_args") min_args = hook.get_kwarg("min_args")
if min_args and len(args_split) < min_args: if min_args and len(args_split) < min_args:
command_prefix = "" command_prefix = ""
if is_channel: if is_channel:
@ -229,7 +231,7 @@ class Module(ModuleManager.BaseModule):
stderr.write(str(e)).send(command_method) stderr.write(str(e)).send(command_method)
return True return True
if not hook.kwargs.get("skip_out", False): if not hook.get_kwarg("skip_out", False):
had_out = stdout.has_text() or stderr.has_text() had_out = stdout.has_text() or stderr.has_text()
command_method = self._command_method(target, server) command_method = self._command_method(target, server)
stdout.send(command_method) stdout.send(command_method)

View file

@ -7,7 +7,7 @@ class Module(ModuleManager.BaseModule):
hooks = self.events.on("raw.received").on(line.command).get_hooks() hooks = self.events.on("raw.received").on(line.command).get_hooks()
default_events = [] default_events = []
for hook in hooks: for hook in hooks:
default_events.append(hook.kwargs.get("default_event", False)) default_events.append(hook.get_kwarg("default_event", False))
kwargs = {"server": server, "line": line, kwargs = {"server": server, "line": line,
"direction": utils.Direction.Recv} "direction": utils.Direction.Recv}

View file

@ -230,7 +230,7 @@ class Module(ModuleManager.BaseModule):
@utils.hook("preprocess.command") @utils.hook("preprocess.command")
def preprocess_command(self, event): def preprocess_command(self, event):
permission = event["hook"].get_kwarg("permission", None) permission = event["hook"].get_kwarg("permission", None)
authenticated = event["hook"].kwargs.get("authenticated", False) authenticated = event["hook"].get_kwarg("authenticated", False)
return self._check_command(event, permission, authenticated) return self._check_command(event, permission, authenticated)
@utils.hook("check.command.permission") @utils.hook("check.command.permission")