Fixed the duplication of input history
This commit is contained in:
parent
db4f73f058
commit
4112dcd538
|
@ -642,21 +642,21 @@ class CommandProcessor(object):
|
||||||
if not text.startswith(self.COMMAND_PREFIX):
|
if not text.startswith(self.COMMAND_PREFIX):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
text = text[len(self.COMMAND_PREFIX):]
|
body = text[len(self.COMMAND_PREFIX):]
|
||||||
text = text.strip()
|
body = body.strip()
|
||||||
|
|
||||||
parts = text.split(' ', 1)
|
parts = body.split(' ', 1)
|
||||||
name, arguments = parts if len(parts) > 1 else (parts[0], None)
|
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:
|
if flag is not None:
|
||||||
return flag
|
return flag
|
||||||
|
|
||||||
self.execute_command(name, arguments)
|
self.execute_command(text, name, arguments)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def execute_command(self, name, arguments):
|
def execute_command(self, text, name, arguments):
|
||||||
command = self.retrieve_command(name)
|
command = self.retrieve_command(name)
|
||||||
|
|
||||||
args, opts = self.parse_command_arguments(arguments) if arguments else ([], [])
|
args, opts = self.parse_command_arguments(arguments) if arguments else ([], [])
|
||||||
|
|
|
@ -31,16 +31,14 @@ class ChatMiddleware(CommandProcessor):
|
||||||
Also provides some few basic utilities for the same purpose.
|
Also provides some few basic utilities for the same purpose.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def process_as_command(self, text):
|
def execute_command(self, text, name, arguments):
|
||||||
try:
|
try:
|
||||||
return super(ChatMiddleware, self).process_as_command(text)
|
super(ChatMiddleware, self).execute_command(text, name, arguments)
|
||||||
except CommandError, exception:
|
except CommandError, exception:
|
||||||
self.echo("%s: %s" %(exception.name, exception.message), 'error')
|
self.echo("%s: %s" %(exception.name, exception.message), 'error')
|
||||||
return True
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self.echo("An error occured while trying to execute the command", 'error')
|
self.echo("An error occured while trying to execute the command", 'error')
|
||||||
print_exc()
|
print_exc()
|
||||||
return True
|
|
||||||
finally:
|
finally:
|
||||||
self.add_history(text)
|
self.add_history(text)
|
||||||
self.clear_input()
|
self.clear_input()
|
||||||
|
|
Loading…
Reference in New Issue