diff options
author | Adam <Adam@anope.org> | 2013-02-13 17:42:01 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-02-14 01:20:18 -0500 |
commit | 9e544a6443117861c3d6406e435043f1cf0f7099 (patch) | |
tree | e7449fb01e377576e8a09f386117d2c251de0596 /modules/commands/ns_alist.cpp | |
parent | 225b7c38c127fbc6aac6724012f71c9483a4da77 (diff) |
Store what channels have references to accounts in NickCore to prevent having to iterate over all channels and then all access entries when nicks expire or from nickserv/alist
Diffstat (limited to 'modules/commands/ns_alist.cpp')
-rw-r--r-- | modules/commands/ns_alist.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp index bd3a22281..c8d7eef0f 100644 --- a/modules/commands/ns_alist.cpp +++ b/modules/commands/ns_alist.cpp @@ -46,12 +46,21 @@ class CommandNSAList : public Command source.Reply(_("Channels that \002%s\002 has access on:"), nc->display.c_str()); - for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) + std::deque<ChannelInfo *> queue; + nc->GetChannelReferences(queue); + + if (queue.empty()) + { + source.Reply(_("\2%s\2 has no access in any channels."), nc->display.c_str()); + return; + } + + for (unsigned i = 0; i < queue.size(); ++i) { - ChannelInfo *ci = it->second; + ChannelInfo *ci = queue[i]; ListFormatter::ListEntry entry; - if (ci->GetFounder() && ci->GetFounder() == nc) + if (ci->GetFounder() == nc) { ++chan_count; entry["Number"] = stringify(chan_count); @@ -61,6 +70,16 @@ class CommandNSAList : public Command continue; } + if (ci->GetSuccessor() == nc) + { + ++chan_count; + entry["Number"] = stringify(chan_count); + entry["Channel"] = (ci->HasExt("NO_EXPIRE") ? "!" : "") + ci->name; + entry["Access"] = "Successor"; + list.AddEntry(entry); + continue; + } + AccessGroup access = ci->AccessFor(nc); if (access.empty()) continue; @@ -69,8 +88,8 @@ class CommandNSAList : public Command entry["Number"] = stringify(chan_count); entry["Channel"] = (ci->HasExt("NO_EXPIRE") ? "!" : "") + ci->name; - for (unsigned i = 0; i < access.size(); ++i) - entry["Access"] = entry["Access"] + ", " + access[i]->AccessSerialize(); + for (unsigned j = 0; j < access.size(); ++j) + entry["Access"] = entry["Access"] + ", " + access[j]->AccessSerialize(); entry["Access"] = entry["Access"].substr(2); list.AddEntry(entry); } @@ -79,6 +98,8 @@ class CommandNSAList : public Command list.Process(replies); for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); + + source.Reply(_("End of list - %d channels shown."), chan_count); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override |