|
@@ -911,10 +911,9 @@ static void cmd_groups(int idx, char *par)
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- 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> > groupBots;
|
|
|
bd::HashTable<bd::String, bd::Array<bd::String> > botGroups;
|
|
bd::HashTable<bd::String, bd::Array<bd::String> > botGroups;
|
|
|
|
|
+ bd::String bothandle;
|
|
|
size_t maxGroupLen = 0;
|
|
size_t maxGroupLen = 0;
|
|
|
|
|
|
|
|
// Need to loop over every bot and make a list of all groups and bots which are in those groups
|
|
// Need to loop over every bot and make a list of all groups and bots which are in those groups
|
|
@@ -926,27 +925,40 @@ static void cmd_groups(int idx, char *par)
|
|
|
if (group.length() > maxGroupLen) {
|
|
if (group.length() > maxGroupLen) {
|
|
|
maxGroupLen = group.length();
|
|
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
|
|
// 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;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (botnick.length()) {
|
|
if (botnick.length()) {
|
|
|
- dprintf(idx, "%s is in groups: %s\n", botnick.c_str(), static_cast<bd::String>(botGroups[botnick].join(" ")).c_str());
|
|
|
|
|
- dprintf(idx, "Total groups: %zu/%zu\n", botGroups[botnick].length(), allgroups.length());
|
|
|
|
|
|
|
+ dprintf(idx, "%s is in groups: %s\n", botnick.c_str(),
|
|
|
|
|
+ static_cast<bd::String>(botGroups[botnick].join(" ")).c_str());
|
|
|
|
|
+ dprintf(idx, "Total groups: %zu/%zu\n", botGroups[botnick].length(),
|
|
|
|
|
+ groupBots.size());
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ std::vector<bd::String> allgroups;
|
|
|
|
|
+ allgroups.reserve(groupBots.size());
|
|
|
|
|
+ for (auto& kv : groupBots) {
|
|
|
|
|
+ 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
|
|
// Display all groups and which bots are in them
|
|
|
for (const auto& group : allgroups) {
|
|
for (const auto& group : allgroups) {
|
|
|
- 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());
|
|
|
|
|
|
|
+ const auto& bots = groupBots[group];
|
|
|
|
|
+ dumplots(idx,
|
|
|
|
|
+ bd::String::printf("%-*s: ", int(maxGroupLen), group.c_str()),
|
|
|
|
|
+ bots.join(" "));
|
|
|
}
|
|
}
|
|
|
- dprintf(idx, "Total groups: %zu\n", allgroups.length());
|
|
|
|
|
|
|
+ dprintf(idx, "Total groups: %zu\n", groupBots.size());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
return;
|