summaryrefslogtreecommitdiff
path: root/src/commandhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-22 16:06:06 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-22 16:06:06 +0300
commit7aa3784a5d62848af60aabc3f82b19fb068b9d79 (patch)
tree6e1538bf378c54a99ff02fe99d7e79ea6ac504f4 /src/commandhandler.cpp
parent147696620522270d51d15ff3fd1e7e2431ff61ae (diff)
downloadplus-7aa3784a5d62848af60aabc3f82b19fb068b9d79.tar.gz
plus-7aa3784a5d62848af60aabc3f82b19fb068b9d79.tar.bz2
plus-7aa3784a5d62848af60aabc3f82b19fb068b9d79.tar.xz
plus-7aa3784a5d62848af60aabc3f82b19fb068b9d79.zip
Add new chat commands.
/url LINK - put http link in chat. /openurl LINK - open link in browser.
Diffstat (limited to 'src/commandhandler.cpp')
-rw-r--r--src/commandhandler.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index af87adafd..8fab8e042 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -69,6 +69,7 @@
#endif
#include "utils/gettext.h"
+#include "utils/process.h"
#include "utils/stringutils.h"
#include "debug.h"
@@ -216,6 +217,10 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab)
handleDumpTests(args, tab);
else if (type == "dumpogl")
handleDumpOGL(args, tab);
+ else if (type == "url")
+ handleUrl(args, tab);
+ else if (type == "open")
+ handleOpen(args, tab);
else if (tab->handleCommand(type, args))
;
else if (type == "hack")
@@ -1212,6 +1217,28 @@ void CommandHandler::handleError(const std::string &args A_UNUSED,
logger->log("test %d", *ptr);
}
+void CommandHandler::handleUrl(const std::string &args,
+ ChatTab *tab)
+{
+ if (tab)
+ {
+ std::string url = args;
+ if (!strStartWith(url, "http"))
+ url = "http://" + url;
+ std::string str = strprintf("[@@%s|%s@@]", url.c_str(), args.c_str());
+ outStringNormal(tab, str, str);
+ }
+}
+
+void CommandHandler::handleOpen(const std::string &args,
+ ChatTab *tab A_UNUSED)
+{
+ std::string url = args;
+ if (!strStartWith(url, "http"))
+ url = "http://" + url;
+ openBrowser(url);
+}
+
#ifdef DEBUG_DUMP_LEAKS1
void showRes(std::string str, ResourceManager::Resources *res);