commands containing multiple slashes are no longer treated like a separate command...
[quassel.git] / src / core / userinputhandler.cpp
index 550e168..0e096a3 100644 (file)
@@ -37,7 +37,10 @@ void UserInputHandler::handleUserInput(const BufferInfo &bufferInfo, const QStri
       return;
     QString cmd;
     QString msg = msg_;
-    if(!msg.startsWith('/')) {
+    // leading slashes indicate there's a command to call unless there is anothere one in the first section (like a path /proc/cpuinfo)
+    int secondSlashPos = msg.indexOf('/', 1);
+    int firstSpacePos = msg.indexOf(' ');
+    if(!msg.startsWith('/') || (secondSlashPos != -1 && (secondSlashPos < firstSpacePos || firstSpacePos == -1))) {
       cmd = QString("SAY");
     } else {
       cmd = msg.section(' ', 0, 0).remove(0, 1).toUpper();
@@ -56,14 +59,17 @@ void UserInputHandler::handleUserInput(const BufferInfo &bufferInfo, const QStri
 void UserInputHandler::handleAway(const BufferInfo &bufferInfo, const QString &msg) {
   Q_UNUSED(bufferInfo)
 
-  QString awayMsg;
+  QString awayMsg = msg;
+  IrcUser *me = network()->me();
+
   // if there is no message supplied we have to check if we are already away or not
   if(msg.isEmpty()) {
-    IrcUser *me = network()->me();
     if(me && !me->isAway())
       awayMsg = networkConnection()->identity()->awayReason();
   }
-
+  if(me)
+    me->setAwayMessage(awayMsg);
+  
   putCmd("AWAY", serverEncode(awayMsg));
 }
 
@@ -193,7 +199,6 @@ void UserInputHandler::handleList(const BufferInfo &bufferInfo, const QString &m
   emit putCmd("LIST", serverEncode(msg.split(' ', QString::SkipEmptyParts)));
 }
 
-
 void UserInputHandler::handleMe(const BufferInfo &bufferInfo, const QString &msg) {
   if(bufferInfo.bufferName().isEmpty()) return; // server buffer
   networkConnection()->ctcpHandler()->query(bufferInfo.bufferName(), "ACTION", msg);
@@ -202,8 +207,14 @@ void UserInputHandler::handleMe(const BufferInfo &bufferInfo, const QString &msg
 
 void UserInputHandler::handleMode(const BufferInfo &bufferInfo, const QString &msg) {
   Q_UNUSED(bufferInfo)
+
+  QStringList params = msg.split(' ', QString::SkipEmptyParts);
+  // if the first argument is neither a channel nor us (user modes are only to oneself) the current buffer is assumed to be the target
+  if(!params.isEmpty() && !network()->isChannelName(params[0]) && !network()->isMyNick(params[0]))
+    params.prepend(bufferInfo.bufferName());
+  
   // TODO handle correct encoding for buffer modes (channelEncode())
-  emit putCmd("MODE", serverEncode(msg.split(' ', QString::SkipEmptyParts)));
+  emit putCmd("MODE", serverEncode(params));
 }
 
 // TODO: show privmsgs