+
+void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible)
+{
+ Numeric::Builder<' '> reply(user, RPL_NAMREPLY, false, chan->name.size() + 3);
+ Numeric::Numeric& numeric = reply.GetNumeric();
+ if (chan->IsModeSet(secretmode))
+ numeric.push(std::string(1, '@'));
+ else if (chan->IsModeSet(privatemode))
+ numeric.push(std::string(1, '*'));
+ else
+ numeric.push(std::string(1, '='));
+
+ numeric.push(chan->name);
+ numeric.push(std::string());
+
+ std::string prefixlist;
+ std::string nick;
+ const Channel::MemberMap& members = chan->GetUsers();
+ for (Channel::MemberMap::const_iterator i = members.begin(); i != members.end(); ++i)
+ {
+ if ((!show_invisible) && (i->first->IsModeSet(invisiblemode)))
+ {
+ // Member is invisible and we are not supposed to show them
+ continue;
+ }
+
+ Membership* const memb = i->second;
+
+ prefixlist.clear();
+ char prefix = memb->GetPrefixChar();
+ if (prefix)
+ prefixlist.push_back(prefix);
+ nick = i->first->nick;
+
+ ModResult res;
+ FIRST_MOD_RESULT_CUSTOM(namesevprov, Names::EventListener, OnNamesListItem, res, (user, memb, prefixlist, nick));
+ if (res != MOD_RES_DENY)
+ reply.Add(prefixlist, nick);
+ }
+
+ reply.Flush();
+ user->WriteNumeric(RPL_ENDOFNAMES, chan->name, "End of /NAMES list.");
+}