]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_list.cpp
Add User::WriteRemoteNumeric() and switch code using SendText() to send numerics...
[user/henk/code/inspircd.git] / src / coremods / core_list.cpp
index bf9d9bdaef54245da6ebe2f31c74521de3662396..67829a55edf472715d7075e5c592ede7c6f2612a 100644 (file)
@@ -53,7 +53,7 @@ CmdResult CommandList::Handle (const std::vector<std::string>& 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)
@@ -74,8 +74,10 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User
        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));
@@ -85,28 +87,29 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User
 
                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 = (has_privs || i->second->HasUser(user));
+               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;
 }