From 4112dcd538e70e69fe61ecc47400b1e82fd7514b Mon Sep 17 00:00:00 2001 From: red-agent Date: Sun, 27 Sep 2009 12:32:57 +0300 Subject: [PATCH] Fixed the duplication of input history --- src/commands/framework.py | 12 ++++++------ src/commands/middleware.py | 6 ++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/commands/framework.py b/src/commands/framework.py index 9520533ff..99cb1aaa8 100644 --- a/src/commands/framework.py +++ b/src/commands/framework.py @@ -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 ([], []) diff --git a/src/commands/middleware.py b/src/commands/middleware.py index ad4fcbf9e..7c139afd9 100644 --- a/src/commands/middleware.py +++ b/src/commands/middleware.py @@ -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()