-/* compile a userlist of a channel into a string, each nick seperated by
- * spaces and op, voice etc status shown as @ and +, and send it to 'user'
- */
-void Channel::UserList(User *user)
-{
- bool has_privs = user->HasPrivPermission("channels/auspex");
- if (this->IsModeSet(secretmode) && !this->HasUser(user) && !has_privs)
- {
- user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", this->name.c_str());
- return;
- }
-
- std::string list;
- list.push_back(this->IsModeSet(secretmode) ? '@' : this->IsModeSet(privatemode) ? '*' : '=');
- list.push_back(' ');
- list.append(this->name).append(" :");
- std::string::size_type pos = list.size();
-
- bool has_one = false;
-
- /* Improvement by Brain - this doesnt change in value, so why was it inside
- * the loop?
- */
- bool has_user = this->HasUser(user);
-
- std::string prefixlist;
- std::string nick;
- for (UserMembIter i = userlist.begin(); i != userlist.end(); ++i)
- {
- if ((!has_user) && (i->first->IsModeSet(invisiblemode)) && (!has_privs))
- {
- /*
- * user is +i, and source not on the channel, does not show
- * nick in NAMES list
- */
- continue;
- }
-
- Membership* memb = i->second;
-
- prefixlist.clear();
- prefixlist.push_back(memb->GetPrefixChar());
- nick = i->first->nick;
-
- FOREACH_MOD(OnNamesListItem, (user, memb, prefixlist, nick));
-
- /* Nick was nuked, a module wants us to skip it */
- if (nick.empty())
- continue;
-
- if (list.size() + prefixlist.length() + nick.length() + 1 > 480)
- {
- /* list overflowed into multiple numerics */
- user->WriteNumeric(RPL_NAMREPLY, list);
-
- // Erase all nicks, keep the constant part
- list.erase(pos);
- has_one = false;
- }
-
- list.append(prefixlist).append(nick).push_back(' ');
-
- has_one = true;
- }
-
- /* if whats left in the list isnt empty, send it */
- if (has_one)
- {
- user->WriteNumeric(RPL_NAMREPLY, list);
- }
-
- user->WriteNumeric(RPL_ENDOFNAMES, "%s :End of /NAMES list.", this->name.c_str());
-}
-