diff options
Diffstat (limited to 'src/coremods/core_channel')
-rw-r--r-- | src/coremods/core_channel/cmd_invite.cpp | 18 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_join.cpp | 2 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_kick.cpp | 12 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_names.cpp | 21 | ||||
-rw-r--r-- | src/coremods/core_channel/cmd_topic.cpp | 14 |
5 files changed, 33 insertions, 34 deletions
diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp index c1f1b00c7..a1319ebc0 100644 --- a/src/coremods/core_channel/cmd_invite.cpp +++ b/src/coremods/core_channel/cmd_invite.cpp @@ -58,7 +58,7 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use if ((!c) || (!u) || (u->registered != REG_ALL)) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c ? parameters[0].c_str() : parameters[1].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(c ? parameters[0] : parameters[1])); return CMD_FAILURE; } @@ -77,13 +77,13 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use if ((IS_LOCAL(user)) && (!c->HasUser(user))) { - user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", c->name.c_str()); + user->WriteNumeric(ERR_NOTONCHANNEL, c->name, "You're not on that channel!"); return CMD_FAILURE; } if (c->HasUser(u)) { - user->WriteNumeric(ERR_USERONCHANNEL, "%s %s :is already on channel", u->nick.c_str(), c->name.c_str()); + user->WriteNumeric(ERR_USERONCHANNEL, u->nick, c->name, "is already on channel"); return CMD_FAILURE; } @@ -102,8 +102,8 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use { // Check whether halfop mode is available and phrase error message accordingly ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL); - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator", - c->name.c_str(), (mh && mh->name == "halfop" ? "half-" : "")); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, InspIRCd::Format("You must be a channel %soperator", + (mh && mh->name == "halfop" ? "half-" : ""))); return CMD_FAILURE; } } @@ -117,9 +117,9 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use if (IS_LOCAL(user)) { - user->WriteNumeric(RPL_INVITING, "%s %s", u->nick.c_str(),c->name.c_str()); + user->WriteNumeric(RPL_INVITING, u->nick, c->name); if (u->IsAway()) - user->WriteNumeric(RPL_AWAY, "%s :%s", u->nick.c_str(), u->awaymsg.c_str()); + user->WriteNumeric(RPL_AWAY, u->nick, u->awaymsg); } char prefix = 0; @@ -161,9 +161,9 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use if (list) { for (Invite::List::const_iterator i = list->begin(); i != list->end(); ++i) - user->WriteNumeric(RPL_INVITELIST, ":%s", (*i)->chan->name.c_str()); + user->WriteNumeric(RPL_INVITELIST, (*i)->chan->name); } - user->WriteNumeric(RPL_ENDOFINVITELIST, ":End of INVITE list"); + user->WriteNumeric(RPL_ENDOFINVITELIST, "End of INVITE list"); } return CMD_SUCCESS; } diff --git a/src/coremods/core_channel/cmd_join.cpp b/src/coremods/core_channel/cmd_join.cpp index 1945bf52e..06e203ead 100644 --- a/src/coremods/core_channel/cmd_join.cpp +++ b/src/coremods/core_channel/cmd_join.cpp @@ -55,6 +55,6 @@ CmdResult CommandJoin::HandleLocal(const std::vector<std::string>& parameters, L } } - user->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :Invalid channel name", parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHCHANNEL, parameters[0], "Invalid channel name"); return CMD_FAILURE; } diff --git a/src/coremods/core_channel/cmd_kick.cpp b/src/coremods/core_channel/cmd_kick.cpp index 44f511bc1..7f8a8a329 100644 --- a/src/coremods/core_channel/cmd_kick.cpp +++ b/src/coremods/core_channel/cmd_kick.cpp @@ -44,7 +44,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User if ((!u) || (!c) || (u->registered != REG_ALL)) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c ? parameters[1].c_str() : parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(c ? parameters[1] : parameters[0])); return CMD_FAILURE; } @@ -54,13 +54,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 +68,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; @@ -110,8 +110,8 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User if (them < req) { - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator", - c->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; } } diff --git a/src/coremods/core_channel/cmd_names.cpp b/src/coremods/core_channel/cmd_names.cpp index 986dbe018..53934b5e3 100644 --- a/src/coremods/core_channel/cmd_names.cpp +++ b/src/coremods/core_channel/cmd_names.cpp @@ -38,7 +38,7 @@ CmdResult CommandNames::HandleLocal(const std::vector<std::string>& parameters, if (!parameters.size()) { - user->WriteNumeric(RPL_ENDOFNAMES, "* :End of /NAMES list."); + user->WriteNumeric(RPL_ENDOFNAMES, '*', "End of /NAMES list."); return CMD_SUCCESS; } @@ -62,24 +62,23 @@ CmdResult CommandNames::HandleLocal(const std::vector<std::string>& parameters, } } - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible) { - Numeric::Builder<' '> reply(user, RPL_NAMREPLY, false); - std::string& list = reply.GetNumeric(); + Numeric::Builder<' '> reply(user, RPL_NAMREPLY, false, chan->name.size() + 4); + Numeric::Numeric& numeric = reply.GetNumeric(); if (chan->IsModeSet(secretmode)) - list.push_back('@'); + numeric.push(std::string(1, '@')); else if (chan->IsModeSet(privatemode)) - list.push_back('*'); + numeric.push(std::string(1, '*')); else - list.push_back('='); + numeric.push(std::string(1, '=')); - list.push_back(' '); - list.append(chan->name).append(" :"); - reply.SaveBeginPos(); + numeric.push(chan->name); + numeric.push(std::string()); std::string prefixlist; std::string nick; @@ -111,5 +110,5 @@ void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible } reply.Flush(); - user->WriteNumeric(RPL_ENDOFNAMES, "%s :End of /NAMES list.", chan->name.c_str()); + user->WriteNumeric(RPL_ENDOFNAMES, chan->name, "End of /NAMES list."); } diff --git a/src/coremods/core_channel/cmd_topic.cpp b/src/coremods/core_channel/cmd_topic.cpp index 8d65d764a..b42148939 100644 --- a/src/coremods/core_channel/cmd_topic.cpp +++ b/src/coremods/core_channel/cmd_topic.cpp @@ -37,7 +37,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, Channel* c = ServerInstance->FindChan(parameters[0]); if (!c) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } @@ -45,7 +45,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, { if ((c->IsModeSet(secretmode)) && (!c->HasUser(user))) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c->name.c_str()); + user->WriteNumeric(Numerics::NoSuchNick(c->name)); return CMD_FAILURE; } @@ -55,7 +55,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, } else { - user->WriteNumeric(RPL_NOTOPICSET, "%s :No topic is set.", c->name.c_str()); + user->WriteNumeric(RPL_NOTOPICSET, c->name, "No topic is set."); } return CMD_SUCCESS; } @@ -70,12 +70,12 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, { if (!c->HasUser(user)) { - user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", c->name.c_str()); + user->WriteNumeric(ERR_NOTONCHANNEL, c->name, "You're not on that channel!"); return CMD_FAILURE; } if (c->IsModeSet(topiclockmode) && !ServerInstance->OnCheckExemption(user, c, "topiclock").check(c->GetPrefixValue(user) >= HALFOP_VALUE)) { - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have access to change the topic on this channel", c->name.c_str()); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, "You do not have access to change the topic on this channel"); return CMD_FAILURE; } } @@ -86,6 +86,6 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, void Topic::ShowTopic(LocalUser* user, Channel* chan) { - user->WriteNumeric(RPL_TOPIC, "%s :%s", chan->name.c_str(), chan->topic.c_str()); - user->WriteNumeric(RPL_TOPICTIME, "%s %s %lu", chan->name.c_str(), chan->setby.c_str(), (unsigned long)chan->topicset); + user->WriteNumeric(RPL_TOPIC, chan->name, chan->topic); + user->WriteNumeric(RPL_TOPICTIME, chan->name, chan->setby, (unsigned long)chan->topicset); } |