From 871203e820e8be156e62c873c366482cf18d1408 Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Wed, 16 Feb 2011 13:58:57 +0100 Subject: Fixing query command handling Tab completion puts quotes around nicks. The query command now removes the quotes. Also avoiding the opening of a tab if no nick was given. Reviewed-by: Freeyorp --- src/commandhandler.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 1c375ad9..f8ef116c 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -50,6 +50,7 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) std::string::size_type pos = command.find(' '); std::string type(command, 0, pos); std::string args(command, pos == std::string::npos ? command.size() : pos + 1); + trim(args); if (type == "help") // Do help before tabs so they can't override it { @@ -402,8 +403,21 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) void CommandHandler::handleQuery(const std::string &args, ChatTab *tab) { - if (chatWindow->addWhisperTab(args, true)) + if (args.empty()) + { + tab->chatLog(_("No was given."), BY_SERVER); + return; + } + + if (args.length() > 1 && args[0] == '\"' && args[args.length() - 1] == '\"') + { + if (chatWindow->addWhisperTab(args.substr(1, args.length() - 2), true)) + return; + } + else if (chatWindow->addWhisperTab(args, true)) + { return; + } tab->chatLog(strprintf(_("Cannot create a whisper tab for nick \"%s\"! " "It either already exists, or is you."), args.c_str()), BY_SERVER); -- cgit v1.2.3-70-g09d2