Fix some formatting problems with /me
authorWuzzy <Wuzzy2@mail.ru>
Sat, 25 Aug 2018 19:07:17 +0200
changeset 13695 e529a34872f9
parent 13694 91fe09213abc
child 13696 d732ca5dcab9
Fix some formatting problems with /me
QTfrontend/net/newnetclient.cpp
QTfrontend/net/proto.cpp
--- a/QTfrontend/net/newnetclient.cpp	Sat Aug 25 18:21:37 2018 +0200
+++ b/QTfrontend/net/newnetclient.cpp	Sat Aug 25 19:07:17 2018 +0200
@@ -383,16 +383,18 @@
 
         QString action;
         QString message;
-        // Fake nicks are nicks used for messages from the server with nicks like
-        // [server], [random], etc.
-        // The '[' character is not allowed in real nicks.
-        bool isFakeNick = lst[1].startsWith('[');
-        if(!isFakeNick)
+        // '[' is a special character used in fake nick names of server messages.
+        // Those are supposed to be translated
+        if(!lst[1].startsWith('['))
         {
             // Normal message
             message = lst[2];
-            // Check for action (/me command)
-            action = HWProto::chatStringToAction(message);
+            // Another kind of fake nick. '(' nicks are server messages, but they must not be translated
+            if(!lst[1].startsWith('('))
+            {
+                // Check for action (/me command)
+                action = HWProto::chatStringToAction(message);
+            }
         }
         else
         {
--- a/QTfrontend/net/proto.cpp	Sat Aug 25 18:21:37 2018 +0200
+++ b/QTfrontend/net/proto.cpp	Sat Aug 25 19:07:17 2018 +0200
@@ -47,8 +47,11 @@
 
 QString HWProto::formatChatMsg(const QString & nick, const QString & msg)
 {
-    if(msg.left(4) == "/me ")
+    // Messages using the /me command.
+    // Server messages (nick starts with a bracket) are never considered /me messages.
+    if(msg.left(4) == "/me " && (!nick.startsWith('[')) && (!nick.startsWith('(')))
         return QString("\x02* %1 %2").arg(nick).arg(msg.mid(4));
+    // Normal chat message
     else
         return QString("\x01%1: %2").arg(nick).arg(msg);
 }