فهرست منبع

Broadcast locally 30 secs delay ( in order to avoid "I'm Over here <player>..." useless irc spam )

Mihawk 8 سال پیش
والد
کامیت
f6abc18d88
1فایلهای تغییر یافته به همراه16 افزوده شده و 7 حذف شده
  1. 16 7
      Client.cpp

+ 16 - 7
Client.cpp

@@ -205,7 +205,7 @@ void Client::parsePrintedLine()
   QString message(myPrintLine.right(myPrintLine.size() - lastMatchSize));
 
 
-  QRegExp regex("^:\\s+\\.(spam|qw|help|qw_mute|qw_unmute|spam_mute|spam_unmute|lm|about)\\s*(.+)$");
+  QRegExp regex("^:\\s+\\.(spam|qw|help|qw_mute|qw_unmute|spam_mute|spam_unmute|lm|about|qw_local)\\s*(.+)$");
   if(regex.indexIn(message) == -1)
     return;
 
@@ -230,7 +230,8 @@ void Client::parsePrintedLine()
 
   if(command == "help")
   {
-    say("Broadcast a message: .qw <message> and .spam <message>", bestPlayer.name);
+    say("Broadcast a message: .qw <message> or .spam <message>", bestPlayer.name);
+    say("Broadcast locally (only to the game servers this bot is connected to): .qw_local <message>", bestPlayer.name);
     say("(Un)Mute: .qw_mute .qw_unmute or .spam_mute .spam_unmute", bestPlayer.name);
     say("Last 5 messages: .lm", bestPlayer.name);
     say("About this bot: .about", bestPlayer.name);
@@ -243,7 +244,7 @@ void Client::parsePrintedLine()
     return;
   }
 
-  if(command == "qw" || command == "spam")
+  if(command == "qw" || command == "spam" || command == "qw_local")
   {
     if(!args.trimmed().size())
     {
@@ -252,7 +253,7 @@ void Client::parsePrintedLine()
     }
 
     /* Floodprot for broadcasting commands */
-    if(command == "qw" || command == "spam")
+    if(command == "qw" || command == "spam" || command == "qw_local")
     {
       if(myBroadcastFloodTimer->isActive())
       {
@@ -260,11 +261,13 @@ void Client::parsePrintedLine()
         return;
       }
 
-      int time;
+      int time = 0;
       if(command == "qw")
         time = Settings::globalInstance()->qwFloodProtTime();
-      else
+      else if(command == "spam")
         time = Settings::globalInstance()->spamFloodProtTime();
+      else if(command == "qw_local")
+          time = 30;
       myBroadcastFloodTimerStart = currentTime;
       myBroadcastFloodTimer->start(time*1000);
     }
@@ -284,7 +287,13 @@ void Client::parsePrintedLine()
     // the server ip isn't replaced by a hostname automatically
     QString internalMessage("-" + command + "- " + nick + " - " + resolvedServer + " " + QString::number(playerCount()) + "/" + QString::number(myMaxClients) + " : " + args.trimmed());
     myApp->broadcast(internalMessage, myActiveClient);
-
+    
+    // If this is a local message don't broadcast externally
+    if (command == "qw_local") {
+        say("Broadcasting within qw servers only...", bestPlayer.name);
+        return;
+    }
+        
     // Message that will be broadcast to other networks (needs namefun parsing)
     // this message passes tru central, thus the server ip will be replaced by a hostname
     // automatically