only try to shlex when we know we've found a command hook

This commit is contained in:
jesopo 2019-11-15 13:26:11 +00:00
parent 64ab4ca1a1
commit 6a55b14afa

View file

@ -99,6 +99,7 @@ class Module(ModuleManager.BaseModule):
return None, None, None return None, None, None
hook = None hook = None
args_split = []
channel_skip = False channel_skip = False
private_skip = False private_skip = False
if self.has_command(command): if self.has_command(command):
@ -122,17 +123,18 @@ class Module(ModuleManager.BaseModule):
continue continue
hook = potential_hook hook = potential_hook
argparse = hook.get_kwarg("argparse", "plain")
if argparse == "shlex":
args_split = shlex.split(args)
elif argparse == "plain":
args_split = args.split(" ")
break break
if not hook and (private_skip or channel_skip): if not hook and (private_skip or channel_skip):
raise BadContextException("channel" if channel_skip else "private") raise BadContextException("channel" if channel_skip else "private")
argparse = hook.get_kwarg("argparse", "plain")
if argparse == "shlex":
args_split = shlex.split(args)
elif argparse == "plain":
args_split = args.split(" ")
return hook, command, args_split return hook, command, args_split
def _check(self, context, kwargs, requests=[]): def _check(self, context, kwargs, requests=[]):