From 149b06a6a4ea2aca2a531ccac01840ca78c1501d Mon Sep 17 00:00:00 2001 From: Griatch Date: Tue, 12 Nov 2013 00:05:06 +0100 Subject: [PATCH] Fixed an issue with exit commands not using arg_regex ending correctly (it turns out you need to include this in the ExitCommand creation call or the metaclass will not pick it up and precompile the regex). Resolves Issue 397. --- src/commands/cmdparser.py | 4 ++-- src/comms/channelhandler.py | 4 +++- src/objects/objects.py | 7 +++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/commands/cmdparser.py b/src/commands/cmdparser.py index 514eb4340b..e281c04aae 100644 --- a/src/commands/cmdparser.py +++ b/src/commands/cmdparser.py @@ -52,8 +52,8 @@ def cmdparser(raw_string, cmdset, caller, match_index=None): try: matches.extend([create_match(cmdname, raw_string, cmd) for cmdname in [cmd.key] + cmd.aliases - if cmdname and l_raw_string.startswith(cmdname.lower()) - and (not cmd.arg_regex or + if cmdname and l_raw_string.startswith(cmdname.lower()) + and (not cmd.arg_regex or cmd.arg_regex.match(l_raw_string[len(cmdname):]))]) except Exception: log_trace("cmdhandler error. raw_input:%s" % raw_string) diff --git a/src/comms/channelhandler.py b/src/comms/channelhandler.py index 48b4cc884e..4616e43732 100644 --- a/src/comms/channelhandler.py +++ b/src/comms/channelhandler.py @@ -125,7 +125,9 @@ class ChannelHandler(object): cmd = ChannelCommand(key=channel.key.strip().lower(), aliases=channel.aliases.all(), locks="cmd:all();%s" % channel.locks, - obj=channel) + help_category="Channel names", + obj=channel, + is_channel=True) cmd.__doc__= self._format_help(channel) self.cached_channel_cmds.append(cmd) self.cached_cmdsets = {} diff --git a/src/objects/objects.py b/src/objects/objects.py index 1d622c8cee..d3cf7f634f 100644 --- a/src/objects/objects.py +++ b/src/objects/objects.py @@ -888,10 +888,7 @@ class Exit(Object): This is a command that simply cause the caller to traverse the object it is attached to. """ - locks = "cmd:all()" # should always be set to this. obj = None - arg_regex=r"\s.*?|$" - is_exit = True # this helps cmdhandler disable exits in cmdsets with no_exits=True. def func(self): "Default exit traverse if no syscommand is defined." @@ -908,12 +905,14 @@ class Exit(Object): # No shorthand error message. Call hook. self.obj.at_failed_traverse(self.caller) - # create an exit command. + # create an exit command. We give the properties here, to always trigger metaclass preparations cmd = ExitCommand(key=exidbobj.db_key.strip().lower(), aliases=exidbobj.aliases.all(), locks=str(exidbobj.locks), auto_help=False, destination=exidbobj.db_destination, + arg_regex=r"$", + is_exit=True, obj=exidbobj) # create a cmdset exit_cmdset = cmdset.CmdSet(None)