]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_channel/cmd_kick.cpp
Various text improvements: consistency, syntax, help and doc updates/fixes.
[user/henk/code/inspircd.git] / src / coremods / core_channel / cmd_kick.cpp
index e2fdd787797d7a2819a66a83252923ea81758bc0..77ac36a668eba376277f0e03e0faa89ea7178997 100644 (file)
 CommandKick::CommandKick(Module* parent)
        : Command(parent, "KICK", 2, 3)
 {
-       syntax = "<channel> <nick>{,<nick>} [<reason>]";
+       syntax = "<channel> <nick>[,<nick>]+ [:<reason>]";
 }
 
 /** Handle /KICK
  */
-CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User *user)
+CmdResult CommandKick::Handle(User* user, const Params& parameters)
 {
        Channel* c = ServerInstance->FindChan(parameters[0]);
        User* u;
@@ -42,9 +42,14 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
        else
                u = ServerInstance->FindNick(parameters[1]);
 
-       if ((!u) || (!c) || (u->registered != REG_ALL))
+       if (!c)
        {
-               user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c ? parameters[1].c_str() : parameters[0].c_str());
+               user->WriteNumeric(Numerics::NoSuchChannel(parameters[0]));
+               return CMD_FAILURE;
+       }
+       if ((!u) || (u->registered != REG_ALL))
+       {
+               user->WriteNumeric(Numerics::NoSuchNick(parameters[1]));
                return CMD_FAILURE;
        }
 
@@ -54,13 +59,13 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
                srcmemb = c->GetUser(user);
                if (!srcmemb)
                {
-                       user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", parameters[0].c_str());
+                       user->WriteNumeric(ERR_NOTONCHANNEL, parameters[0], "You're not on that channel!");
                        return CMD_FAILURE;
                }
 
                if (u->server->IsULine())
                {
-                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You may not kick a u-lined client", c->name.c_str());
+                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, "You may not kick a U-lined client");
                        return CMD_FAILURE;
                }
        }
@@ -68,7 +73,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
        const Channel::MemberMap::iterator victimiter = c->userlist.find(u);
        if (victimiter == c->userlist.end())
        {
-               user->WriteNumeric(ERR_USERNOTINCHANNEL, "%s %s :They are not on that channel", u->nick.c_str(), c->name.c_str());
+               user->WriteNumeric(ERR_USERNOTINCHANNEL, u->nick, c->name, "They are not on that channel");
                return CMD_FAILURE;
        }
        Membership* const memb = victimiter->second;
@@ -104,14 +109,14 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
                        for (std::string::size_type i = 0; i < memb->modes.length(); i++)
                        {
                                ModeHandler* mh = ServerInstance->Modes->FindMode(memb->modes[i], MODETYPE_CHANNEL);
-                               if (mh && mh->GetLevelRequired() > req)
-                                       req = mh->GetLevelRequired();
+                               if (mh && mh->GetLevelRequired(true) > req)
+                                       req = mh->GetLevelRequired(true);
                        }
 
                        if (them < req)
                        {
-                               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator",
-                                       this->name.c_str(), req > HALFOP_VALUE ? "" : "half-");
+                               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, InspIRCd::Format("You must be a channel %soperator",
+                                       req > HALFOP_VALUE ? "" : "half-"));
                                return CMD_FAILURE;
                        }
                }
@@ -122,7 +127,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
        return CMD_SUCCESS;
 }
 
-RouteDescriptor CommandKick::GetRouting(User* user, const std::vector<std::string>& parameters)
+RouteDescriptor CommandKick::GetRouting(User* user, const Params& parameters)
 {
        return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST);
 }