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

* Specify bot to cmd_groups to show groups for that bot

Bryan Drewery 14 лет назад
Родитель
Сommit
12475c471b
2 измененных файлов с 14 добавлено и 7 удалено
  1. 3 1
      doc/help.txt
  2. 11 6
      src/cmds.c

+ 3 - 1
doc/help.txt

@@ -1054,8 +1054,10 @@ See also: -exempt, +exempt, console%{+m|m}, chanset, chaninfo%{-}, stick, unstic
  
 See also: console, channels%{+m}, status%{-}
 :hub:groups
-###  $bgroups$b
+###  $bgroups$b [bot]
    Shows the list of groups and which bots are in them.
+
+   Specify a bot to only show which groups it is in.
  
 See also: bots, downbots%{+n}, bottree%{-}
 ::handle

+ 11 - 6
src/cmds.c

@@ -905,7 +905,8 @@ static void cmd_groups(int idx, char *par)
 {
   struct userrec *u = NULL;
 
-  putlog(LOG_CMDS, "*", "#%s# groups", dcc[idx].nick);
+  putlog(LOG_CMDS, "*", "#%s# groups %s", dcc[idx].nick, par);
+  bd::String botnick(newsplit(&par));
 
   bd::Array<bd::String> globalgroups = bd::String(var_get_gdata("groups")).split(",");
   bd::Array<bd::String> allgroups;
@@ -934,11 +935,15 @@ static void cmd_groups(int idx, char *par)
     }
   }
 
-  // Display all groups and which bots are in them
-  for (size_t i = 0; i < allgroups.length(); ++i) {
-    const bd::String group(allgroups[i]);
-    const bd::Array<bd::String> bots(groupBots[group]);
-    dumplots(idx, bd::String::printf("%-*s: ", int(maxGroupLen), group.c_str()).c_str(), static_cast<bd::String>(bots.join(" ")).c_str());
+  if (botnick.length()) {
+    dprintf(idx, "%s is in groups: %s\n", botnick.c_str(), static_cast<bd::String>(botGroups[botnick].join(" ")).c_str());
+  } else {
+    // Display all groups and which bots are in them
+    for (size_t i = 0; i < allgroups.length(); ++i) {
+      const bd::String group(allgroups[i]);
+      const bd::Array<bd::String> bots(groupBots[group]);
+      dumplots(idx, bd::String::printf("%-*s: ", int(maxGroupLen), group.c_str()).c_str(), static_cast<bd::String>(bots.join(" ")).c_str());
+    }
   }
 
   dprintf(idx, "Total groups: %zu\n", allgroups.length());