Просмотр исходного кода

* Improvemnts to cmd_bots [nodename]

svn: 1531
Bryan Drewery 21 лет назад
Родитель
Сommit
24fe7d84f3
2 измененных файлов с 22 добавлено и 9 удалено
  1. 21 8
      src/botnet.c
  2. 1 1
      src/cmds.c

+ 21 - 8
src/botnet.c

@@ -526,7 +526,7 @@ void
 tell_bots(int idx, int up, char *nodename)
 {
   struct userrec *u = NULL;
-  int cnt = 0, tot = 0;
+  int cnt = 0, tot = 0, total = 1, mtot = 0;
   char work[128] = "", *node = NULL;
 
   if (up) {
@@ -536,22 +536,33 @@ tell_bots(int idx, int up, char *nodename)
       strcat(work, " ");
       cnt++;
       tot++;
+      if (nodename)
+        mtot++;
     }
   }
 
   for (u = userlist; u; u = u->next) {
     if (u->bot) {
       if (egg_strcasecmp(u->handle, conf.bot->nick)) {
-        if (nodename || (!nodename && ((!up && !findbot(u->handle)) || (up && findbot(u->handle))))) {
+        bool found = 0;
+        
+        if (findbot(u->handle))
+          found = 1;
+        total++;
+        if (nodename || (!nodename && ((!up && !found) || (up && found)))) {
           node = (char *) get_user(&USERENTRY_NODENAME, u);
           if (!nodename || (nodename && node && wild_match(nodename, node))) {
-            if (nodename && !findbot(u->handle))
+            if (nodename && !found)
               strcat(work, "*");
             strcat(work, u->handle);
-            cnt++;
-            tot++;
+            if (!nodename && found)
+              cnt++;
+            else if (nodename)
+              mtot++;
+            if (!nodename || (nodename && found))
+              tot++;
             if (cnt == 11) {
-              dprintf(idx, "%s bots: %s\n", up ? "Up" : "Down", work);
+              dprintf(idx, "%s bots: %s\n", nodename ? "Matching" : up ? "Up" : "Down", work);
               work[0] = 0;
               cnt = 0;
             } else {
@@ -563,8 +574,10 @@ tell_bots(int idx, int up, char *nodename)
     }
   }
   if (work[0])
-    dprintf(idx, "%s bot%s: %s\n", up ? "Up" : "Down", cnt > 1 ? "s" : "", work);
-  dprintf(idx, "(Total %s: %d)\n", up ? "up" : "down", tot);
+    dprintf(idx, "%s bot%s: %s\n", nodename ? "Matching" : up ? "Up" : "Down", cnt > 1 ? "s" : "", work);
+  if (nodename)
+    dprintf(idx, "(Total Matching: %d/%d)\n", mtot, total);
+  dprintf(idx, "(Total %s: %d/%d)\n", nodename ? "up" : up ? "up" : "down", tot, nodename ? mtot : total);
 }
 
 /* Show a simpleton bot tree

+ 1 - 1
src/cmds.c

@@ -686,7 +686,7 @@ static void cmd_secpass(int idx, char *par)
 static void cmd_bots(int idx, char *par)
 {
   putlog(LOG_CMDS, "*", "#%s# bots %s", dcc[idx].nick, par ? par : "");
-  tell_bots(idx, 1, par);
+  tell_bots(idx, 1, par[0] ? par : NULL);
 }
 
 static void cmd_downbots(int idx, char *par)