summaryrefslogtreecommitdiff
path: root/src/commandhandler.cpp
diff options
context:
space:
mode:
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);