X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_list.cpp;h=6a62d122f660e1e932b4e7d28463a19cbe13f61a;hb=b0654ef6abd8d976fcbadce24ea350f7c420fe08;hp=ceffae43a5606de859e07a0f0f03787c10547da6;hpb=c67d3103e9f7397f0ab9631bf07a5e5547deb2c3;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index ceffae43a..6a62d122f 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -53,10 +53,9 @@ CmdResult CommandList::Handle (const std::vector& parameters, User { int minusers = 0, maxusers = 0; - user->WriteNumeric(RPL_LISTSTART, "Channel :Users Name"); + user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name"); - /* Work around mIRC suckyness. YOU SUCK, KHALED! */ - if (parameters.size() == 1) + if ((parameters.size() == 1) && (!parameters[0].empty())) { if (parameters[0][0] == '<') { @@ -68,10 +67,16 @@ CmdResult CommandList::Handle (const std::vector& parameters, User } } - for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); i++) + const bool has_privs = user->HasPrivPermission("channels/auspex"); + const bool match_name_topic = ((!parameters.empty()) && (!parameters[0].empty()) && (parameters[0][0] != '<') && (parameters[0][0] != '>')); + + const chan_hash& chans = ServerInstance->GetChans(); + for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i) { + Channel* const chan = i->second; + // attempt to match a glob pattern - long users = i->second->GetUserCounter(); + long users = chan->GetUserCounter(); bool too_few = (minusers && (users <= minusers)); bool too_many = (maxusers && (users >= maxusers)); @@ -79,30 +84,31 @@ CmdResult CommandList::Handle (const std::vector& parameters, User if (too_many || too_few) continue; - if (parameters.size() && !parameters[0].empty() && (parameters[0][0] != '<' && parameters[0][0] != '>')) + if (match_name_topic) { - if (!InspIRCd::Match(i->second->name, parameters[0]) && !InspIRCd::Match(i->second->topic, parameters[0])) + if (!InspIRCd::Match(chan->name, parameters[0]) && !InspIRCd::Match(chan->topic, parameters[0])) continue; } // if the channel is not private/secret, OR the user is on the channel anyway - bool n = (i->second->HasUser(user) || user->HasPrivPermission("channels/auspex")); + bool n = (has_privs || chan->HasUser(user)); - if (!n && i->second->IsModeSet(privatemode)) - { - /* Channel is +p and user is outside/not privileged */ - user->WriteNumeric(RPL_LIST, "* %ld :", users); - } - else + // If we're not in the channel and +s is set on it, we want to ignore it + if ((n) || (!chan->IsModeSet(secretmode))) { - if (n || !i->second->IsModeSet(secretmode)) + if ((!n) && (chan->IsModeSet(privatemode))) + { + // Channel is private (+p) and user is outside/not privileged + user->WriteNumeric(RPL_LIST, '*', users, ""); + } + else { /* User is in the channel/privileged, channel is not +s */ - user->WriteNumeric(RPL_LIST, "%s %ld :[+%s] %s",i->second->name.c_str(),users,i->second->ChanModes(n),i->second->topic.c_str()); + user->WriteNumeric(RPL_LIST, chan->name, users, InspIRCd::Format("[+%s] %s", chan->ChanModes(n), chan->topic.c_str())); } } } - user->WriteNumeric(RPL_LISTEND, ":End of channel list."); + user->WriteNumeric(RPL_LISTEND, "End of channel list."); return CMD_SUCCESS; }