|
@@ -901,6 +901,50 @@ static void cmd_userlist(int idx, char *par)
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static void cmd_groups(int idx, char *par)
|
|
|
|
|
+{
|
|
|
|
|
+ struct userrec *u = NULL;
|
|
|
|
|
+
|
|
|
|
|
+ putlog(LOG_CMDS, "*", "#%s# groups", dcc[idx].nick);
|
|
|
|
|
+
|
|
|
|
|
+ bd::Array<bd::String> globalgroups = bd::String(var_get_gdata("groups")).split(",");
|
|
|
|
|
+ bd::Array<bd::String> allgroups;
|
|
|
|
|
+ bd::HashTable<bd::String, bd::Array<bd::String> > groupBots;
|
|
|
|
|
+ bd::HashTable<bd::String, bd::Array<bd::String> > botGroups;
|
|
|
|
|
+ size_t maxGroupLen = 0;
|
|
|
|
|
+
|
|
|
|
|
+ // Need to loop over every bot and make a list of all groups and bots which are in those groups
|
|
|
|
|
+ for (u = userlist; u; u = u->next) {
|
|
|
|
|
+ if (u->bot && bot_hublevel(u) == 999) {
|
|
|
|
|
+ // Gather all the groups for this bot
|
|
|
|
|
+ botGroups[u->handle] = bd::String(var_get_bot_data(u, "groups", true)).split(",");
|
|
|
|
|
+ for (size_t i = 0; i < botGroups[u->handle].length(); ++i) {
|
|
|
|
|
+ const bd::String group(botGroups[u->handle][i]);
|
|
|
|
|
+ if (group.length() > maxGroupLen) {
|
|
|
|
|
+ maxGroupLen = group.length();
|
|
|
|
|
+ }
|
|
|
|
|
+ // Add their groups into the master list
|
|
|
|
|
+ if (allgroups.find(group) == allgroups.npos) {
|
|
|
|
|
+ allgroups << group;
|
|
|
|
|
+ }
|
|
|
|
|
+ // Add them to the list for this group
|
|
|
|
|
+ groupBots[group] << u->handle;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 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());
|
|
|
|
|
+ return;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void cmd_channels(int idx, char *par) {
|
|
static void cmd_channels(int idx, char *par) {
|
|
|
putlog(LOG_CMDS, "*", "#%s# channels %s", dcc[idx].nick, par);
|
|
putlog(LOG_CMDS, "*", "#%s# channels %s", dcc[idx].nick, par);
|
|
|
if (par[0] && (dcc[idx].user->flags & USER_MASTER)) {
|
|
if (par[0] && (dcc[idx].user->flags & USER_MASTER)) {
|
|
@@ -4666,6 +4710,7 @@ cmd_t C_dcc[] =
|
|
|
{"version", "o", (Function) cmd_version, NULL, 0},
|
|
{"version", "o", (Function) cmd_version, NULL, 0},
|
|
|
{"netversion", "o", (Function) cmd_netversion, NULL, HUB},
|
|
{"netversion", "o", (Function) cmd_netversion, NULL, HUB},
|
|
|
{"userlist", "m", (Function) cmd_userlist, NULL, 0},
|
|
{"userlist", "m", (Function) cmd_userlist, NULL, 0},
|
|
|
|
|
+ {"groups", "m", (Function) cmd_groups, NULL, HUB},
|
|
|
{"ps", "n", (Function) cmd_ps, NULL, 0},
|
|
{"ps", "n", (Function) cmd_ps, NULL, 0},
|
|
|
{"last", "n", (Function) cmd_last, NULL, 0},
|
|
{"last", "n", (Function) cmd_last, NULL, 0},
|
|
|
{"exec", "a", (Function) cmd_exec, NULL, 0},
|
|
{"exec", "a", (Function) cmd_exec, NULL, 0},
|