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

* cmd_bots now takes an optional parameter. A nodename (hostname) to match for bots. Down bots are prepended with a *.

svn: 1530
Bryan Drewery 21 лет назад
Родитель
Сommit
f213f87c45
5 измененных файлов с 36 добавлено и 22 удалено
  1. 1 0
      doc/UPDATES
  2. 5 2
      misc/help.txt
  3. 26 16
      src/botnet.c
  4. 1 1
      src/botnet.h
  5. 3 3
      src/cmds.c

+ 1 - 0
doc/UPDATES

@@ -66,6 +66,7 @@ This is a summary of ChangeLog basically.
 * cmd_bottree now shows HUBS as yellow.
 * Added cmd_login to change login display settings seen in .whois for a few versions
 * pscloak is now default 0.
+* cmd_bots now takes an optional parameter. A nodename (hostname) to match for bots. Down bots are prepended with a *.
 
 1.1.9
 

+ 5 - 2
misc/help.txt

@@ -311,13 +311,16 @@ See also: netnick
     Removes bot from the specified channel
  
 See also: botjoin, +chan, -chan, chanset, chaninfo
-:hub:bots
+:hub:bots [nodename]
 ###  $bbots$b
    Shows the list of bots currently on the botnet.
    Example:
       Bots: cEvin, ruthie, Killa1
    There is no indication of which bots are directly connected to this current
    bot. %{+n}Use $b'%dwho'$b or $b'%dbottree'$b for that information.%{-}
+
+   Specifying a nodename will display all bots up/down on that nodename.
+   Bots with a * preceeding it's name is down.
  
 See also: downbots%{+n}, bottree%{-}
 ::botserver:
@@ -900,7 +903,7 @@ See also: cycle
  
    Example:
       Down bots: cEvin, ruthie, Killa1
- 
+
 See also: bots
 :leaf:dump
 ###  $bdump$b <text>

+ 26 - 16
src/botnet.c

@@ -16,6 +16,7 @@
 #include "net.h"
 #include "socket.h"
 #include "adns.h"
+#include "match.h"
 #include "users.h"
 #include "misc.h"
 #include "userrec.h"
@@ -522,32 +523,41 @@ void answer_local_whom(int idx, int chan)
 /* Show z a list of all bots connected
  */
 void
-tell_bots(int idx, int up)
+tell_bots(int idx, int up, char *nodename)
 {
   struct userrec *u = NULL;
   int cnt = 0, tot = 0;
-  char work[128] = "";
+  char work[128] = "", *node = NULL;
 
   if (up) {
-    strcat(work, conf.bot->nick);
-    strcat(work, " ");
-    cnt++;
-    tot++;
+    node = (char *) get_user(&USERENTRY_NODENAME, conf.bot->u);    
+    if (!nodename || (nodename && node && wild_match(nodename, node))) {
+      strcat(work, conf.bot->nick);
+      strcat(work, " ");
+      cnt++;
+      tot++;
+    }
   }
 
   for (u = userlist; u; u = u->next) {
     if (u->bot) {
       if (egg_strcasecmp(u->handle, conf.bot->nick)) {
-        if ((!up && !findbot(u->handle)) || (up && findbot(u->handle))) {
-          strcat(work, u->handle);
-          cnt++;
-          tot++;
-          if (cnt == 11) {
-            dprintf(idx, "%s bots: %s\n", up ? "Up" : "Down", work);
-            work[0] = 0;
-            cnt = 0;
-          } else
-            strcat(work, " ");
+        if (nodename || (!nodename && ((!up && !findbot(u->handle)) || (up && findbot(u->handle))))) {
+          node = (char *) get_user(&USERENTRY_NODENAME, u);
+          if (!nodename || (nodename && node && wild_match(nodename, node))) {
+            if (nodename && !findbot(u->handle))
+              strcat(work, "*");
+            strcat(work, u->handle);
+            cnt++;
+            tot++;
+            if (cnt == 11) {
+              dprintf(idx, "%s bots: %s\n", up ? "Up" : "Down", work);
+              work[0] = 0;
+              cnt = 0;
+            } else {
+              strcat(work, " ");
+            }
+          }
         }
       }
     }

+ 1 - 1
src/botnet.h

@@ -17,7 +17,7 @@ char *lastbot(char *);
 int nextbot(char *);
 int in_chain(char *);
 #ifdef HUB
-void tell_bots(int, int);
+void tell_bots(int, int, char *);
 void tell_bottree(int);
 #endif /* HUB */
 void dump_links(int);

+ 3 - 3
src/cmds.c

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