diff options
author | Adam <Adam@anope.org> | 2013-11-12 06:51:31 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-11-12 06:51:31 -0500 |
commit | 6c7a3ceb6c674a9af09da955ee0238e9291cf29a (patch) | |
tree | c9fd79d5814685e43f5d9ade75cad5f11da06364 /src/commands | |
parent | 407f8ef1391e5d09e99e0abfc570389decc3ce2d (diff) |
Use WriteNumeric() everywhere we send numerics and include the user's nick automatically
Diffstat (limited to 'src/commands')
26 files changed, 97 insertions, 97 deletions
diff --git a/src/commands/cmd_away.cpp b/src/commands/cmd_away.cpp index de0969af4..6a95212e6 100644 --- a/src/commands/cmd_away.cpp +++ b/src/commands/cmd_away.cpp @@ -60,7 +60,7 @@ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User user->awaytime = ServerInstance->Time(); user->awaymsg.assign(parameters[0], 0, ServerInstance->Config->Limits.MaxAway); - user->WriteNumeric(RPL_NOWAWAY, "%s :You have been marked as being away",user->nick.c_str()); + user->WriteNumeric(RPL_NOWAWAY, ":You have been marked as being away"); } else { @@ -70,7 +70,7 @@ CmdResult CommandAway::Handle (const std::vector<std::string>& parameters, User return CMD_FAILURE; user->awaymsg.clear(); - user->WriteNumeric(RPL_UNAWAY, "%s :You are no longer marked as being away",user->nick.c_str()); + user->WriteNumeric(RPL_UNAWAY, ":You are no longer marked as being away"); } return CMD_SUCCESS; diff --git a/src/commands/cmd_commands.cpp b/src/commands/cmd_commands.cpp index 99acdfe96..190c883bd 100644 --- a/src/commands/cmd_commands.cpp +++ b/src/commands/cmd_commands.cpp @@ -60,7 +60,7 @@ CmdResult CommandCommands::Handle (const std::vector<std::string>&, User *user) sort(list.begin(), list.end()); for(unsigned int i=0; i < list.size(); i++) user->Write(list[i]); - user->WriteNumeric(RPL_COMMANDSEND, "%s :End of COMMANDS list",user->nick.c_str()); + user->WriteNumeric(RPL_COMMANDSEND, ":End of COMMANDS list"); return CMD_SUCCESS; } diff --git a/src/commands/cmd_invite.cpp b/src/commands/cmd_invite.cpp index dabc51aee..2e32d99b0 100644 --- a/src/commands/cmd_invite.cpp +++ b/src/commands/cmd_invite.cpp @@ -72,19 +72,19 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use if ((!c) || (!u) || (u->registered != REG_ALL)) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), c ? parameters[0].c_str() : parameters[1].c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c ? parameters[0].c_str() : parameters[1].c_str()); return CMD_FAILURE; } if ((IS_LOCAL(user)) && (!c->HasUser(user))) { - user->WriteNumeric(ERR_NOTONCHANNEL, "%s %s :You're not on that channel!",user->nick.c_str(), c->name.c_str()); + user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", c->name.c_str()); return CMD_FAILURE; } if (c->HasUser(u)) { - user->WriteNumeric(ERR_USERONCHANNEL, "%s %s %s :is already on channel",user->nick.c_str(),u->nick.c_str(),c->name.c_str()); + user->WriteNumeric(ERR_USERONCHANNEL, "%s %s :is already on channel", u->nick.c_str(), c->name.c_str()); return CMD_FAILURE; } @@ -103,8 +103,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 %s :You must be a channel %soperator", - user->nick.c_str(), c->name.c_str(), (mh && mh->name == "halfop" ? "half-" : "")); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator", + c->name.c_str(), (mh && mh->name == "halfop" ? "half-" : "")); return CMD_FAILURE; } } @@ -117,7 +117,7 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use } if (IS_LOCAL(user)) - user->WriteNumeric(RPL_INVITING, "%s %s %s",user->nick.c_str(),u->nick.c_str(),c->name.c_str()); + user->WriteNumeric(RPL_INVITING, "%s %s", u->nick.c_str(),c->name.c_str()); if (ServerInstance->Config->AnnounceInvites != ServerConfig::INVITE_ANNOUNCE_NONE) { @@ -152,9 +152,9 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use InviteList& il = IS_LOCAL(user)->GetInviteList(); for (InviteList::const_iterator i = il.begin(); i != il.end(); ++i) { - user->WriteNumeric(RPL_INVITELIST, "%s :%s",user->nick.c_str(), (*i)->chan->name.c_str()); + user->WriteNumeric(RPL_INVITELIST, ":%s", (*i)->chan->name.c_str()); } - user->WriteNumeric(RPL_ENDOFINVITELIST, "%s :End of INVITE list",user->nick.c_str()); + user->WriteNumeric(RPL_ENDOFINVITELIST, ":End of INVITE list"); } return CMD_SUCCESS; } diff --git a/src/commands/cmd_join.cpp b/src/commands/cmd_join.cpp index 9e2678b5d..1c90e4a2b 100644 --- a/src/commands/cmd_join.cpp +++ b/src/commands/cmd_join.cpp @@ -73,7 +73,7 @@ CmdResult CommandJoin::HandleLocal(const std::vector<std::string>& parameters, L } } - user->WriteNumeric(ERR_NOSUCHCHANNEL, "%s %s :Invalid channel name",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :Invalid channel name", parameters[0].c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_kick.cpp b/src/commands/cmd_kick.cpp index b59eec030..10022d105 100644 --- a/src/commands/cmd_kick.cpp +++ b/src/commands/cmd_kick.cpp @@ -62,7 +62,7 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User if (!u || !c) { - user->WriteServ( "401 %s %s :No such nick/channel", user->nick.c_str(), u ? parameters[0].c_str() : parameters[1].c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", u ? parameters[0].c_str() : parameters[1].c_str()); return CMD_FAILURE; } @@ -72,13 +72,13 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User srcmemb = c->GetUser(user); if (!srcmemb) { - user->WriteServ( "442 %s %s :You're not on that channel!", user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", parameters[0].c_str()); return CMD_FAILURE; } if (ServerInstance->ULine(u->server)) { - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You may not kick a u-lined client", user->nick.c_str(), c->name.c_str()); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You may not kick a u-lined client", c->name.c_str()); return CMD_FAILURE; } } diff --git a/src/commands/cmd_kill.cpp b/src/commands/cmd_kill.cpp index dddfe4291..1b6f02128 100644 --- a/src/commands/cmd_kill.cpp +++ b/src/commands/cmd_kill.cpp @@ -163,7 +163,7 @@ CmdResult CommandKill::Handle (const std::vector<std::string>& parameters, User } else { - user->WriteServ( "401 %s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_links.cpp b/src/commands/cmd_links.cpp index f4152ebc5..a81741150 100644 --- a/src/commands/cmd_links.cpp +++ b/src/commands/cmd_links.cpp @@ -44,8 +44,8 @@ class CommandLinks : public Command */ CmdResult CommandLinks::Handle (const std::vector<std::string>&, User *user) { - user->WriteNumeric(364, "%s %s %s :0 %s",user->nick.c_str(),ServerInstance->Config->ServerName.c_str(),ServerInstance->Config->ServerName.c_str(),ServerInstance->Config->ServerDesc.c_str()); - user->WriteNumeric(365, "%s * :End of /LINKS list.",user->nick.c_str()); + user->WriteNumeric(RPL_LINKS, "%s %s :0 %s", ServerInstance->Config->ServerName.c_str(),ServerInstance->Config->ServerName.c_str(),ServerInstance->Config->ServerDesc.c_str()); + user->WriteNumeric(RPL_ENDOFLINKS, "* :End of /LINKS list."); return CMD_SUCCESS; } diff --git a/src/commands/cmd_list.cpp b/src/commands/cmd_list.cpp index 5962e2547..f840c9ab0 100644 --- a/src/commands/cmd_list.cpp +++ b/src/commands/cmd_list.cpp @@ -57,7 +57,7 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User { int minusers = 0, maxusers = 0; - user->WriteNumeric(321, "%s Channel :Users Name",user->nick.c_str()); + user->WriteNumeric(RPL_LISTSTART, "Channel :Users Name"); /* Work around mIRC suckyness. YOU SUCK, KHALED! */ if (parameters.size() == 1) @@ -95,18 +95,18 @@ CmdResult CommandList::Handle (const std::vector<std::string>& parameters, User if (!n && i->second->IsModeSet(privatemode)) { /* Channel is +p and user is outside/not privileged */ - user->WriteNumeric(322, "%s * %ld :",user->nick.c_str(), users); + user->WriteNumeric(RPL_LIST, "* %ld :", users); } else { if (n || !i->second->IsModeSet(secretmode)) { /* User is in the channel/privileged, channel is not +s */ - user->WriteNumeric(322, "%s %s %ld :[+%s] %s",user->nick.c_str(),i->second->name.c_str(),users,i->second->ChanModes(n),i->second->topic.c_str()); + 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(323, "%s :End of channel list.",user->nick.c_str()); + user->WriteNumeric(RPL_LISTEND, ":End of channel list."); return CMD_SUCCESS; } diff --git a/src/commands/cmd_loadmodule.cpp b/src/commands/cmd_loadmodule.cpp index 379e597e4..d49611659 100644 --- a/src/commands/cmd_loadmodule.cpp +++ b/src/commands/cmd_loadmodule.cpp @@ -47,12 +47,12 @@ CmdResult CommandLoadmodule::Handle (const std::vector<std::string>& parameters, if (ServerInstance->Modules->Load(parameters[0])) { ServerInstance->SNO->WriteGlobalSno('a', "NEW MODULE: %s loaded %s",user->nick.c_str(), parameters[0].c_str()); - user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module successfully loaded.", parameters[0].c_str()); return CMD_SUCCESS; } else { - user->WriteNumeric(974, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(ERR_CANTLOADMODULE, "%s :%s", parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); return CMD_FAILURE; } } diff --git a/src/commands/cmd_lusers.cpp b/src/commands/cmd_lusers.cpp index 63ce032d1..37b193e66 100644 --- a/src/commands/cmd_lusers.cpp +++ b/src/commands/cmd_lusers.cpp @@ -88,19 +88,19 @@ CmdResult CommandLusers::Handle (const std::vector<std::string>&, User *user) counters.UpdateMaxUsers(); - user->WriteNumeric(251, "%s :There are %d users and %d invisible on %d servers",user->nick.c_str(), + user->WriteNumeric(RPL_LUSERCLIENT, ":There are %d users and %d invisible on %d servers", n_users - counters.invisible, counters.invisible, n_serv); if (ServerInstance->Users->OperCount()) - user->WriteNumeric(252, "%s %d :operator(s) online",user->nick.c_str(),ServerInstance->Users->OperCount()); + user->WriteNumeric(RPL_LUSEROP, "%d :operator(s) online", ServerInstance->Users->OperCount()); if (ServerInstance->Users->UnregisteredUserCount()) - user->WriteNumeric(253, "%s %d :unknown connections",user->nick.c_str(),ServerInstance->Users->UnregisteredUserCount()); + user->WriteNumeric(RPL_LUSERUNKNOWN, "%d :unknown connections", ServerInstance->Users->UnregisteredUserCount()); - user->WriteNumeric(254, "%s %ld :channels formed",user->nick.c_str(),ServerInstance->ChannelCount()); - user->WriteNumeric(255, "%s :I have %d clients and %d servers",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),n_local_servs); - user->WriteNumeric(265, "%s :Current Local Users: %d Max: %d", user->nick.c_str(), ServerInstance->Users->LocalUserCount(), counters.max_local); - user->WriteNumeric(266, "%s :Current Global Users: %d Max: %d", user->nick.c_str(), n_users, counters.max_global); + user->WriteNumeric(RPL_LUSERCHANNELS, "%ld :channels formed", ServerInstance->ChannelCount()); + user->WriteNumeric(RPL_LUSERME, ":I have %d clients and %d servers", ServerInstance->Users->LocalUserCount(),n_local_servs); + user->WriteNumeric(RPL_LOCALUSERS, ":Current Local Users: %d Max: %d", ServerInstance->Users->LocalUserCount(), counters.max_local); + user->WriteNumeric(RPL_GLOBALUSERS, ":Current Global Users: %d Max: %d", n_users, counters.max_global); return CMD_SUCCESS; } diff --git a/src/commands/cmd_names.cpp b/src/commands/cmd_names.cpp index c74d18c23..206b1ccaa 100644 --- a/src/commands/cmd_names.cpp +++ b/src/commands/cmd_names.cpp @@ -56,7 +56,7 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User if (!parameters.size()) { - user->WriteNumeric(366, "%s * :End of /NAMES list.",user->nick.c_str()); + user->WriteNumeric(RPL_ENDOFNAMES, "* :End of /NAMES list."); return CMD_SUCCESS; } @@ -68,14 +68,14 @@ CmdResult CommandNames::Handle (const std::vector<std::string>& parameters, User { if ((c->IsModeSet(secretmode)) && (!c->HasUser(user))) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name.c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c->name.c_str()); return CMD_FAILURE; } c->UserList(user); } else { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); } return CMD_SUCCESS; diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp index e58aab986..26061490d 100644 --- a/src/commands/cmd_nick.cpp +++ b/src/commands/cmd_nick.cpp @@ -58,7 +58,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User if (newnick.empty()) { - user->WriteNumeric(432, "%s * :Erroneous Nickname", oldnick.c_str()); + user->WriteNumeric(ERR_ERRONEUSNICKNAME, "* :Erroneous Nickname"); return CMD_FAILURE; } @@ -68,7 +68,7 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User } else if (!ServerInstance->IsNick(newnick)) { - user->WriteNumeric(432, "%s %s :Erroneous Nickname", user->nick.c_str(),newnick.c_str()); + user->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Erroneous Nickname", newnick.c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_oper.cpp b/src/commands/cmd_oper.cpp index e1018f805..5094fae22 100644 --- a/src/commands/cmd_oper.cpp +++ b/src/commands/cmd_oper.cpp @@ -76,7 +76,7 @@ CmdResult CommandOper::HandleLocal(const std::vector<std::string>& parameters, L fields.append("hosts"); // tell them they suck, and lag them up to help prevent brute-force attacks - user->WriteNumeric(491, "%s :Invalid oper credentials",user->nick.c_str()); + user->WriteNumeric(ERR_NOOPERHOST, ":Invalid oper credentials"); user->CommandFloodPenalty += 10000; ServerInstance->SNO->WriteGlobalSno('o', "WARNING! Failed oper attempt by %s using login '%s': The following fields do not match: %s", user->GetFullRealHost().c_str(), parameters[0].c_str(), fields.c_str()); diff --git a/src/commands/cmd_part.cpp b/src/commands/cmd_part.cpp index adf9da727..83aab1d82 100644 --- a/src/commands/cmd_part.cpp +++ b/src/commands/cmd_part.cpp @@ -72,7 +72,7 @@ CmdResult CommandPart::Handle (const std::vector<std::string>& parameters, User } else { - user->WriteServ( "401 %s %s :No such channel", user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); return CMD_FAILURE; } diff --git a/src/commands/cmd_pass.cpp b/src/commands/cmd_pass.cpp index f082a4ce8..56e52425e 100644 --- a/src/commands/cmd_pass.cpp +++ b/src/commands/cmd_pass.cpp @@ -46,7 +46,7 @@ CmdResult CommandPass::HandleLocal(const std::vector<std::string>& parameters, L // Check to make sure they haven't registered -- Fix by FCS if (user->registered == REG_ALL) { - user->WriteNumeric(ERR_ALREADYREGISTERED, "%s :You may not reregister",user->nick.c_str()); + user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister"); return CMD_FAILURE; } user->password = parameters[0]; diff --git a/src/commands/cmd_privmsg.cpp b/src/commands/cmd_privmsg.cpp index 5a8e23e9b..79437432f 100644 --- a/src/commands/cmd_privmsg.cpp +++ b/src/commands/cmd_privmsg.cpp @@ -112,13 +112,13 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para { if (chan->IsModeSet(noextmsgmode) && !chan->HasUser(user)) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (no external messages)", user->nick.c_str(), chan->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (no external messages)", chan->name.c_str()); return CMD_FAILURE; } if (chan->IsModeSet(moderatedmode)) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (+m)", chan->name.c_str()); return CMD_FAILURE; } @@ -126,7 +126,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para { if (chan->IsBanned(user)) { - user->WriteNumeric(404, "%s %s :Cannot send to channel (you're banned)", user->nick.c_str(), chan->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str()); return CMD_FAILURE; } } @@ -143,7 +143,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para /* Check again, a module may have zapped the input string */ if (temp.empty()) { - user->WriteNumeric(412, "%s :No text to send", user->nick.c_str()); + user->WriteNumeric(ERR_NOTEXTTOSEND, ":No text to send"); return CMD_FAILURE; } @@ -170,7 +170,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para else { /* no such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel", user->nick.c_str(), target); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", target); return CMD_FAILURE; } return CMD_SUCCESS; @@ -191,7 +191,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para if (dest && strcasecmp(dest->server.c_str(), targetserver + 1)) { /* Incorrect server for user */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); return CMD_FAILURE; } } @@ -205,14 +205,14 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para { if (parameters[1].empty()) { - user->WriteNumeric(412, "%s :No text to send", user->nick.c_str()); + user->WriteNumeric(ERR_NOTEXTTOSEND, ":No text to send"); return CMD_FAILURE; } if ((dest->IsAway()) && (mt == MSG_PRIVMSG)) { /* auto respond with aweh msg */ - user->WriteNumeric(301, "%s %s :%s", user->nick.c_str(), dest->nick.c_str(), dest->awaymsg.c_str()); + user->WriteNumeric(RPL_AWAY, "%s :%s", dest->nick.c_str(), dest->awaymsg.c_str()); } ModResult MOD_RESULT; @@ -237,7 +237,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para else { /* no such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); return CMD_FAILURE; } return CMD_SUCCESS; diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp index 441ddbd2a..a08ba1ba5 100644 --- a/src/commands/cmd_rehash.cpp +++ b/src/commands/cmd_rehash.cpp @@ -79,8 +79,8 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use ServerInstance->SNO->WriteGlobalSno('a', m); if (IS_LOCAL(user)) - user->WriteNumeric(RPL_REHASHING, "%s %s :Rehashing", - user->nick.c_str(),ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str())); + user->WriteNumeric(RPL_REHASHING, "%s :Rehashing", + ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str())); else ServerInstance->PI->SendUserNotice(user, std::string("*** Rehashing server ") + ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str())); diff --git a/src/commands/cmd_reloadmodule.cpp b/src/commands/cmd_reloadmodule.cpp index 81ecce1cb..6ce7358da 100644 --- a/src/commands/cmd_reloadmodule.cpp +++ b/src/commands/cmd_reloadmodule.cpp @@ -48,8 +48,8 @@ class ReloadModuleWorker : public HandlerBase1<void, bool> name.c_str(), result ? "" : "un"); User* user = ServerInstance->FindNick(uid); if (user) - user->WriteNumeric(975, "%s %s :Module %ssuccessfully reloaded.", - user->nick.c_str(), name.c_str(), result ? "" : "un"); + user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %ssuccessfully reloaded.", + name.c_str(), result ? "" : "un"); ServerInstance->GlobalCulls.AddItem(this); } }; @@ -58,8 +58,8 @@ CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameter { if (parameters[0] == "cmd_reloadmodule.so") { - user->WriteNumeric(975, "%s %s :You cannot reload cmd_reloadmodule.so (unload and load it)", - user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(RPL_LOADEDMODULE, "%s :You cannot reload cmd_reloadmodule.so (unload and load it)", + parameters[0].c_str()); return CMD_FAILURE; } @@ -71,7 +71,7 @@ CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameter } else { - user->WriteNumeric(975, "%s %s :Could not find module by that name", user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(RPL_LOADEDMODULE, "%s :Could not find module by that name", parameters[0].c_str()); return CMD_FAILURE; } } diff --git a/src/commands/cmd_server.cpp b/src/commands/cmd_server.cpp index d54eca392..08c221584 100644 --- a/src/commands/cmd_server.cpp +++ b/src/commands/cmd_server.cpp @@ -44,11 +44,11 @@ CmdResult CommandServer::Handle (const std::vector<std::string>&, User *user) { if (user->registered == REG_ALL) { - user->WriteNumeric(ERR_ALREADYREGISTERED, "%s :You are already registered. (Perhaps your IRC client does not have a /SERVER command).",user->nick.c_str()); + user->WriteNumeric(ERR_ALREADYREGISTERED, ":You are already registered. (Perhaps your IRC client does not have a /SERVER command)."); } else { - user->WriteNumeric(ERR_NOTREGISTERED, "%s :You may not register as a server (servers have separate ports from clients, change your config)",name.c_str()); + user->WriteNumeric(ERR_NOTREGISTERED, ":You may not register as a server (servers have separate ports from clients, change your config)"); } return CMD_FAILURE; } diff --git a/src/commands/cmd_topic.cpp b/src/commands/cmd_topic.cpp index 8f5979865..38982a7a2 100644 --- a/src/commands/cmd_topic.cpp +++ b/src/commands/cmd_topic.cpp @@ -58,7 +58,7 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, Channel* c = ServerInstance->FindChan(parameters[0]); if (!c) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); return CMD_FAILURE; } @@ -68,18 +68,18 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, { if ((c->IsModeSet(secretmode)) && (!c->HasUser(user))) { - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), c->name.c_str()); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", c->name.c_str()); return CMD_FAILURE; } if (c->topic.length()) { - user->WriteNumeric(332, "%s %s :%s", user->nick.c_str(), c->name.c_str(), c->topic.c_str()); - user->WriteNumeric(333, "%s %s %s %lu", user->nick.c_str(), c->name.c_str(), c->setby.c_str(), (unsigned long)c->topicset); + user->WriteNumeric(RPL_TOPIC, "%s :%s", c->name.c_str(), c->topic.c_str()); + user->WriteNumeric(RPL_TOPICTIME, "%s %s %lu", c->name.c_str(), c->setby.c_str(), (unsigned long)c->topicset); } else { - user->WriteNumeric(RPL_NOTOPICSET, "%s %s :No topic is set.", user->nick.c_str(), c->name.c_str()); + user->WriteNumeric(RPL_NOTOPICSET, "%s :No topic is set.", c->name.c_str()); } } return CMD_SUCCESS; @@ -95,12 +95,12 @@ CmdResult CommandTopic::HandleLocal(const std::vector<std::string>& parameters, { if (!c->HasUser(user)) { - user->WriteNumeric(442, "%s %s :You're not on that channel!", user->nick.c_str(), c->name.c_str()); + user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", c->name.c_str()); return CMD_FAILURE; } if (c->IsModeSet(topiclockmode) && !ServerInstance->OnCheckExemption(user, c, "topiclock").check(c->GetPrefixValue(user) >= HALFOP_VALUE)) { - user->WriteNumeric(482, "%s %s :You do not have access to change the topic on this channel", user->nick.c_str(), c->name.c_str()); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have access to change the topic on this channel", c->name.c_str()); return CMD_FAILURE; } } diff --git a/src/commands/cmd_unloadmodule.cpp b/src/commands/cmd_unloadmodule.cpp index 29f454987..4e86d3ded 100644 --- a/src/commands/cmd_unloadmodule.cpp +++ b/src/commands/cmd_unloadmodule.cpp @@ -45,13 +45,13 @@ CmdResult CommandUnloadmodule::Handle (const std::vector<std::string>& parameter if (!ServerInstance->Config->ConfValue("security")->getBool("allowcoreunload") && InspIRCd::Match(parameters[0], "cmd_*.so", ascii_case_insensitive_map)) { - user->WriteNumeric(972, "%s %s :You cannot unload core commands!", user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :You cannot unload core commands!", parameters[0].c_str()); return CMD_FAILURE; } if (parameters[0] == "cmd_unloadmodule.so" || parameters[0] == "cmd_loadmodule.so") { - user->WriteNumeric(972, "%s %s :You cannot unload module loading commands!", user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :You cannot unload module loading commands!", parameters[0].c_str()); return CMD_FAILURE; } @@ -59,11 +59,11 @@ CmdResult CommandUnloadmodule::Handle (const std::vector<std::string>& parameter if (m && ServerInstance->Modules->Unload(m)) { ServerInstance->SNO->WriteGlobalSno('a', "MODULE UNLOADED: %s unloaded %s", user->nick.c_str(), parameters[0].c_str()); - user->WriteNumeric(973, "%s %s :Module successfully unloaded.",user->nick.c_str(), parameters[0].c_str()); + user->WriteNumeric(RPL_UNLOADEDMODULE, "%s :Module successfully unloaded.", parameters[0].c_str()); } else { - user->WriteNumeric(972, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), + user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :%s", parameters[0].c_str(), m ? ServerInstance->Modules->LastError().c_str() : "No such module"); return CMD_FAILURE; } diff --git a/src/commands/cmd_user.cpp b/src/commands/cmd_user.cpp index b4d86f07b..932e3a9b8 100644 --- a/src/commands/cmd_user.cpp +++ b/src/commands/cmd_user.cpp @@ -51,7 +51,7 @@ CmdResult CommandUser::HandleLocal(const std::vector<std::string>& parameters, L * RFC says we must use this numeric, so we do. Let's make it a little more nub friendly though. :) * -- Craig, and then w00t. */ - user->WriteNumeric(461, "%s USER :Your username is not valid",user->nick.c_str()); + user->WriteNumeric(ERR_NEEDMOREPARAMS, "USER :Your username is not valid"); return CMD_FAILURE; } else @@ -68,7 +68,7 @@ CmdResult CommandUser::HandleLocal(const std::vector<std::string>& parameters, L } else { - user->WriteNumeric(462, "%s :You may not reregister", user->nick.c_str()); + user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister"); return CMD_FAILURE; } diff --git a/src/commands/cmd_version.cpp b/src/commands/cmd_version.cpp index 9fdd9c838..8e6783b3c 100644 --- a/src/commands/cmd_version.cpp +++ b/src/commands/cmd_version.cpp @@ -43,7 +43,7 @@ class CommandVersion : public Command CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user) { std::string version = ServerInstance->GetVersionString((user->IsOper())); - user->WriteNumeric(RPL_VERSION, "%s :%s", user->nick.c_str(), version.c_str()); + user->WriteNumeric(RPL_VERSION, ":%s", version.c_str()); LocalUser *lu = IS_LOCAL(user); if (lu != NULL) { diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index 5e0e55b66..edfeeda42 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -388,7 +388,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User * /* Send the results out */ for (std::vector<std::string>::const_iterator n = whoresults.begin(); n != whoresults.end(); n++) user->WriteServ(*n); - user->WriteNumeric(315, "%s %s :End of /WHO list.",user->nick.c_str(), *parameters[0].c_str() ? parameters[0].c_str() : "*"); + user->WriteNumeric(RPL_ENDOFWHO, "%s :End of /WHO list.", *parameters[0].c_str() ? parameters[0].c_str() : "*"); // Penalize the user a bit for large queries // (add one unit of penalty per 200 results) diff --git a/src/commands/cmd_whois.cpp b/src/commands/cmd_whois.cpp index 0df6b65f0..a6a4447b9 100644 --- a/src/commands/cmd_whois.cpp +++ b/src/commands/cmd_whois.cpp @@ -82,7 +82,7 @@ void CommandWhois::SplitChanList(User* source, User* dest, const std::string& cl std::ostringstream prefix; std::string::size_type start, pos, length; - prefix << source->nick << " " << dest->nick << " :"; + prefix << dest->nick << " :"; line = prefix.str(); int namelen = ServerInstance->Config->ServerName.length() + 6; @@ -92,7 +92,7 @@ void CommandWhois::SplitChanList(User* source, User* dest, const std::string& cl if (line.length() + namelen + length - start > 510) { - ServerInstance->SendWhoisLine(source, dest, 319, "%s", line.c_str()); + ServerInstance->SendWhoisLine(source, dest, 319, line); line = prefix.str(); } @@ -109,16 +109,16 @@ void CommandWhois::SplitChanList(User* source, User* dest, const std::string& cl if (line.length() != prefix.str().length()) { - ServerInstance->SendWhoisLine(source, dest, 319, "%s", line.c_str()); + ServerInstance->SendWhoisLine(source, dest, 319, line); } } void CommandWhois::DoWhois(User* user, User* dest, unsigned long signon, unsigned long idle) { - ServerInstance->SendWhoisLine(user, dest, 311, "%s %s %s %s * :%s",user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->dhost.c_str(), dest->fullname.c_str()); + ServerInstance->SendWhoisLine(user, dest, 311, "%s %s %s * :%s", dest->nick.c_str(), dest->ident.c_str(), dest->dhost.c_str(), dest->fullname.c_str()); if (user == dest || user->HasPrivPermission("users/auspex")) { - ServerInstance->SendWhoisLine(user, dest, 378, "%s %s :is connecting from %s@%s %s", user->nick.c_str(), dest->nick.c_str(), dest->ident.c_str(), dest->host.c_str(), dest->GetIPString().c_str()); + ServerInstance->SendWhoisLine(user, dest, 378, "%s :is connecting from %s@%s %s", dest->nick.c_str(), dest->ident.c_str(), dest->host.c_str(), dest->GetIPString().c_str()); } std::string cl = ChannelList(user, dest, false); @@ -134,42 +134,42 @@ void CommandWhois::DoWhois(User* user, User* dest, unsigned long signon, unsigne std::string scl = ChannelList(user, dest, true); if (scl.length()) { - ServerInstance->SendWhoisLine(user, dest, 336, "%s %s :is on private/secret channels:",user->nick.c_str(), dest->nick.c_str()); + ServerInstance->SendWhoisLine(user, dest, 336, "%s :is on private/secret channels:", dest->nick.c_str()); SplitChanList(user, dest, scl); } } if (user != dest && !ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")) { - ServerInstance->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick.c_str(), dest->nick.c_str(), ServerInstance->Config->HideWhoisServer.c_str(), ServerInstance->Config->Network.c_str()); + ServerInstance->SendWhoisLine(user, dest, 312, "%s %s :%s", dest->nick.c_str(), ServerInstance->Config->HideWhoisServer.c_str(), ServerInstance->Config->Network.c_str()); } else { std::string serverdesc = ServerInstance->GetServerDescription(dest->server); - ServerInstance->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick.c_str(), dest->nick.c_str(), dest->server.c_str(), serverdesc.c_str()); + ServerInstance->SendWhoisLine(user, dest, 312, "%s %s :%s", dest->nick.c_str(), dest->server.c_str(), serverdesc.c_str()); } if (dest->IsAway()) { - ServerInstance->SendWhoisLine(user, dest, 301, "%s %s :%s",user->nick.c_str(), dest->nick.c_str(), dest->awaymsg.c_str()); + ServerInstance->SendWhoisLine(user, dest, 301, "%s :%s", dest->nick.c_str(), dest->awaymsg.c_str()); } if (dest->IsOper()) { if (ServerInstance->Config->GenericOper) - ServerInstance->SendWhoisLine(user, dest, 313, "%s %s :is an IRC operator",user->nick.c_str(), dest->nick.c_str()); + ServerInstance->SendWhoisLine(user, dest, 313, "%s :is an IRC operator", dest->nick.c_str()); else - ServerInstance->SendWhoisLine(user, dest, 313, "%s %s :is %s %s on %s",user->nick.c_str(), dest->nick.c_str(), (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"),dest->oper->name.c_str(), ServerInstance->Config->Network.c_str()); + ServerInstance->SendWhoisLine(user, dest, 313, "%s :is %s %s on %s", dest->nick.c_str(), (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"),dest->oper->name.c_str(), ServerInstance->Config->Network.c_str()); } if (user == dest || user->HasPrivPermission("users/auspex")) { if (dest->IsModeSet(snomaskmode)) { - ServerInstance->SendWhoisLine(user, dest, 379, "%s %s :is using modes +%s %s", user->nick.c_str(), dest->nick.c_str(), dest->FormatModes(), snomaskmode->GetUserParameter(dest).c_str()); + ServerInstance->SendWhoisLine(user, dest, 379, "%s :is using modes +%s %s", dest->nick.c_str(), dest->FormatModes(), snomaskmode->GetUserParameter(dest).c_str()); } else { - ServerInstance->SendWhoisLine(user, dest, 379, "%s %s :is using modes +%s", user->nick.c_str(), dest->nick.c_str(), dest->FormatModes()); + ServerInstance->SendWhoisLine(user, dest, 379, "%s :is using modes +%s", dest->nick.c_str(), dest->FormatModes()); } } @@ -181,10 +181,10 @@ void CommandWhois::DoWhois(User* user, User* dest, unsigned long signon, unsigne */ if ((idle) || (signon)) { - ServerInstance->SendWhoisLine(user, dest, 317, "%s %s %lu %lu :seconds idle, signon time",user->nick.c_str(), dest->nick.c_str(), idle, signon); + ServerInstance->SendWhoisLine(user, dest, 317, "%s %lu %lu :seconds idle, signon time", dest->nick.c_str(), idle, signon); } - ServerInstance->SendWhoisLine(user, dest, 318, "%s %s :End of /WHOIS list.",user->nick.c_str(), dest->nick.c_str()); + ServerInstance->SendWhoisLine(user, dest, 318, "%s :End of /WHOIS list.", dest->nick.c_str()); } CmdResult CommandWhois::HandleRemote(const std::vector<std::string>& parameters, RemoteUser* target) @@ -242,8 +242,8 @@ CmdResult CommandWhois::HandleLocal(const std::vector<std::string>& parameters, else { /* no such nick/channel */ - user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), !parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); - user->WriteNumeric(318, "%s %s :End of /WHOIS list.",user->nick.c_str(), !parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); + user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", !parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); + user->WriteNumeric(RPL_ENDOFWHOIS, "%s :End of /WHOIS list.", !parameters[userindex].empty() ? parameters[userindex].c_str() : "*"); return CMD_FAILURE; } diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp index 175b2bdf3..bdd16b520 100644 --- a/src/commands/cmd_whowas.cpp +++ b/src/commands/cmd_whowas.cpp @@ -36,7 +36,7 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use /* if whowas disabled in config */ if (this->GroupSize == 0 || this->MaxGroups == 0) { - user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick.c_str(),name.c_str()); + user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :This command has been disabled.", name.c_str()); return CMD_FAILURE; } @@ -44,7 +44,7 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use if (i == whowas.end()) { - user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick.c_str(),parameters[0].c_str()); + user->WriteNumeric(ERR_WASNOSUCHNICK, "%s :There was no such nickname", parameters[0].c_str()); } else { @@ -55,25 +55,25 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use { WhoWasGroup* u = *ux; - user->WriteNumeric(314, "%s %s %s %s * :%s",user->nick.c_str(),parameters[0].c_str(), + user->WriteNumeric(RPL_WHOWASUSER, "%s %s %s * :%s", parameters[0].c_str(), u->ident.c_str(),u->dhost.c_str(),u->gecos.c_str()); if (user->HasPrivPermission("users/auspex")) - user->WriteNumeric(379, "%s %s :was connecting from *@%s", - user->nick.c_str(), parameters[0].c_str(), u->host.c_str()); + user->WriteNumeric(RPL_WHOWASIP, "%s :was connecting from *@%s", + parameters[0].c_str(), u->host.c_str()); std::string signon = ServerInstance->TimeString(u->signon); bool hide_server = (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")); - user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(), parameters[0].c_str(), (hide_server ? ServerInstance->Config->HideWhoisServer.c_str() : u->server.c_str()), signon.c_str()); + user->WriteNumeric(RPL_WHOISSERVER, "%s %s :%s", parameters[0].c_str(), (hide_server ? ServerInstance->Config->HideWhoisServer.c_str() : u->server.c_str()), signon.c_str()); } } else { - user->WriteNumeric(406, "%s %s :There was no such nickname",user->nick.c_str(),parameters[0].c_str()); + user->WriteNumeric(ERR_WASNOSUCHNICK, "%s :There was no such nickname", parameters[0].c_str()); } } - user->WriteNumeric(369, "%s %s :End of WHOWAS",user->nick.c_str(),parameters[0].c_str()); + user->WriteNumeric(RPL_ENDOFWHOWAS, "%s :End of WHOWAS", parameters[0].c_str()); return CMD_SUCCESS; } |