Fixed the duplication of input history

This commit is contained in:
red-agent 2009-09-27 12:32:57 +03:00
parent db4f73f058
commit 4112dcd538
2 changed files with 8 additions and 10 deletions

View File

@ -642,21 +642,21 @@ class CommandProcessor(object):
if not text.startswith(self.COMMAND_PREFIX):
return False
text = text[len(self.COMMAND_PREFIX):]
text = text.strip()
body = text[len(self.COMMAND_PREFIX):]
body = body.strip()
parts = text.split(' ', 1)
parts = body.split(' ', 1)
name, arguments = parts if len(parts) > 1 else (parts[0], None)
flag = self.looks_like_command(text, name, arguments)
flag = self.looks_like_command(body, name, arguments)
if flag is not None:
return flag
self.execute_command(name, arguments)
self.execute_command(text, name, arguments)
return True
def execute_command(self, name, arguments):
def execute_command(self, text, name, arguments):
command = self.retrieve_command(name)
args, opts = self.parse_command_arguments(arguments) if arguments else ([], [])

View File

@ -31,16 +31,14 @@ class ChatMiddleware(CommandProcessor):
Also provides some few basic utilities for the same purpose.
"""
def process_as_command(self, text):
def execute_command(self, text, name, arguments):
try:
return super(ChatMiddleware, self).process_as_command(text)
super(ChatMiddleware, self).execute_command(text, name, arguments)
except CommandError, exception:
self.echo("%s: %s" %(exception.name, exception.message), 'error')
return True
except Exception:
self.echo("An error occured while trying to execute the command", 'error')
print_exc()
return True
finally:
self.add_history(text)
self.clear_input()