Răsfoiți Sursa

cmds_groups: Indicate down bots with '*'

Bryan Drewery 7 ani în urmă
părinte
comite
f92bd834f3
5 a modificat fișierele cu 18 adăugiri și 4 ștergeri
  1. 1 0
      doc/UPDATES.md
  2. 1 0
      doc/help.txt
  3. 1 1
      src/botnet.cc
  4. 5 0
      src/botnet.h
  5. 10 3
      src/cmds.cc

+ 1 - 0
doc/UPDATES.md

@@ -14,6 +14,7 @@
   * Fix server connect bursting for joining channels with help from other bots.
   * Tweak server connect burst to progress quicker.
   * Sort cmd_groups and cmd_bots better.
+  * cmd_groups: Indicate which bots are down with a _*_.
 
 # maint
   * Clear FiSH keys when a client quits.

+ 1 - 0
doc/help.txt

@@ -1098,6 +1098,7 @@ See also: console, channels%{+m}, status%{-}
    Shows the list of groups and which bots are in them.
  
    Specify a bot to only show which groups it is in.
+   Bots with a * preceding its name are down.
  
 See also: bots, downbots%{+n}, bottree%{-}
 ::handle

+ 1 - 1
src/botnet.cc

@@ -547,7 +547,7 @@ void answer_local_whom(int idx, int chan)
   dprintf(idx, "Total users: %d\n", total);
 }
 
-static bool
+bool
 __attribute__((pure))
 sortDownBots(bd::String botA, bd::String botB) {
   if (botA[0] == '*') ++botA;

+ 5 - 0
src/botnet.h

@@ -5,6 +5,10 @@
 #  include "config.h"
 #endif
 
+namespace bd {
+  class String;
+}
+
 #include "tandem.h"
 
 extern tand_t		*tandbot;
@@ -16,6 +20,7 @@ void answer_local_whom(int, int);
 char *lastbot(const char *) __attribute__((pure));
 int nextbot(const char *) __attribute__((pure));
 int in_chain(const char *) __attribute__((pure));
+bool sortDownBots(bd::String botA, bd::String botB) __attribute__((pure));
 void tell_bots(int, int, const char *);
 void tell_bottree(int);
 void dump_links(int);

+ 10 - 3
src/cmds.cc

@@ -913,6 +913,7 @@ static void cmd_groups(int idx, char *par)
 
   bd::HashTable<bd::String, bd::Array<bd::String> > groupBots;
   bd::HashTable<bd::String, bd::Array<bd::String> > botGroups;
+  bd::String bothandle;
   size_t maxGroupLen = 0;
 
   // Need to loop over every bot and make a list of all groups and bots which are in those groups
@@ -925,7 +926,11 @@ static void cmd_groups(int idx, char *par)
           maxGroupLen = group.length();
         }
         // Add them to the list for this group
-        groupBots[group] << u->handle;
+        if (u != conf.bot->u && !findbot(u->handle))
+          bothandle = bd::String::printf("*%s", u->handle);
+        else
+          bothandle = u->handle;
+        groupBots[group] << bothandle;
 
       }
     }
@@ -940,8 +945,10 @@ static void cmd_groups(int idx, char *par)
     std::vector<bd::String> allgroups;
     allgroups.reserve(groupBots.size());
     for (auto& kv : groupBots) {
-      allgroups.push_back(kv.first);
-      std::sort(kv.second.begin(), kv.second.end());
+      const auto& group{kv.first};
+      auto& botlist{kv.second};
+      allgroups.push_back(group);
+      std::sort(botlist.begin(), botlist.end(), sortDownBots);
     }
     std::sort(allgroups.begin(), allgroups.end());
     // Display all groups and which bots are in them