From da29af8cba49d51e53d6e68237ccbf6370b6dd1f Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Thu, 25 Feb 2016 16:12:09 +0100 Subject: [PATCH] Convert WriteNumeric() calls to pass the parameters of the numeric as method parameters --- include/isupportmanager.h | 6 +-- include/modules.h | 2 +- include/numericbuilder.h | 28 +++++----- include/users.h | 53 ++++++++++++++++++- src/channels.cpp | 10 ++-- src/command_parse.cpp | 18 +++---- src/configreader.cpp | 8 +-- src/coremods/core_channel/cmd_invite.cpp | 18 +++---- src/coremods/core_channel/cmd_join.cpp | 2 +- src/coremods/core_channel/cmd_kick.cpp | 12 ++--- src/coremods/core_channel/cmd_names.cpp | 21 ++++---- src/coremods/core_channel/cmd_topic.cpp | 14 ++--- src/coremods/core_info/cmd_commands.cpp | 2 +- src/coremods/core_info/cmd_version.cpp | 2 +- src/coremods/core_list.cpp | 8 +-- src/coremods/core_loadmodule.cpp | 13 +++-- src/coremods/core_lusers.cpp | 16 +++--- src/coremods/core_oper/cmd_kill.cpp | 2 +- src/coremods/core_oper/cmd_oper.cpp | 2 +- src/coremods/core_oper/cmd_rehash.cpp | 2 +- src/coremods/core_privmsg.cpp | 18 +++---- src/coremods/core_reloadmodule.cpp | 7 ++- src/coremods/core_stub.cpp | 8 +-- src/coremods/core_user/cmd_away.cpp | 4 +- src/coremods/core_user/cmd_mode.cpp | 10 ++-- src/coremods/core_user/cmd_nick.cpp | 6 +-- src/coremods/core_user/cmd_part.cpp | 4 +- src/coremods/core_user/cmd_user.cpp | 4 +- src/coremods/core_user/core_user.cpp | 2 +- src/coremods/core_who.cpp | 2 +- src/coremods/core_whois.cpp | 8 +-- src/coremods/core_whowas.cpp | 12 ++--- src/coremods/core_xline/core_xline.cpp | 2 +- src/listmode.cpp | 8 +-- src/mode.cpp | 23 ++++---- src/modes/umode_s.cpp | 2 +- src/modules.cpp | 2 +- src/modules/m_abbreviation.cpp | 4 +- src/modules/m_alias.cpp | 4 +- src/modules/m_allowinvite.cpp | 2 +- src/modules/m_autoop.cpp | 6 +-- src/modules/m_banredirect.cpp | 16 +++--- src/modules/m_blockcaps.cpp | 2 +- src/modules/m_blockcolor.cpp | 2 +- src/modules/m_callerid.cpp | 16 +++--- src/modules/m_cap.cpp | 2 +- src/modules/m_cban.cpp | 2 +- src/modules/m_censor.cpp | 2 +- src/modules/m_chanfilter.cpp | 12 ++--- src/modules/m_chghost.cpp | 2 +- src/modules/m_chgident.cpp | 2 +- src/modules/m_chgname.cpp | 2 +- src/modules/m_commonchans.cpp | 2 +- src/modules/m_cycle.cpp | 4 +- src/modules/m_dccallow.cpp | 30 +++++------ src/modules/m_delaymsg.cpp | 3 +- src/modules/m_denychans.cpp | 4 +- src/modules/m_dnsbl.cpp | 4 +- src/modules/m_exemptchanops.cpp | 10 ++-- src/modules/m_filter.cpp | 4 +- src/modules/m_globalload.cpp | 10 ++-- src/modules/m_helpop.cpp | 18 +++---- src/modules/m_hidelist.cpp | 2 +- src/modules/m_hideoper.cpp | 6 +-- src/modules/m_httpd_stats.cpp | 8 +-- src/modules/m_joinflood.cpp | 6 +-- src/modules/m_jumpserver.cpp | 5 +- src/modules/m_kicknorejoin.cpp | 2 +- src/modules/m_knock.cpp | 8 +-- src/modules/m_lockserv.cpp | 4 +- src/modules/m_messageflood.cpp | 4 +- src/modules/m_mlock.cpp | 3 +- src/modules/m_monitor.cpp | 4 +- src/modules/m_muteban.cpp | 2 +- src/modules/m_namedmodes.cpp | 4 +- src/modules/m_nickflood.cpp | 6 +-- src/modules/m_nicklock.cpp | 4 +- src/modules/m_noctcp.cpp | 2 +- src/modules/m_nokicks.cpp | 2 +- src/modules/m_nonicks.cpp | 4 +- src/modules/m_nonotice.cpp | 2 +- src/modules/m_ojoin.cpp | 2 +- src/modules/m_operchans.cpp | 3 +- src/modules/m_operlevels.cpp | 2 +- src/modules/m_redirect.cpp | 12 ++--- src/modules/m_regonlycreate.cpp | 2 +- src/modules/m_remove.cpp | 6 +-- src/modules/m_restrictchans.cpp | 2 +- src/modules/m_restrictmsg.cpp | 2 +- src/modules/m_sajoin.cpp | 2 +- src/modules/m_sakick.cpp | 2 +- src/modules/m_samode.cpp | 2 +- src/modules/m_sanick.cpp | 2 +- src/modules/m_sapart.cpp | 2 +- src/modules/m_saquit.cpp | 2 +- src/modules/m_sasl.cpp | 8 +-- src/modules/m_satopic.cpp | 2 +- src/modules/m_securelist.cpp | 4 +- src/modules/m_services_account.cpp | 13 +++-- src/modules/m_servprotect.cpp | 7 ++- src/modules/m_setidle.cpp | 4 +- src/modules/m_silence.cpp | 14 ++--- src/modules/m_spanningtree/main.cpp | 13 +++-- src/modules/m_spanningtree/override_map.cpp | 2 +- src/modules/m_spanningtree/override_whois.cpp | 4 +- src/modules/m_spanningtree/uid.cpp | 2 +- src/modules/m_sslinfo.cpp | 6 +-- src/modules/m_sslmodes.cpp | 4 +- src/modules/m_starttls.cpp | 8 +-- src/modules/m_svshold.cpp | 2 +- src/modules/m_swhois.cpp | 2 +- src/modules/m_timedbans.cpp | 5 +- src/modules/m_topiclock.cpp | 2 +- src/modules/m_uninvite.cpp | 8 +-- src/modules/m_userip.cpp | 2 +- src/modules/m_watch.cpp | 25 ++++----- src/server.cpp | 19 ++++--- src/usermanager.cpp | 2 +- src/users.cpp | 31 ++++------- src/xline.cpp | 2 +- 120 files changed, 431 insertions(+), 407 deletions(-) diff --git a/include/isupportmanager.h b/include/isupportmanager.h index 1f41de5d2..3a0df78f9 100644 --- a/include/isupportmanager.h +++ b/include/isupportmanager.h @@ -24,7 +24,7 @@ class CoreExport ISupportManager { private: /** The generated lines which are sent to clients. */ - std::vector cachedlines; + std::vector cachedlines; public: /** (Re)build the ISUPPORT vector. @@ -34,9 +34,9 @@ class CoreExport ISupportManager void Build(); /** Returns the cached std::vector of ISUPPORT lines. - * @return A list of strings prepared for sending to users + * @return A list of Numeric::Numeric objects prepared for sending to users */ - const std::vector& GetLines() const { return cachedlines; } + const std::vector& GetLines() const { return cachedlines; } /** Send the 005 numerics (ISUPPORT) to a user. * @param user The user to send the ISUPPORT numerics to diff --git a/include/modules.h b/include/modules.h index 526c283b2..86ee7f4f3 100644 --- a/include/modules.h +++ b/include/modules.h @@ -987,7 +987,7 @@ class CoreExport Module : public classbase, public usecountbase */ virtual ModResult OnNamesListItem(User* issuer, Membership* item, std::string& prefixes, std::string& nick); - virtual ModResult OnNumeric(User* user, unsigned int numeric, const std::string &text); + virtual ModResult OnNumeric(User* user, const Numeric::Numeric& numeric); /** Called whenever a result from /WHO is about to be returned * @param source The user running the /WHO query diff --git a/include/numericbuilder.h b/include/numericbuilder.h index 371f275a9..726aeff3f 100644 --- a/include/numericbuilder.h +++ b/include/numericbuilder.h @@ -40,9 +40,9 @@ class Numeric::WriteNumericSink { } - void operator()(unsigned int numeric, const std::string& params) const + void operator()(Numeric& numeric) const { - user->WriteNumeric(numeric, params); + user->WriteNumeric(numeric); } }; @@ -50,14 +50,12 @@ template class Numeric::GenericBuilder { Sink sink; - std::string data; - const unsigned int numeric; + Numeric numeric; const std::string::size_type max; - std::string::size_type beginpos; bool HasRoom(const std::string::size_type additional) const { - return (data.size() + additional <= max); + return (numeric.GetParams().back().size() + additional <= max); } public: @@ -67,28 +65,28 @@ class Numeric::GenericBuilder , max(ServerInstance->Config->Limits.MaxLine - ServerInstance->Config->ServerName.size() - additionalsize - 9) { if (addparam) - data.push_back(':'); - SaveBeginPos(); + numeric.push(std::string()); } - std::string& GetNumeric() { return data; } + Numeric& GetNumeric() { return numeric; } void Add(const std::string& entry) { if (!HasRoom(entry.size())) Flush(); - data.append(entry).push_back(Sep); + numeric.GetParams().back().append(entry).push_back(Sep); } void Add(const std::string& entry1, const std::string& entry2) { if (!HasRoom(entry1.size() + entry2.size())) Flush(); - data.append(entry1).append(entry2).push_back(Sep); + numeric.GetParams().back().append(entry1).append(entry2).push_back(Sep); } void Flush() { + std::string& data = numeric.GetParams().back(); if (IsEmpty()) { if (!SendEmpty) @@ -99,13 +97,11 @@ class Numeric::GenericBuilder data.erase(data.size()-1); } - sink(numeric, data); - if (data.size() > beginpos) - data.erase(beginpos); + sink(numeric); + data.clear(); } - bool IsEmpty() const { return (data.size() == beginpos); } - void SaveBeginPos() { beginpos = data.size(); } + bool IsEmpty() const { return (numeric.GetParams().back().empty()); } }; template diff --git a/include/users.h b/include/users.h index fa346a329..8aa88798c 100644 --- a/include/users.h +++ b/include/users.h @@ -519,9 +519,58 @@ class CoreExport User : public Extensible */ void WriteNotice(const std::string& text) { this->WriteCommand("NOTICE", ":" + text); } - void WriteNumeric(unsigned int numeric, const char* text, ...) CUSTOM_PRINTF(3, 4); - void WriteNumeric(unsigned int numeric, const std::string &text); + void WriteNumeric(const Numeric::Numeric& numeric); + + template + void WriteNumeric(unsigned int numeric, T1 p1) + { + Numeric::Numeric n(numeric); + n.push(p1); + WriteNumeric(n); + } + + template + void WriteNumeric(unsigned int numeric, T1 p1, T2 p2) + { + Numeric::Numeric n(numeric); + n.push(p1); + n.push(p2); + WriteNumeric(n); + } + + template + void WriteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3) + { + Numeric::Numeric n(numeric); + n.push(p1); + n.push(p2); + n.push(p3); + WriteNumeric(n); + } + + template + void WriteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4) + { + Numeric::Numeric n(numeric); + n.push(p1); + n.push(p2); + n.push(p3); + n.push(p4); + WriteNumeric(n); + } + + template + void WriteNumeric(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) + { + Numeric::Numeric n(numeric); + n.push(p1); + n.push(p2); + n.push(p3); + n.push(p4); + n.push(p5); + WriteNumeric(n); + } /** Write text to this user, appending CR/LF and prepending :nick!user\@host of the user provided in the first parameter. * @param user The user to prepend the :nick!user\@host of diff --git a/src/channels.cpp b/src/channels.cpp index 99da00708..a2d5c4a30 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -180,7 +180,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co } if (user->chans.size() >= maxchans) { - user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s :You are on too many channels", cname.c_str()); + user->WriteNumeric(ERR_TOOMANYCHANNELS, cname, "You are on too many channels"); return NULL; } } @@ -240,7 +240,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co if (!MOD_RESULT.check(InspIRCd::TimingSafeCompare(ckey, key))) { // If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled) - user->WriteNumeric(ERR_BADCHANNELKEY, "%s :Cannot join channel (Incorrect channel key)", chan->name.c_str()); + user->WriteNumeric(ERR_BADCHANNELKEY, chan->name, "Cannot join channel (Incorrect channel key)"); return NULL; } } @@ -250,7 +250,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, chan)); if (MOD_RESULT != MOD_RES_ALLOW) { - user->WriteNumeric(ERR_INVITEONLYCHAN, "%s :Cannot join channel (Invite only)", chan->name.c_str()); + user->WriteNumeric(ERR_INVITEONLYCHAN, chan->name, "Cannot join channel (Invite only)"); return NULL; } } @@ -261,14 +261,14 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, chan)); if (!MOD_RESULT.check((chan->GetUserCounter() < atol(limit.c_str())))) { - user->WriteNumeric(ERR_CHANNELISFULL, "%s :Cannot join channel (Channel is full)", chan->name.c_str()); + user->WriteNumeric(ERR_CHANNELISFULL, chan->name, "Cannot join channel (Channel is full)"); return NULL; } } if (chan->IsBanned(user)) { - user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s :Cannot join channel (You're banned)", chan->name.c_str()); + user->WriteNumeric(ERR_BANNEDFROMCHAN, chan->name, "Cannot join channel (You're banned)"); return NULL; } } diff --git a/src/command_parse.cpp b/src/command_parse.cpp index c123353b0..514394a57 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -217,7 +217,7 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd) if (!handler) { if (user->registered == REG_ALL) - user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :Unknown command",command.c_str()); + user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "Unknown command"); ServerInstance->stats.Unknown++; return; } @@ -268,15 +268,15 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd) if (!user->IsModeSet(handler->flags_needed)) { user->CommandFloodPenalty += failpenalty; - user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - You do not have the required operator privileges"); + user->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges"); return; } if (!user->HasPermission(command)) { user->CommandFloodPenalty += failpenalty; - user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - Oper type %s does not have access to command %s", - user->oper->name.c_str(), command.c_str()); + user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper type %s does not have access to command %s", + user->oper->name.c_str(), command.c_str())); return; } } @@ -287,11 +287,11 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd) user->CommandFloodPenalty += failpenalty; if (ServerInstance->Config->DisabledDontExist) { - user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :Unknown command", command.c_str()); + user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "Unknown command"); } else { - user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :This command has been disabled.", command.c_str()); + user->WriteNumeric(ERR_UNKNOWNCOMMAND, command, "This command has been disabled."); } ServerInstance->SNO->WriteToSnoMask('a', "%s denied for %s (%s@%s)", @@ -305,16 +305,16 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd) if (command_p.size() < handler->min_params) { user->CommandFloodPenalty += failpenalty; - user->WriteNumeric(ERR_NEEDMOREPARAMS, "%s :Not enough parameters.", command.c_str()); + user->WriteNumeric(ERR_NEEDMOREPARAMS, command, "Not enough parameters."); if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (handler->syntax.length())) - user->WriteNumeric(RPL_SYNTAX, ":SYNTAX %s %s", handler->name.c_str(), handler->syntax.c_str()); + user->WriteNumeric(RPL_SYNTAX, InspIRCd::Format("SYNTAX %s %s", handler->name.c_str(), handler->syntax.c_str())); return; } if ((user->registered != REG_ALL) && (!handler->WorksBeforeReg())) { user->CommandFloodPenalty += failpenalty; - user->WriteNumeric(ERR_NOTREGISTERED, "%s :You have not registered",command.c_str()); + user->WriteNumeric(ERR_NOTREGISTERED, command, "You have not registered"); } else { diff --git a/src/configreader.cpp b/src/configreader.cpp index 2c31fa0ae..cec4be3d3 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -688,14 +688,14 @@ void ServerConfig::ApplyModules(User* user) ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH UNLOADED MODULE: %s", modname.c_str()); if (user) - user->WriteNumeric(RPL_UNLOADEDMODULE, "%s :Module %s successfully unloaded.", modname.c_str(), modname.c_str()); + user->WriteNumeric(RPL_UNLOADEDMODULE, modname, InspIRCd::Format("Module %s successfully unloaded.", modname.c_str())); else ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully unloaded.", modname.c_str()); } else { if (user) - user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :Failed to unload module %s: %s", modname.c_str(), modname.c_str(), ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(ERR_CANTUNLOADMODULE, modname, InspIRCd::Format("Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str())); else ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str()); } @@ -707,14 +707,14 @@ void ServerConfig::ApplyModules(User* user) { ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH LOADED MODULE: %s",adding->c_str()); if (user) - user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %s successfully loaded.", adding->c_str(), adding->c_str()); + user->WriteNumeric(RPL_LOADEDMODULE, *adding, InspIRCd::Format("Module %s successfully loaded.", adding->c_str())); else ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully loaded.", adding->c_str()); } else { if (user) - user->WriteNumeric(ERR_CANTLOADMODULE, "%s :Failed to load module %s: %s", adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(ERR_CANTLOADMODULE, *adding, InspIRCd::Format("Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str())); else ServerInstance->SNO->WriteGlobalSno('a', "Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str()); } 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& 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& 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& 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& 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& 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& 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& 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& 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& 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& 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& 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& 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& 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& 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& 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& 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& 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); } diff --git a/src/coremods/core_info/cmd_commands.cpp b/src/coremods/core_info/cmd_commands.cpp index 3ff6728d8..e15d178f5 100644 --- a/src/coremods/core_info/cmd_commands.cpp +++ b/src/coremods/core_info/cmd_commands.cpp @@ -48,6 +48,6 @@ CmdResult CommandCommands::Handle (const std::vector&, User *user) std::sort(list.begin(), list.end()); for(unsigned int i=0; i < list.size(); i++) user->Write(list[i]); - user->WriteNumeric(RPL_COMMANDSEND, ":End of COMMANDS list"); + user->WriteNumeric(RPL_COMMANDSEND, "End of COMMANDS list"); return CMD_SUCCESS; } diff --git a/src/coremods/core_info/cmd_version.cpp b/src/coremods/core_info/cmd_version.cpp index eb3ab2c4e..9ec0108b1 100644 --- a/src/coremods/core_info/cmd_version.cpp +++ b/src/coremods/core_info/cmd_version.cpp @@ -30,7 +30,7 @@ CommandVersion::CommandVersion(Module* parent) CmdResult CommandVersion::Handle (const std::vector&, User *user) { std::string version = ServerInstance->GetVersionString((user->IsOper())); - user->WriteNumeric(RPL_VERSION, ":%s", version.c_str()); + user->WriteNumeric(RPL_VERSION, version); LocalUser *lu = IS_LOCAL(user); if (lu != NULL) { diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index 278e6044d..67829a55e 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -53,7 +53,7 @@ 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) @@ -100,16 +100,16 @@ CmdResult CommandList::Handle (const std::vector& parameters, User if ((!n) && (chan->IsModeSet(privatemode))) { // Channel is private (+p) and user is outside/not privileged - user->WriteNumeric(RPL_LIST, "* %ld :", users); + user->WriteNumeric(RPL_LIST, '*', users, ""); } else { /* User is in the channel/privileged, channel is not +s */ - user->WriteNumeric(RPL_LIST, "%s %ld :[+%s] %s", chan->name.c_str(), users, chan->ChanModes(n), chan->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; } diff --git a/src/coremods/core_loadmodule.cpp b/src/coremods/core_loadmodule.cpp index 1d49d89d0..09c044198 100644 --- a/src/coremods/core_loadmodule.cpp +++ b/src/coremods/core_loadmodule.cpp @@ -43,12 +43,12 @@ CmdResult CommandLoadmodule::Handle (const std::vector& 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(RPL_LOADEDMODULE, "%s :Module successfully loaded.", parameters[0].c_str()); + user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "Module successfully loaded."); return CMD_SUCCESS; } else { - user->WriteNumeric(ERR_CANTLOADMODULE, "%s :%s", parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(ERR_CANTLOADMODULE, parameters[0], ServerInstance->Modules->LastError()); return CMD_FAILURE; } } @@ -80,26 +80,25 @@ CmdResult CommandUnloadmodule::Handle(const std::vector& parameters if (!ServerInstance->Config->ConfValue("security")->getBool("allowcoreunload") && InspIRCd::Match(parameters[0], "core_*.so", ascii_case_insensitive_map)) { - user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :You cannot unload core commands!", parameters[0].c_str()); + user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], "You cannot unload core commands!"); return CMD_FAILURE; } Module* m = ServerInstance->Modules->Find(parameters[0]); if (m == creator) { - user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :You cannot unload module loading commands!", parameters[0].c_str()); + user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], "You cannot unload module loading commands!"); return CMD_FAILURE; } 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(RPL_UNLOADEDMODULE, "%s :Module successfully unloaded.", parameters[0].c_str()); + user->WriteNumeric(RPL_UNLOADEDMODULE, parameters[0], "Module successfully unloaded."); } else { - user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :%s", parameters[0].c_str(), - m ? ServerInstance->Modules->LastError().c_str() : "No such module"); + user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], (m ? ServerInstance->Modules->LastError() : "No such module")); return CMD_FAILURE; } diff --git a/src/coremods/core_lusers.cpp b/src/coremods/core_lusers.cpp index 2529ca42b..a0d0d0205 100644 --- a/src/coremods/core_lusers.cpp +++ b/src/coremods/core_lusers.cpp @@ -84,19 +84,19 @@ CmdResult CommandLusers::Handle (const std::vector&, User *user) counters.UpdateMaxUsers(); - user->WriteNumeric(RPL_LUSERCLIENT, ":There are %d users and %d invisible on %d servers", - n_users - counters.invisible, counters.invisible, n_serv); + user->WriteNumeric(RPL_LUSERCLIENT, InspIRCd::Format("There are %d users and %d invisible on %d servers", + n_users - counters.invisible, counters.invisible, n_serv)); if (ServerInstance->Users->OperCount()) - user->WriteNumeric(RPL_LUSEROP, "%d :operator(s) online", ServerInstance->Users->OperCount()); + user->WriteNumeric(RPL_LUSEROP, ServerInstance->Users.OperCount(), "operator(s) online"); if (ServerInstance->Users->UnregisteredUserCount()) - user->WriteNumeric(RPL_LUSERUNKNOWN, "%d :unknown connections", ServerInstance->Users->UnregisteredUserCount()); + user->WriteNumeric(RPL_LUSERUNKNOWN, ServerInstance->Users.UnregisteredUserCount(), "unknown connections"); - user->WriteNumeric(RPL_LUSERCHANNELS, "%lu :channels formed", (unsigned long)ServerInstance->GetChans().size()); - 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); + user->WriteNumeric(RPL_LUSERCHANNELS, ServerInstance->GetChans().size(), "channels formed"); + user->WriteNumeric(RPL_LUSERME, InspIRCd::Format("I have %d clients and %d servers", ServerInstance->Users.LocalUserCount(), n_local_servs)); + user->WriteNumeric(RPL_LOCALUSERS, InspIRCd::Format("Current local users: %d Max: %d", ServerInstance->Users.LocalUserCount(), counters.max_local)); + user->WriteNumeric(RPL_GLOBALUSERS, InspIRCd::Format("Current global users: %d Max: %d", n_users, counters.max_global)); return CMD_SUCCESS; } diff --git a/src/coremods/core_oper/cmd_kill.cpp b/src/coremods/core_oper/cmd_kill.cpp index 4a0cb2f28..0d111ce02 100644 --- a/src/coremods/core_oper/cmd_kill.cpp +++ b/src/coremods/core_oper/cmd_kill.cpp @@ -129,7 +129,7 @@ CmdResult CommandKill::Handle (const std::vector& parameters, User } else { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } diff --git a/src/coremods/core_oper/cmd_oper.cpp b/src/coremods/core_oper/cmd_oper.cpp index e4ba69549..9c06583a8 100644 --- a/src/coremods/core_oper/cmd_oper.cpp +++ b/src/coremods/core_oper/cmd_oper.cpp @@ -63,7 +63,7 @@ CmdResult CommandOper::HandleLocal(const std::vector& parameters, L fields.append("hosts"); // tell them they suck, and lag them up to help prevent brute-force attacks - user->WriteNumeric(ERR_NOOPERHOST, ":Invalid oper credentials"); + 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/coremods/core_oper/cmd_rehash.cpp b/src/coremods/core_oper/cmd_rehash.cpp index 19d2fa8c2..5ce38eb2c 100644 --- a/src/coremods/core_oper/cmd_rehash.cpp +++ b/src/coremods/core_oper/cmd_rehash.cpp @@ -68,7 +68,7 @@ CmdResult CommandRehash::Handle (const std::vector& parameters, Use ServerInstance->SNO->WriteGlobalSno('a', m); if (IS_LOCAL(user)) - user->WriteNumeric(RPL_REHASHING, "%s :Rehashing", FileSystem::GetFileName(ServerInstance->ConfigFileName).c_str()); + user->WriteNumeric(RPL_REHASHING, FileSystem::GetFileName(ServerInstance->ConfigFileName), "Rehashing"); else ServerInstance->PI->SendUserNotice(user, "*** Rehashing server " + FileSystem::GetFileName(ServerInstance->ConfigFileName)); diff --git a/src/coremods/core_privmsg.cpp b/src/coremods/core_privmsg.cpp index d691464c0..cccba0850 100644 --- a/src/coremods/core_privmsg.cpp +++ b/src/coremods/core_privmsg.cpp @@ -130,13 +130,13 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector& para { if (chan->IsModeSet(noextmsgmode) && !chan->HasUser(user)) { - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (no external messages)", chan->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (no external messages)"); return CMD_FAILURE; } if (chan->IsModeSet(moderatedmode)) { - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (+m)", chan->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (+m)"); return CMD_FAILURE; } @@ -144,7 +144,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector& para { if (chan->IsBanned(user)) { - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're banned)"); return CMD_FAILURE; } } @@ -161,7 +161,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector& para /* Check again, a module may have zapped the input string */ if (temp.empty()) { - user->WriteNumeric(ERR_NOTEXTTOSEND, ":No text to send"); + user->WriteNumeric(ERR_NOTEXTTOSEND, "No text to send"); return CMD_FAILURE; } @@ -181,7 +181,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector& para else { /* no such nick/channel */ - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", target); + user->WriteNumeric(Numerics::NoSuchNick(target)); return CMD_FAILURE; } return CMD_SUCCESS; @@ -202,7 +202,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector& para if (dest && strcasecmp(dest->server->GetName().c_str(), targetserver + 1)) { /* Incorrect server for user */ - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } } @@ -216,14 +216,14 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector& para { if (parameters[1].empty()) { - user->WriteNumeric(ERR_NOTEXTTOSEND, ":No text to send"); + user->WriteNumeric(ERR_NOTEXTTOSEND, "No text to send"); return CMD_FAILURE; } if ((dest->IsAway()) && (mt == MSG_PRIVMSG)) { /* auto respond with aweh msg */ - user->WriteNumeric(RPL_AWAY, "%s :%s", dest->nick.c_str(), dest->awaymsg.c_str()); + user->WriteNumeric(RPL_AWAY, dest->nick, dest->awaymsg); } ModResult MOD_RESULT; @@ -248,7 +248,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector& para else { /* no such nick/channel */ - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } return CMD_SUCCESS; diff --git a/src/coremods/core_reloadmodule.cpp b/src/coremods/core_reloadmodule.cpp index 0d01d9e85..6fcec8ac2 100644 --- a/src/coremods/core_reloadmodule.cpp +++ b/src/coremods/core_reloadmodule.cpp @@ -601,7 +601,7 @@ class ReloadAction : public HandlerBase0 ServerInstance->SNO->WriteGlobalSno('a', "RELOAD MODULE: %s %ssuccessfully reloaded", passedname.c_str(), result ? "" : "un"); User* user = ServerInstance->FindUUID(uuid); if (user) - user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %ssuccessfully reloaded.", passedname.c_str(), result ? "" : "un"); + user->WriteNumeric(RPL_LOADEDMODULE, passedname, InspIRCd::Format("Module %ssuccessfully reloaded.", (result ? "" : "un"))); ServerInstance->GlobalCulls.AddItem(this); } @@ -612,8 +612,7 @@ CmdResult CommandReloadmodule::Handle (const std::vector& parameter Module* m = ServerInstance->Modules->Find(parameters[0]); if (m == creator) { - user->WriteNumeric(RPL_LOADEDMODULE, "%s :You cannot reload core_reloadmodule.so (unload and load it)", - parameters[0].c_str()); + user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "You cannot reload core_reloadmodule.so (unload and load it)"); return CMD_FAILURE; } @@ -627,7 +626,7 @@ CmdResult CommandReloadmodule::Handle (const std::vector& parameter } else { - user->WriteNumeric(RPL_LOADEDMODULE, "%s :Could not find module by that name", parameters[0].c_str()); + user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "Could not find module by that name"); return CMD_FAILURE; } } diff --git a/src/coremods/core_stub.cpp b/src/coremods/core_stub.cpp index 20f6888b5..91fc16241 100644 --- a/src/coremods/core_stub.cpp +++ b/src/coremods/core_stub.cpp @@ -70,8 +70,8 @@ class CommandLinks : public Command */ CmdResult Handle(const std::vector& parameters, User* user) { - 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."); + user->WriteNumeric(RPL_LINKS, ServerInstance->Config->ServerName, ServerInstance->Config->ServerName, InspIRCd::Format("0 %s", ServerInstance->Config->ServerDesc.c_str())); + user->WriteNumeric(RPL_ENDOFLINKS, '*', "End of /LINKS list."); return CMD_SUCCESS; } }; @@ -98,11 +98,11 @@ class CommandServer : public Command { if (user->registered == REG_ALL) { - user->WriteNumeric(ERR_ALREADYREGISTERED, ":You are already registered. (Perhaps your IRC client does not have a /SERVER command)."); + user->WriteNumeric(ERR_ALREADYREGISTERED, "You are already registered. (Perhaps your IRC client does not have a /SERVER command)."); } else { - user->WriteNumeric(ERR_NOTREGISTERED, "SERVER :You may not register as a server (servers have separate ports from clients, change your config)"); + user->WriteNumeric(ERR_NOTREGISTERED, "SERVER", "You may not register as a server (servers have separate ports from clients, change your config)"); } return CMD_FAILURE; } diff --git a/src/coremods/core_user/cmd_away.cpp b/src/coremods/core_user/cmd_away.cpp index adc6e6c18..fb720a5a7 100644 --- a/src/coremods/core_user/cmd_away.cpp +++ b/src/coremods/core_user/cmd_away.cpp @@ -43,7 +43,7 @@ CmdResult CommandAway::Handle (const std::vector& parameters, User user->awaytime = ServerInstance->Time(); user->awaymsg.assign(parameters[0], 0, ServerInstance->Config->Limits.MaxAway); - user->WriteNumeric(RPL_NOWAWAY, ":You have been marked as being away"); + user->WriteNumeric(RPL_NOWAWAY, "You have been marked as being away"); } else { @@ -53,7 +53,7 @@ CmdResult CommandAway::Handle (const std::vector& parameters, User return CMD_FAILURE; user->awaymsg.clear(); - user->WriteNumeric(RPL_UNAWAY, ":You are no longer marked as being away"); + user->WriteNumeric(RPL_UNAWAY, "You are no longer marked as being away"); } return CMD_SUCCESS; diff --git a/src/coremods/core_user/cmd_mode.cpp b/src/coremods/core_user/cmd_mode.cpp index a62bf51ca..b1790bb89 100644 --- a/src/coremods/core_user/cmd_mode.cpp +++ b/src/coremods/core_user/cmd_mode.cpp @@ -45,7 +45,7 @@ CmdResult CommandMode::Handle(const std::vector& parameters, User* if ((!targetchannel) && (!targetuser)) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", target.c_str()); + user->WriteNumeric(Numerics::NoSuchNick(target)); return CMD_FAILURE; } if (parameters.size() == 1) @@ -70,7 +70,7 @@ CmdResult CommandMode::Handle(const std::vector& parameters, User* if ((targetuser) && (user != targetuser)) { // Local users may only change the modes of other users if a module explicitly allows it - user->WriteNumeric(ERR_USERSDONTMATCH, ":Can't change mode for other users"); + user->WriteNumeric(ERR_USERSDONTMATCH, "Can't change mode for other users"); return CMD_FAILURE; } @@ -135,8 +135,8 @@ void CommandMode::DisplayCurrentModes(User* user, User* targetuser, Channel* tar if (targetchannel) { // Display channel's current mode string - user->WriteNumeric(RPL_CHANNELMODEIS, "%s +%s", targetchannel->name.c_str(), targetchannel->ChanModes(targetchannel->HasUser(user))); - user->WriteNumeric(RPL_CHANNELCREATED, "%s %lu", targetchannel->name.c_str(), (unsigned long)targetchannel->age); + user->WriteNumeric(RPL_CHANNELMODEIS, targetchannel->name, (std::string("+") + targetchannel->ChanModes(targetchannel->HasUser(user)))); + user->WriteNumeric(RPL_CHANNELCREATED, targetchannel->name, (unsigned long)targetchannel->age); } else { @@ -157,7 +157,7 @@ void CommandMode::DisplayCurrentModes(User* user, User* targetuser, Channel* tar } else { - user->WriteNumeric(ERR_USERSDONTMATCH, ":Can't view modes for other users"); + user->WriteNumeric(ERR_USERSDONTMATCH, "Can't view modes for other users"); } } } diff --git a/src/coremods/core_user/cmd_nick.cpp b/src/coremods/core_user/cmd_nick.cpp index a62e1c207..45e7adae5 100644 --- a/src/coremods/core_user/cmd_nick.cpp +++ b/src/coremods/core_user/cmd_nick.cpp @@ -47,7 +47,7 @@ CmdResult CommandNick::HandleLocal(const std::vector& parameters, L if (newnick.empty()) { - user->WriteNumeric(ERR_ERRONEUSNICKNAME, "* :Erroneous Nickname"); + user->WriteNumeric(ERR_ERRONEUSNICKNAME, '*', "Erroneous Nickname"); return CMD_FAILURE; } @@ -57,7 +57,7 @@ CmdResult CommandNick::HandleLocal(const std::vector& parameters, L } else if (!ServerInstance->IsNick(newnick)) { - user->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Erroneous Nickname", newnick.c_str()); + user->WriteNumeric(ERR_ERRONEUSNICKNAME, newnick, "Erroneous Nickname"); return CMD_FAILURE; } @@ -77,7 +77,7 @@ CmdResult CommandNick::HandleLocal(const std::vector& parameters, L Channel* chan = (*i)->chan; if (chan->GetPrefixValue(user) < VOICE_VALUE && chan->IsBanned(user)) { - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're banned)"); return CMD_FAILURE; } } diff --git a/src/coremods/core_user/cmd_part.cpp b/src/coremods/core_user/cmd_part.cpp index 77aafd1b3..4da2787d9 100644 --- a/src/coremods/core_user/cmd_part.cpp +++ b/src/coremods/core_user/cmd_part.cpp @@ -46,13 +46,13 @@ CmdResult CommandPart::Handle (const std::vector& parameters, User if (!c) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } if (!c->PartUser(user, reason)) { - 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; } diff --git a/src/coremods/core_user/cmd_user.cpp b/src/coremods/core_user/cmd_user.cpp index cbf4f5e08..37ac116df 100644 --- a/src/coremods/core_user/cmd_user.cpp +++ b/src/coremods/core_user/cmd_user.cpp @@ -40,7 +40,7 @@ CmdResult CommandUser::HandleLocal(const std::vector& 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(ERR_NEEDMOREPARAMS, "USER :Your username is not valid"); + user->WriteNumeric(ERR_NEEDMOREPARAMS, name, "Your username is not valid"); return CMD_FAILURE; } else @@ -57,7 +57,7 @@ CmdResult CommandUser::HandleLocal(const std::vector& parameters, L } else { - user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister"); + user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister"); user->CommandFloodPenalty += 1000; return CMD_FAILURE; } diff --git a/src/coremods/core_user/core_user.cpp b/src/coremods/core_user/core_user.cpp index dd778548a..a2ffc009e 100644 --- a/src/coremods/core_user/core_user.cpp +++ b/src/coremods/core_user/core_user.cpp @@ -46,7 +46,7 @@ class CommandPass : public SplitCommand if (user->registered == REG_ALL) { user->CommandFloodPenalty += 1000; - user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister"); + user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister"); return CMD_FAILURE; } user->password = parameters[0]; diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp index 8b9258d71..1bc03c78e 100644 --- a/src/coremods/core_who.cpp +++ b/src/coremods/core_who.cpp @@ -385,7 +385,7 @@ CmdResult CommandWho::Handle (const std::vector& parameters, User * /* Send the results out */ for (std::vector::const_iterator n = whoresults.begin(); n != whoresults.end(); n++) user->WriteServ(*n); - user->WriteNumeric(RPL_ENDOFWHO, "%s :End of /WHO list.", *parameters[0].c_str() ? parameters[0].c_str() : "*"); + user->WriteNumeric(RPL_ENDOFWHO, (*parameters[0].c_str() ? parameters[0] : "*"), "End of /WHO list."); // Penalize the user a bit for large queries // (add one unit of penalty per 200 results) diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp index ecc406a8c..0645eda4c 100644 --- a/src/coremods/core_whois.cpp +++ b/src/coremods/core_whois.cpp @@ -95,9 +95,9 @@ class WhoisNumericSink { } - void operator()(unsigned int numeric, const std::string& text) const + void operator()(Numeric::Numeric& numeric) const { - whois.SendLine(numeric, text); + whois.SendLine(numeric); } }; @@ -296,8 +296,8 @@ CmdResult CommandWhois::HandleLocal(const std::vector& parameters, else { /* no such nick/channel */ - 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() : "*"); + user->WriteNumeric(Numerics::NoSuchNick(!parameters[userindex].empty() ? parameters[userindex] : "*")); + user->WriteNumeric(RPL_ENDOFWHOIS, (!parameters[userindex].empty() ? parameters[userindex] : "*"), "End of /WHOIS list."); return CMD_FAILURE; } diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp index 79ce94cc9..e04a69200 100644 --- a/src/coremods/core_whowas.cpp +++ b/src/coremods/core_whowas.cpp @@ -35,14 +35,14 @@ CmdResult CommandWhowas::Handle (const std::vector& parameters, Use /* if whowas disabled in config */ if (!manager.IsEnabled()) { - user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s :This command has been disabled.", name.c_str()); + user->WriteNumeric(ERR_UNKNOWNCOMMAND, name, "This command has been disabled."); return CMD_FAILURE; } const WhoWas::Nick* const nick = manager.FindNick(parameters[0]); if (!nick) { - user->WriteNumeric(ERR_WASNOSUCHNICK, "%s :There was no such nickname", parameters[0].c_str()); + user->WriteNumeric(ERR_WASNOSUCHNICK, parameters[0], "There was no such nickname"); } else { @@ -51,18 +51,18 @@ CmdResult CommandWhowas::Handle (const std::vector& parameters, Use { WhoWas::Entry* u = *i; - user->WriteNumeric(RPL_WHOWASUSER, "%s %s %s * :%s", parameters[0].c_str(), u->ident.c_str(),u->dhost.c_str(),u->gecos.c_str()); + user->WriteNumeric(RPL_WHOWASUSER, parameters[0], u->ident, u->dhost, '*', u->gecos); if (user->HasPrivPermission("users/auspex")) - user->WriteNumeric(RPL_WHOWASIP, "%s :was connecting from *@%s", parameters[0].c_str(), u->host.c_str()); + user->WriteNumeric(RPL_WHOWASIP, parameters[0], InspIRCd::Format("was connecting from *@%s", u->host.c_str())); std::string signon = InspIRCd::TimeString(u->signon); bool hide_server = (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")); - 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()); + user->WriteNumeric(RPL_WHOISSERVER, parameters[0], (hide_server ? ServerInstance->Config->HideWhoisServer : u->server), signon); } } - user->WriteNumeric(RPL_ENDOFWHOWAS, "%s :End of WHOWAS", parameters[0].c_str()); + user->WriteNumeric(RPL_ENDOFWHOWAS, parameters[0], "End of WHOWAS"); return CMD_SUCCESS; } diff --git a/src/coremods/core_xline/core_xline.cpp b/src/coremods/core_xline/core_xline.cpp index 7fa7da019..93ac1db31 100644 --- a/src/coremods/core_xline/core_xline.cpp +++ b/src/coremods/core_xline/core_xline.cpp @@ -80,7 +80,7 @@ class CoreModXLine : public Module } // Send a numeric because if we deny then the core doesn't reply anything - user->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Invalid nickname: %s", newnick.c_str(), xline->reason.c_str()); + user->WriteNumeric(ERR_ERRONEUSNICKNAME, newnick, InspIRCd::Format("Invalid nickname: %s", xline->reason.c_str())); return MOD_RES_DENY; } diff --git a/src/listmode.cpp b/src/listmode.cpp index 35964dfb3..cd034688c 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -35,15 +35,15 @@ void ListModeBase::DisplayList(User* user, Channel* channel) { for (ModeList::const_iterator it = cd->list.begin(); it != cd->list.end(); ++it) { - user->WriteNumeric(listnumeric, "%s %s %s %lu", channel->name.c_str(), it->mask.c_str(), it->setter.c_str(), (unsigned long) it->time); + user->WriteNumeric(listnumeric, channel->name, it->mask, it->setter, (unsigned long) it->time); } } - user->WriteNumeric(endoflistnumeric, "%s :%s", channel->name.c_str(), endofliststring.c_str()); + user->WriteNumeric(endoflistnumeric, channel->name, endofliststring); } void ListModeBase::DisplayEmptyList(User* user, Channel* channel) { - user->WriteNumeric(endoflistnumeric, "%s :%s", channel->name.c_str(), endofliststring.c_str()); + user->WriteNumeric(endoflistnumeric, channel->name, endofliststring); } void ListModeBase::RemoveMode(Channel* channel, Modes::ChangeList& changelist) @@ -212,7 +212,7 @@ bool ListModeBase::ValidateParam(User*, Channel*, std::string&) void ListModeBase::TellListTooLong(User* source, Channel* channel, std::string& parameter) { - source->WriteNumeric(ERR_BANLISTFULL, "%s %s :Channel ban list is full", channel->name.c_str(), parameter.c_str()); + source->WriteNumeric(ERR_BANLISTFULL, channel->name, parameter, "Channel ban list is full"); } void ListModeBase::TellAlreadyOnList(User*, Channel*, std::string&) diff --git a/src/mode.cpp b/src/mode.cpp index 6038f6f5b..b29eda828 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -175,7 +175,7 @@ ModeAction PrefixMode::OnModeChange(User* source, User*, Channel* chan, std::str if (!target) { - source->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameter.c_str()); + source->WriteNumeric(Numerics::NoSuchNick(parameter)); return MODEACTION_DENY; } @@ -263,11 +263,10 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode } } if (neededmh) - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must have channel %s access or above to %sset channel mode %c", - chan->name.c_str(), neededmh->name.c_str(), adding ? "" : "un", modechar); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You must have channel %s access or above to %sset channel mode %c", + neededmh->name.c_str(), adding ? "" : "un", modechar)); else - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You cannot %sset channel mode %c", - chan->name.c_str(), adding ? "" : "un", modechar); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You cannot %sset channel mode %c", (adding ? "" : "un"), modechar)); return MODEACTION_DENY; } } @@ -294,8 +293,8 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode char* disabled = (type == MODETYPE_CHANNEL) ? ServerInstance->Config->DisabledCModes : ServerInstance->Config->DisabledUModes; if (disabled[modechar - 'A']) { - user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - %s mode %c has been locked by the administrator", - type == MODETYPE_CHANNEL ? "channel" : "user", modechar); + user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - %s mode %c has been locked by the administrator", + type == MODETYPE_CHANNEL ? "channel" : "user", modechar)); return MODEACTION_DENY; } } @@ -305,13 +304,13 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode /* It's an oper only mode, and they don't have access to it. */ if (user->IsOper()) { - user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - Oper type %s does not have access to set %s mode %c", - user->oper->name.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar); + user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper type %s does not have access to set %s mode %c", + user->oper->name.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar)); } else { - user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - Only operators may set %s mode %c", - type == MODETYPE_CHANNEL ? "channel" : "user", modechar); + user->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Only operators may set %s mode %c", + type == MODETYPE_CHANNEL ? "channel" : "user", modechar)); } return MODEACTION_DENY; } @@ -359,7 +358,7 @@ void ModeParser::ModeParamsToChangeList(User* user, ModeType type, const std::ve if (!mh) { /* No mode handler? Unknown mode character then. */ - user->WriteNumeric(type == MODETYPE_CHANNEL ? ERR_UNKNOWNMODE : ERR_UNKNOWNSNOMASK, "%c :is unknown mode char to me", modechar); + user->WriteNumeric(type == MODETYPE_CHANNEL ? ERR_UNKNOWNMODE : ERR_UNKNOWNSNOMASK, modechar, "is unknown mode char to me"); continue; } diff --git a/src/modes/umode_s.cpp b/src/modes/umode_s.cpp index 08ee7f562..f0fa5e94b 100644 --- a/src/modes/umode_s.cpp +++ b/src/modes/umode_s.cpp @@ -99,7 +99,7 @@ std::string ModeUserServerNoticeMask::ProcessNoticeMasks(User* user, const std:: { if (!ServerInstance->SNO->IsSnomaskUsable(*i)) { - user->WriteNumeric(ERR_UNKNOWNSNOMASK, "%c :is unknown snomask char to me", *i); + user->WriteNumeric(ERR_UNKNOWNSNOMASK, *i, "is unknown snomask char to me"); continue; } } diff --git a/src/modules.cpp b/src/modules.cpp index 292986df5..28ded66d8 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -135,7 +135,7 @@ void Module::OnGarbageCollect() { DetachEvent(I_OnGarbageCollect); } ModResult Module::OnSetConnectClass(LocalUser* user, ConnectClass* myclass) { DetachEvent(I_OnSetConnectClass); return MOD_RES_PASSTHRU; } void Module::OnText(User*, void*, int, const std::string&, char, CUList&) { DetachEvent(I_OnText); } ModResult Module::OnNamesListItem(User*, Membership*, std::string&, std::string&) { DetachEvent(I_OnNamesListItem); return MOD_RES_PASSTHRU; } -ModResult Module::OnNumeric(User*, unsigned int, const std::string&) { DetachEvent(I_OnNumeric); return MOD_RES_PASSTHRU; } +ModResult Module::OnNumeric(User*, const Numeric::Numeric&) { DetachEvent(I_OnNumeric); return MOD_RES_PASSTHRU; } ModResult Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { DetachEvent(I_OnAcceptConnection); return MOD_RES_PASSTHRU; } void Module::OnSendWhoLine(User*, const std::vector&, User*, Membership*, std::string&) { DetachEvent(I_OnSendWhoLine); } void Module::OnSetUserIP(LocalUser*) { DetachEvent(I_OnSetUserIP); } diff --git a/src/modules/m_abbreviation.cpp b/src/modules/m_abbreviation.cpp index d2fa09c4e..85709080f 100644 --- a/src/modules/m_abbreviation.cpp +++ b/src/modules/m_abbreviation.cpp @@ -49,7 +49,7 @@ class ModuleAbbreviation : public Module { if (matchlist.length() > 450) { - user->WriteNumeric(420, ":Ambiguous abbreviation and too many possible matches."); + user->WriteNumeric(420, "Ambiguous abbreviation and too many possible matches."); return MOD_RES_DENY; } @@ -67,7 +67,7 @@ class ModuleAbbreviation : public Module /* Ambiguous command, list the matches */ if (!matchlist.empty()) { - user->WriteNumeric(420, ":Ambiguous abbreviation, possible matches: %s%s", foundcommand.c_str(), matchlist.c_str()); + user->WriteNumeric(420, InspIRCd::Format("Ambiguous abbreviation, possible matches: %s%s", foundcommand.c_str(), matchlist.c_str())); return MOD_RES_DENY; } diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 3a4bf5348..9184b10af 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -253,14 +253,14 @@ class ModuleAlias : public Module User* u = ServerInstance->FindNick(a->RequiredNick); if (!u) { - user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is currently unavailable. Please try again later."); + user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick, "is currently unavailable. Please try again later."); return 1; } if ((a->ULineOnly) && (!u->server->IsULine())) { ServerInstance->SNO->WriteToSnoMask('a', "NOTICE -- Service "+a->RequiredNick+" required by alias "+a->AliasedCommand+" is not on a u-lined server, possibly underhanded antics detected!"); - user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick + " :is an imposter! Please inform an IRC operator as soon as possible."); + user->WriteNumeric(ERR_NOSUCHNICK, a->RequiredNick, "is an imposter! Please inform an IRC operator as soon as possible."); return 1; } } diff --git a/src/modules/m_allowinvite.cpp b/src/modules/m_allowinvite.cpp index 05e76113a..6a4db1822 100644 --- a/src/modules/m_allowinvite.cpp +++ b/src/modules/m_allowinvite.cpp @@ -47,7 +47,7 @@ class ModuleAllowInvite : public Module if (res == MOD_RES_DENY) { // Matching extban, explicitly deny /invite - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You are banned from using INVITE", channel->name.c_str()); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, "You are banned from using INVITE"); return res; } if (channel->IsModeSet(ni) || res == MOD_RES_ALLOW) diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp index 2b9c2e1c2..8c7f300da 100644 --- a/src/modules/m_autoop.cpp +++ b/src/modules/m_autoop.cpp @@ -52,8 +52,7 @@ class AutoOpList : public ListModeBase if (adding && !mh) { - source->WriteNumeric(415, "%s :Cannot find prefix mode '%s' for autoop", - mid.c_str(), mid.c_str()); + source->WriteNumeric(415, mid, InspIRCd::Format("Cannot find prefix mode '%s' for autoop", mid.c_str())); return MOD_RES_DENY; } else if (!mh) @@ -64,8 +63,7 @@ class AutoOpList : public ListModeBase return MOD_RES_DENY; if (mh->GetLevelRequired() > mylevel) { - source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be able to set mode '%s' to include it in an autoop", - channel->name.c_str(), mid.c_str()); + source->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, InspIRCd::Format("You must be able to set mode '%s' to include it in an autoop", mid.c_str())); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index d3490acc0..c44a10f05 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -82,7 +82,7 @@ class BanRedirect : public ModeWatcher ListModeBase::ModeList* list = banlm->GetList(channel); if ((list) && (adding) && (maxbans <= list->size())) { - source->WriteNumeric(ERR_BANLISTFULL, "%s :Channel ban list for %s is full (maximum entries for this channel is %u)", channel->name.c_str(), channel->name.c_str(), maxbans); + source->WriteNumeric(ERR_BANLISTFULL, channel->name, InspIRCd::Format("Channel ban list for %s is full (maximum entries for this channel is %u)", channel->name.c_str(), maxbans)); return false; } @@ -150,25 +150,25 @@ class BanRedirect : public ModeWatcher { if (!ServerInstance->IsChannel(mask[CHAN])) { - source->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :Invalid channel name in redirection (%s)", channel->name.c_str(), mask[CHAN].c_str()); + source->WriteNumeric(ERR_NOSUCHCHANNEL, channel->name, InspIRCd::Format("Invalid channel name in redirection (%s)", mask[CHAN].c_str())); return false; } Channel *c = ServerInstance->FindChan(mask[CHAN]); if (!c) { - source->WriteNumeric(690, ":Target channel %s must exist to be set as a redirect.", mask[CHAN].c_str()); + source->WriteNumeric(690, InspIRCd::Format("Target channel %s must exist to be set as a redirect.", mask[CHAN].c_str())); return false; } else if (adding && c->GetPrefixValue(source) < OP_VALUE) { - source->WriteNumeric(690, ":You must be opped on %s to set it as a redirect.", mask[CHAN].c_str()); + source->WriteNumeric(690, InspIRCd::Format("You must be opped on %s to set it as a redirect.", mask[CHAN].c_str())); return false; } if (assign(channel->name) == mask[CHAN]) { - source->WriteNumeric(690, "%s :You cannot set a ban redirection to the channel the ban is on", channel->name.c_str()); + source->WriteNumeric(690, channel->name, "You cannot set a ban redirection to the channel the ban is on"); return false; } } @@ -311,13 +311,13 @@ class ModuleBanRedirect : public Module if(destchan && destchan->IsModeSet(redirectmode) && !destlimit.empty() && (destchan->GetUserCounter() >= atoi(destlimit.c_str()))) { - user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s :Cannot join channel (You are banned)", chan->name.c_str()); + user->WriteNumeric(ERR_BANNEDFROMCHAN, chan->name, "Cannot join channel (You are banned)"); return MOD_RES_DENY; } else { - user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s :Cannot join channel (You are banned)", chan->name.c_str()); - user->WriteNumeric(470, "%s %s :You are banned from this channel, so you are automatically transferred to the redirected channel.", chan->name.c_str(), redir->targetchan.c_str()); + user->WriteNumeric(ERR_BANNEDFROMCHAN, chan->name, "Cannot join channel (You are banned)"); + user->WriteNumeric(470, chan->name, redir->targetchan, "You are banned from this channel, so you are automatically transferred to the redirected channel."); nofollow = true; Channel::JoinUser(user, redir->targetchan); nofollow = false; diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index 57f86afd1..cd7698d69 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -74,7 +74,7 @@ public: if (((caps * 100) / text.length()) >= percent) { - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Your message cannot contain %d%% or more capital letters if it's longer than %d characters", c->name.c_str(), percent, minlen); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, InspIRCd::Format("Your message cannot contain %d%% or more capital letters if it's longer than %d characters", percent, minlen)); return MOD_RES_DENY; } } diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp index a08ad7c6f..567bdb249 100644 --- a/src/modules/m_blockcolor.cpp +++ b/src/modules/m_blockcolor.cpp @@ -67,7 +67,7 @@ class ModuleBlockColor : public Module case 21: case 22: case 31: - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Can't send colors to channel (+c set)", c->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send colors to channel (+c set)"); return MOD_RES_DENY; break; } diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 0eb208138..149767f18 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -225,7 +225,7 @@ public: ACCEPTAction action = GetTargetAndAction(tok, user); if (!action.first) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", tok.c_str()); + user->WriteNumeric(Numerics::NoSuchNick(tok)); return CMD_FAILURE; } @@ -271,7 +271,7 @@ public: for (callerid_data::UserSet::iterator i = dat->accepting.begin(); i != dat->accepting.end(); ++i) user->WriteNumeric(RPL_ACCEPTLIST, (*i)->nick); } - user->WriteNumeric(RPL_ENDOFACCEPT, ":End of ACCEPT list"); + user->WriteNumeric(RPL_ENDOFACCEPT, "End of ACCEPT list"); } bool AddAccept(User* user, User* whotoadd) @@ -280,12 +280,12 @@ public: callerid_data* dat = extInfo.get(user, true); if (dat->accepting.size() >= maxaccepts) { - user->WriteNumeric(ERR_ACCEPTFULL, ":Accept list is full (limit is %d)", maxaccepts); + user->WriteNumeric(ERR_ACCEPTFULL, InspIRCd::Format("Accept list is full (limit is %d)", maxaccepts)); return false; } if (!dat->accepting.insert(whotoadd).second) { - user->WriteNumeric(ERR_ACCEPTEXIST, "%s :is already on your accept list", whotoadd->nick.c_str()); + user->WriteNumeric(ERR_ACCEPTEXIST, whotoadd->nick, "is already on your accept list"); return false; } @@ -303,12 +303,12 @@ public: callerid_data* dat = extInfo.get(user, false); if (!dat) { - user->WriteNumeric(ERR_ACCEPTNOT, "%s :is not on your accept list", whotoremove->nick.c_str()); + user->WriteNumeric(ERR_ACCEPTNOT, whotoremove->nick, "is not on your accept list"); return false; } if (!dat->accepting.erase(whotoremove)) { - user->WriteNumeric(ERR_ACCEPTNOT, "%s :is not on your accept list", whotoremove->nick.c_str()); + user->WriteNumeric(ERR_ACCEPTNOT, whotoremove->nick, "is not on your accept list"); return false; } @@ -395,10 +395,10 @@ public: { time_t now = ServerInstance->Time(); /* +g and *not* accepted */ - user->WriteNumeric(ERR_TARGUMODEG, "%s :is in +g mode (server-side ignore).", dest->nick.c_str()); + user->WriteNumeric(ERR_TARGUMODEG, dest->nick, "is in +g mode (server-side ignore)."); if (now > (dat->lastnotify + (time_t)notify_cooldown)) { - user->WriteNumeric(RPL_TARGNOTIFY, "%s :has been informed that you messaged them.", dest->nick.c_str()); + user->WriteNumeric(RPL_TARGNOTIFY, dest->nick, "has been informed that you messaged them."); dest->SendText(":%s %03d %s %s %s@%s :is messaging you, and you have umode +g. Use /ACCEPT +%s to allow.", ServerInstance->Config->ServerName.c_str(), RPL_UMODEGMSG, dest->nick.c_str(), user->nick.c_str(), user->ident.c_str(), user->dhost.c_str(), user->nick.c_str()); dat->lastnotify = now; diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp index 09d5e604d..e6e01570d 100644 --- a/src/modules/m_cap.cpp +++ b/src/modules/m_cap.cpp @@ -398,7 +398,7 @@ class CommandCap : public SplitCommand } else { - user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, "%s :Invalid CAP subcommand", subcommand.c_str()); + user->WriteNumeric(ERR_INVALIDCAPSUBCOMMAND, subcommand, "Invalid CAP subcommand"); return CMD_FAILURE; } diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index 4fb0653a9..1ddc625db 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -181,7 +181,7 @@ class ModuleCBan : public Module if (rl) { // Channel is banned. - user->WriteNumeric(384, "%s :Cannot join channel, CBANed (%s)", cname.c_str(), rl->reason.c_str()); + user->WriteNumeric(384, cname, InspIRCd::Format("Cannot join channel, CBANed (%s)", rl->reason.c_str())); ServerInstance->SNO->WriteGlobalSno('a', "%s tried to join %s which is CBANed (%s)", user->nick.c_str(), cname.c_str(), rl->reason.c_str()); return MOD_RES_DENY; diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index da22b5153..7d8c74024 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -79,7 +79,7 @@ class ModuleCensor : public Module { if (index->second.empty()) { - user->WriteNumeric(ERR_WORDFILTERED, "%s %s :Your message contained a censored word, and was blocked", ((Channel*)dest)->name.c_str(), index->first.c_str()); + user->WriteNumeric(ERR_WORDFILTERED, ((Channel*)dest)->name, index->first, "Your message contained a censored word, and was blocked"); return MOD_RES_DENY; } diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index 53428a5a8..a7bc21557 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -37,7 +37,7 @@ class ChanFilter : public ListModeBase { if (word.length() > 35) { - user->WriteNumeric(935, "%s %s :word is too long for censor list", chan->name.c_str(), word.c_str()); + user->WriteNumeric(935, chan->name, word, "%word is too long for censor list"); return false; } @@ -46,17 +46,17 @@ class ChanFilter : public ListModeBase void TellListTooLong(User* user, Channel* chan, std::string &word) { - user->WriteNumeric(939, "%s %s :Channel spamfilter list is full", chan->name.c_str(), word.c_str()); + user->WriteNumeric(939, chan->name, word, "Channel spamfilter list is full"); } void TellAlreadyOnList(User* user, Channel* chan, std::string &word) { - user->WriteNumeric(937, "%s :The word %s is already on the spamfilter list", chan->name.c_str(), word.c_str()); + user->WriteNumeric(937, chan->name, InspIRCd::Format("The word %s is already on the spamfilter list", word.c_str())); } void TellNotSet(User* user, Channel* chan, std::string &word) { - user->WriteNumeric(938, "%s :No such spamfilter word is set", chan->name.c_str()); + user->WriteNumeric(938, chan->name, "No such spamfilter word is set"); } }; @@ -98,9 +98,9 @@ class ModuleChanFilter : public Module if (InspIRCd::Match(text, i->mask)) { if (hidemask) - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (your message contained a censored word)", chan->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (your message contained a censored word)"); else - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s %s :Cannot send to channel (your message contained a censored word)", chan->name.c_str(), i->mask.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, i->mask, "Cannot send to channel (your message contained a censored word)"); return MOD_RES_DENY; } } diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 43b2a323b..163f1f2eb 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -59,7 +59,7 @@ class CommandChghost : public Command // Allow services to change the host of unregistered users if ((!dest) || ((dest->registered != REG_ALL) && (!user->server->IsULine()))) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } diff --git a/src/modules/m_chgident.cpp b/src/modules/m_chgident.cpp index c855216bf..0b4e78f12 100644 --- a/src/modules/m_chgident.cpp +++ b/src/modules/m_chgident.cpp @@ -41,7 +41,7 @@ class CommandChgident : public Command if ((!dest) || (dest->registered != REG_ALL)) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } diff --git a/src/modules/m_chgname.cpp b/src/modules/m_chgname.cpp index 830d5070b..3ad9cede9 100644 --- a/src/modules/m_chgname.cpp +++ b/src/modules/m_chgname.cpp @@ -39,7 +39,7 @@ class CommandChgname : public Command if ((!dest) || (dest->registered != REG_ALL)) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } diff --git a/src/modules/m_commonchans.cpp b/src/modules/m_commonchans.cpp index eab53b9bc..e04217e71 100644 --- a/src/modules/m_commonchans.cpp +++ b/src/modules/m_commonchans.cpp @@ -47,7 +47,7 @@ class ModulePrivacyMode : public Module User* t = (User*)dest; if (!user->IsOper() && (t->IsModeSet(pm)) && (!user->server->IsULine()) && !user->SharesChannelWith(t)) { - user->WriteNumeric(ERR_CANTSENDTOUSER, "%s :You are not permitted to send private messages to this user (+c set)", t->nick.c_str()); + user->WriteNumeric(ERR_CANTSENDTOUSER, t->nick, "You are not permitted to send private messages to this user (+c set)"); return MOD_RES_DENY; } } diff --git a/src/modules/m_cycle.cpp b/src/modules/m_cycle.cpp index c8b6bd8b4..202cb123f 100644 --- a/src/modules/m_cycle.cpp +++ b/src/modules/m_cycle.cpp @@ -44,7 +44,7 @@ class CommandCycle : public SplitCommand if (!channel) { - user->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :No such channel", parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHCHANNEL, parameters[0], "No such channel"); return CMD_FAILURE; } @@ -64,7 +64,7 @@ class CommandCycle : public SplitCommand } else { - user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel", channel->name.c_str()); + user->WriteNumeric(ERR_NOTONCHANNEL, channel->name, "You're not on that channel"); } return CMD_FAILURE; diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 45a230465..21cc97aa5 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -120,7 +120,7 @@ class CommandDccallow : public Command } else { - user->WriteNumeric(998, ":DCCALLOW command not understood. For help on DCCALLOW, type /DCCALLOW HELP"); + user->WriteNumeric(998, "DCCALLOW command not understood. For help on DCCALLOW, type /DCCALLOW HELP"); return CMD_FAILURE; } } @@ -143,7 +143,7 @@ class CommandDccallow : public Command if (i->nickname == target->nick) { dl->erase(i); - user->WriteNumeric(995, "%s :Removed %s from your DCCALLOW list", user->nick.c_str(), target->nick.c_str()); + user->WriteNumeric(995, user->nick, InspIRCd::Format("Removed %s from your DCCALLOW list", target->nick.c_str())); break; } } @@ -153,7 +153,7 @@ class CommandDccallow : public Command { if (target == user) { - user->WriteNumeric(996, "%s :You cannot add yourself to your own DCCALLOW list!", user->nick.c_str()); + user->WriteNumeric(996, user->nick, "You cannot add yourself to your own DCCALLOW list!"); return CMD_FAILURE; } @@ -168,7 +168,7 @@ class CommandDccallow : public Command if (dl->size() >= maxentries) { - user->WriteNumeric(996, "%s :Too many nicks on DCCALLOW list", user->nick.c_str()); + user->WriteNumeric(996, user->nick, "Too many nicks on DCCALLOW list"); return CMD_FAILURE; } @@ -176,7 +176,7 @@ class CommandDccallow : public Command { if (k->nickname == target->nick) { - user->WriteNumeric(996, "%s :%s is already on your DCCALLOW list", user->nick.c_str(), target->nick.c_str()); + user->WriteNumeric(996, user->nick, InspIRCd::Format("%s is already on your DCCALLOW list", target->nick.c_str())); return CMD_FAILURE; } } @@ -207,11 +207,11 @@ class CommandDccallow : public Command if (length > 0) { - user->WriteNumeric(993, "%s :Added %s to DCCALLOW list for %ld seconds", user->nick.c_str(), target->nick.c_str(), length); + user->WriteNumeric(993, user->nick, InspIRCd::Format("Added %s to DCCALLOW list for %ld seconds", target->nick.c_str(), length)); } else { - user->WriteNumeric(994, "%s :Added %s to DCCALLOW list for this session", user->nick.c_str(), target->nick.c_str()); + user->WriteNumeric(994, user->nick, InspIRCd::Format("Added %s to DCCALLOW list for this session", target->nick.c_str())); } /* route it. */ @@ -221,7 +221,7 @@ class CommandDccallow : public Command else { // nick doesn't exist - user->WriteNumeric(401, "%s :No such nick/channel", nick.c_str()); + user->WriteNumeric(Numerics::NoSuchNick(nick)); return CMD_FAILURE; } } @@ -236,8 +236,8 @@ class CommandDccallow : public Command void DisplayHelp(User* user) { for (size_t i = 0; i < sizeof(helptext)/sizeof(helptext[0]); i++) - user->WriteNumeric(998, ":%s", helptext[i]); - user->WriteNumeric(999, ":End of DCCALLOW HELP"); + user->WriteNumeric(998, helptext[i]); + user->WriteNumeric(999, "End of DCCALLOW HELP"); LocalUser* localuser = IS_LOCAL(user); if (localuser) @@ -247,18 +247,18 @@ class CommandDccallow : public Command void DisplayDCCAllowList(User* user) { // display current DCCALLOW list - user->WriteNumeric(990, ":Users on your DCCALLOW list:"); + user->WriteNumeric(990, "Users on your DCCALLOW list:"); dl = ext.get(user); if (dl) { for (dccallowlist::const_iterator c = dl->begin(); c != dl->end(); ++c) { - user->WriteNumeric(991, "%s :%s (%s)", user->nick.c_str(), c->nickname.c_str(), c->hostmask.c_str()); + user->WriteNumeric(991, user->nick, InspIRCd::Format("%s (%s)", c->nickname.c_str(), c->hostmask.c_str())); } } - user->WriteNumeric(992, ":End of DCCALLOW list"); + user->WriteNumeric(992, "End of DCCALLOW list"); } }; @@ -400,7 +400,7 @@ class ModuleDCCAllow : public Module { if (iter2->length != 0 && (iter2->set_on + iter2->length) <= ServerInstance->Time()) { - u->WriteNumeric(997, "%s :DCCALLOW entry for %s has expired", u->nick.c_str(), iter2->nickname.c_str()); + u->WriteNumeric(997, u->nick, InspIRCd::Format("DCCALLOW entry for %s has expired", iter2->nickname.c_str())); iter2 = dl->erase(iter2); } else @@ -435,7 +435,7 @@ class ModuleDCCAllow : public Module { u->WriteNotice(i->nickname + " left the network or changed their nickname and has been removed from your DCCALLOW list"); - u->WriteNumeric(995, "%s :Removed %s from your DCCALLOW list", u->nick.c_str(), i->nickname.c_str()); + u->WriteNumeric(995, u->nick, InspIRCd::Format("Removed %s from your DCCALLOW list", i->nickname.c_str())); dl->erase(i); break; } diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp index f64297e15..1ad41cc57 100644 --- a/src/modules/m_delaymsg.cpp +++ b/src/modules/m_delaymsg.cpp @@ -118,8 +118,7 @@ ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_ty { if (channel->GetPrefixValue(user) < VOICE_VALUE) { - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :You must wait %d seconds after joining to send to channel (+d)", - channel->name.c_str(), len); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, channel->name, InspIRCd::Format("You must wait %d seconds after joining to send to channel (+d)", len)); return MOD_RES_DENY; } } diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index 6378ba273..467c8a03b 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -113,13 +113,13 @@ class ModuleDenyChannels : public Module Channel *newchan = ServerInstance->FindChan(redirect); if ((!newchan) || (!newchan->IsModeSet(redirectmode))) { - user->WriteNumeric(926, "%s :Channel %s is forbidden, redirecting to %s: %s", cname.c_str(),cname.c_str(),redirect.c_str(), reason.c_str()); + user->WriteNumeric(926, cname, InspIRCd::Format("Channel %s is forbidden, redirecting to %s: %s", cname.c_str(), redirect.c_str(), reason.c_str())); Channel::JoinUser(user, redirect); return MOD_RES_DENY; } } - user->WriteNumeric(926, "%s :Channel %s is forbidden: %s", cname.c_str(),cname.c_str(),reason.c_str()); + user->WriteNumeric(926, cname, InspIRCd::Format("Channel %s is forbidden: %s", cname.c_str(), reason.c_str())); return MOD_RES_DENY; } } diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 5eaa8c279..726ee1351 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -117,13 +117,13 @@ class DNSBLResolver : public DNS::Request { if (!ConfEntry->ident.empty()) { - them->WriteNumeric(304, ":Your ident has been set to " + ConfEntry->ident + " because you matched " + reason); + them->WriteNumeric(304, "Your ident has been set to " + ConfEntry->ident + " because you matched " + reason); them->ChangeIdent(ConfEntry->ident); } if (!ConfEntry->host.empty()) { - them->WriteNumeric(304, ":Your host has been set to " + ConfEntry->host + " because you matched " + reason); + them->WriteNumeric(304, "Your host has been set to " + ConfEntry->host + " because you matched " + reason); them->ChangeDisplayedHost(ConfEntry->host); } diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp index 076445644..2884385fb 100644 --- a/src/modules/m_exemptchanops.cpp +++ b/src/modules/m_exemptchanops.cpp @@ -32,7 +32,7 @@ class ExemptChanOps : public ListModeBase std::string::size_type p = word.find(':'); if (p == std::string::npos) { - user->WriteNumeric(955, "%s %s :Invalid exemptchanops entry, format is :", chan->name.c_str(), word.c_str()); + user->WriteNumeric(955, chan->name, word, "Invalid exemptchanops entry, format is :"); return false; } @@ -45,7 +45,7 @@ class ExemptChanOps : public ListModeBase if (!ServerInstance->Modes->FindMode(restriction, MODETYPE_CHANNEL)) { - user->WriteNumeric(955, "%s %s :Unknown restriction", chan->name.c_str(), restriction.c_str()); + user->WriteNumeric(955, chan->name, restriction, "Unknown restriction"); return false; } @@ -54,17 +54,17 @@ class ExemptChanOps : public ListModeBase void TellListTooLong(User* user, Channel* chan, std::string &word) { - user->WriteNumeric(959, "%s %s :Channel exemptchanops list is full", chan->name.c_str(), word.c_str()); + user->WriteNumeric(959, chan->name, word, "Channel exemptchanops list is full"); } void TellAlreadyOnList(User* user, Channel* chan, std::string &word) { - user->WriteNumeric(957, "%s :The word %s is already on the exemptchanops list", chan->name.c_str(), word.c_str()); + user->WriteNumeric(957, chan->name, InspIRCd::Format("The word %s is already on the exemptchanops list", word.c_str())); } void TellNotSet(User* user, Channel* chan, std::string &word) { - user->WriteNumeric(958, "%s :No such exemptchanops word is set", chan->name.c_str()); + user->WriteNumeric(958, chan->name, "No such exemptchanops word is set"); } }; diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 34d0bebb3..bd1022a08 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -343,14 +343,14 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, void* dest, int target_type { ServerInstance->SNO->WriteGlobalSno('a', "FILTER: "+user->nick+" had their message filtered, target was "+target+": "+f->reason); if (target_type == TYPE_CHANNEL) - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Message to channel blocked and opers notified (%s)", target.c_str(), f->reason.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked and opers notified (%s)", f->reason.c_str())); else user->WriteNotice("Your message to "+target+" was blocked and opers notified: "+f->reason); } else if (f->action == FA_SILENT) { if (target_type == TYPE_CHANNEL) - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Message to channel blocked (%s)", target.c_str(), f->reason.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked (%s)", f->reason.c_str())); else user->WriteNotice("Your message to "+target+" was blocked: "+f->reason); } diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp index 294187fa5..2355cc979 100644 --- a/src/modules/m_globalload.cpp +++ b/src/modules/m_globalload.cpp @@ -44,11 +44,11 @@ class CommandGloadmodule : public Command if (ServerInstance->Modules->Load(parameters[0].c_str())) { ServerInstance->SNO->WriteToSnoMask('a', "NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0].c_str(), user->nick.c_str()); - user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module successfully loaded.", parameters[0].c_str()); + user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "Module successfully loaded."); } else { - user->WriteNumeric(ERR_CANTLOADMODULE, "%s :%s", parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(ERR_CANTLOADMODULE, parameters[0], ServerInstance->Modules->LastError()); } } else @@ -79,7 +79,7 @@ class CommandGunloadmodule : public Command if (!ServerInstance->Config->ConfValue("security")->getBool("allowcoreunload") && InspIRCd::Match(parameters[0], "core_*.so", ascii_case_insensitive_map)) { - user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :You cannot unload core commands!", parameters[0].c_str()); + user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], "You cannot unload core commands!"); return CMD_FAILURE; } @@ -98,7 +98,7 @@ class CommandGunloadmodule : public Command } else { - user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s :%s", parameters[0].c_str(), ServerInstance->Modules->LastError().c_str()); + user->WriteNumeric(ERR_CANTUNLOADMODULE, parameters[0], ServerInstance->Modules->LastError()); } } else @@ -140,7 +140,7 @@ class CommandGreloadmodule : public Command } else { - user->WriteNumeric(RPL_LOADEDMODULE, "%s :Could not find module by that name", parameters[0].c_str()); + user->WriteNumeric(RPL_LOADEDMODULE, parameters[0], "Could not find module by that name"); return CMD_FAILURE; } } diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index ef9ae5e22..f567aa076 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -57,15 +57,15 @@ class CommandHelpop : public Command if (parameter == "index") { /* iterate over all helpop items */ - user->WriteNumeric(290, ":HELPOP topic index"); + user->WriteNumeric(290, "HELPOP topic index"); for (HelpopMap::const_iterator iter = helpop_map.begin(); iter != helpop_map.end(); iter++) - user->WriteNumeric(292, ": %s", iter->first.c_str()); - user->WriteNumeric(292, ":*** End of HELPOP topic index"); + user->WriteNumeric(292, InspIRCd::Format(" %s", iter->first.c_str())); + user->WriteNumeric(292, "*** End of HELPOP topic index"); } else { - user->WriteNumeric(290, ":*** HELPOP for %s", parameter.c_str()); - user->WriteNumeric(292, ": -"); + user->WriteNumeric(290, InspIRCd::Format("*** HELPOP for %s", parameter.c_str())); + user->WriteNumeric(292, " -"); HelpopMap::const_iterator iter = helpop_map.find(parameter); @@ -82,13 +82,13 @@ class CommandHelpop : public Command { // Writing a blank line will not work with some clients if (token.empty()) - user->WriteNumeric(292, ": "); + user->WriteNumeric(292, ' '); else - user->WriteNumeric(292, ":%s", token.c_str()); + user->WriteNumeric(292, token); } - user->WriteNumeric(292, ": -"); - user->WriteNumeric(292, ":*** End of HELPOP"); + user->WriteNumeric(292, " -"); + user->WriteNumeric(292, "*** End of HELPOP"); } return CMD_SUCCESS; } diff --git a/src/modules/m_hidelist.cpp b/src/modules/m_hidelist.cpp index cde8371fc..97173c14b 100644 --- a/src/modules/m_hidelist.cpp +++ b/src/modules/m_hidelist.cpp @@ -46,7 +46,7 @@ class ListWatcher : public ModeWatcher if (user->HasPrivPermission("channels/auspex")) return true; - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have access to view the %s list", chan->name.c_str(), GetModeName().c_str()); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You do not have access to view the %s list", GetModeName().c_str())); return false; } }; diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index 03f6745ee..b90f3f234 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -71,9 +71,9 @@ class ModuleHideOper : public Module, public Whois::LineEventListener hm.opercount--; } - ModResult OnNumeric(User* user, unsigned int numeric, const std::string& text) CXX11_OVERRIDE + ModResult OnNumeric(User* user, const Numeric::Numeric& numeric) CXX11_OVERRIDE { - if (numeric != 252 || active || user->HasPrivPermission("users/auspex")) + if (numeric.GetNumeric() != 252 || active || user->HasPrivPermission("users/auspex")) return MOD_RES_PASSTHRU; // If there are no visible operators then we shouldn't send the numeric. @@ -81,7 +81,7 @@ class ModuleHideOper : public Module, public Whois::LineEventListener if (opercount) { active = true; - user->WriteNumeric(252, "%lu :operator(s) online", opercount); + user->WriteNumeric(252, opercount, "operator(s) online"); active = false; } return MOD_RES_DENY; diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 541e080f5..eb8e856ac 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -109,10 +109,12 @@ class ModuleHttpStats : public Module, public HTTPRequestEventListener data << "" << ServerInstance->startup_time << ""; data << ""; - const std::vector& isupport = ServerInstance->ISupport.GetLines(); - for (std::vector::const_iterator it = isupport.begin(); it != isupport.end(); it++) + const std::vector& isupport = ServerInstance->ISupport.GetLines(); + for (std::vector::const_iterator i = isupport.begin(); i != isupport.end(); ++i) { - data << Sanitize(*it) << std::endl; + const Numeric::Numeric& num = *i; + for (std::vector::const_iterator j = num.GetParams().begin(); j != num.GetParams().end()-1; ++j) + data << "" << Sanitize(*j) << "" << std::endl; } data << ""; std::vector xltypes = ServerInstance->XLines->GetAllTypes(); diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index 52802f168..56e109c1a 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -95,7 +95,7 @@ class JoinFlood : public ParamMode > std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { - source->WriteNumeric(608, "%s :Invalid flood parameter",channel->name.c_str()); + source->WriteNumeric(608, channel->name, "Invalid flood parameter"); return MODEACTION_DENY; } @@ -104,7 +104,7 @@ class JoinFlood : public ParamMode > unsigned int nsecs = ConvToInt(parameter.substr(colon+1)); if ((njoins<1) || (nsecs<1)) { - source->WriteNumeric(608, "%s :Invalid flood parameter",channel->name.c_str()); + source->WriteNumeric(608, channel->name, "Invalid flood parameter"); return MODEACTION_DENY; } @@ -136,7 +136,7 @@ class ModuleJoinFlood : public Module joinfloodsettings *f = jf.ext.get(chan); if (f && f->islocked()) { - user->WriteNumeric(609, "%s :This channel is temporarily unavailable (+j). Please try again later.",chan->name.c_str()); + user->WriteNumeric(609, chan->name, "This channel is temporarily unavailable (+j). Please try again later."); return MOD_RES_DENY; } } diff --git a/src/modules/m_jumpserver.cpp b/src/modules/m_jumpserver.cpp index e9c07f45f..33b9bcd35 100644 --- a/src/modules/m_jumpserver.cpp +++ b/src/modules/m_jumpserver.cpp @@ -116,7 +116,7 @@ class CommandJumpserver : public Command ++i; if (!t->IsOper()) { - t->WriteNumeric(RPL_REDIR, "%s %d :Please use this Server/Port instead", parameters[0].c_str(), GetPort(t)); + t->WriteNumeric(RPL_REDIR, parameters[0], GetPort(t), "Please use this Server/Port instead"); ServerInstance->Users->QuitUser(t, reason); n_done++; } @@ -160,8 +160,7 @@ class ModuleJumpServer : public Module if (js.redirect_new_users) { int port = js.GetPort(user); - user->WriteNumeric(RPL_REDIR, "%s %d :Please use this Server/Port instead", - js.redirect_to.c_str(), port); + user->WriteNumeric(RPL_REDIR, js.redirect_to, port, "Please use this Server/Port instead"); ServerInstance->Users->QuitUser(user, js.reason); return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index b8a776667..ad8bfdcb6 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -132,7 +132,7 @@ public: const KickRejoinData* data = kr.ext.get(chan); if ((data) && (!data->canjoin(user))) { - user->WriteNumeric(ERR_DELAYREJOIN, "%s :You must wait %u seconds after being kicked to rejoin (+J)", chan->name.c_str(), data->delay); + user->WriteNumeric(ERR_DELAYREJOIN, chan, InspIRCd::Format("You must wait %u seconds after being kicked to rejoin (+J)", data->delay)); return MOD_RES_DENY; } } diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index 26397bc9c..545c2dc14 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -45,25 +45,25 @@ class CommandKnock : public Command Channel* c = ServerInstance->FindChan(parameters[0]); if (!c) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } if (c->HasUser(user)) { - user->WriteNumeric(ERR_KNOCKONCHAN, "%s :Can't KNOCK on %s, you are already on that channel.", c->name.c_str(), c->name.c_str()); + user->WriteNumeric(ERR_KNOCKONCHAN, c->name, InspIRCd::Format("Can't KNOCK on %s, you are already on that channel.", c->name.c_str())); return CMD_FAILURE; } if (c->IsModeSet(noknockmode)) { - user->WriteNumeric(480, ":Can't KNOCK on %s, +K is set.", c->name.c_str()); + user->WriteNumeric(480, InspIRCd::Format("Can't KNOCK on %s, +K is set.", c->name.c_str())); return CMD_FAILURE; } if (!c->IsModeSet(inviteonlymode)) { - user->WriteNumeric(ERR_CHANOPEN, "%s :Can't KNOCK on %s, channel is not invite only so knocking is pointless!", c->name.c_str(), c->name.c_str()); + user->WriteNumeric(ERR_CHANOPEN, c->name, InspIRCd::Format("Can't KNOCK on %s, channel is not invite only so knocking is pointless!", c->name.c_str())); return CMD_FAILURE; } diff --git a/src/modules/m_lockserv.cpp b/src/modules/m_lockserv.cpp index 65b9aa036..ffcc04682 100644 --- a/src/modules/m_lockserv.cpp +++ b/src/modules/m_lockserv.cpp @@ -44,7 +44,7 @@ class CommandLockserv : public Command } locked = true; - user->WriteNumeric(988, "%s :Closed for new connections", user->server->GetName().c_str()); + user->WriteNumeric(988, user->server->GetName(), "Closed for new connections"); ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used LOCKSERV to temporarily disallow new connections", user->nick.c_str()); return CMD_SUCCESS; } @@ -69,7 +69,7 @@ class CommandUnlockserv : public Command } locked = false; - user->WriteNumeric(989, "%s :Open for new connections", user->server->GetName().c_str()); + user->WriteNumeric(989, user->server->GetName(), "Open for new connections"); ServerInstance->SNO->WriteGlobalSno('a', "Oper %s used UNLOCKSERV to allow new connections", user->nick.c_str()); return CMD_SUCCESS; } diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 1faf3bfb9..c5c872169 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -73,7 +73,7 @@ class MsgFlood : public ParamMode > std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { - source->WriteNumeric(608, "%s :Invalid flood parameter", channel->name.c_str()); + source->WriteNumeric(608, channel->name, "Invalid flood parameter"); return MODEACTION_DENY; } @@ -84,7 +84,7 @@ class MsgFlood : public ParamMode > if ((nlines<2) || (nsecs<1)) { - source->WriteNumeric(608, "%s :Invalid flood parameter", channel->name.c_str()); + source->WriteNumeric(608, channel->name, "Invalid flood parameter"); return MODEACTION_DENY; } diff --git a/src/modules/m_mlock.cpp b/src/modules/m_mlock.cpp index 9b0fa8dab..d3ab5b9fd 100644 --- a/src/modules/m_mlock.cpp +++ b/src/modules/m_mlock.cpp @@ -50,8 +50,7 @@ class ModuleMLock : public Module std::string::size_type p = mlock_str->find(mode); if (p != std::string::npos) { - source->WriteNumeric(742, "%s %c %s :MODE cannot be set due to channel having an active MLOCK restriction policy", - channel->name.c_str(), mode, mlock_str->c_str()); + source->WriteNumeric(742, channel->name, mode, *mlock_str, "MODE cannot be set due to channel having an active MLOCK restriction policy"); return MOD_RES_DENY; } diff --git a/src/modules/m_monitor.cpp b/src/modules/m_monitor.cpp index 139c70e76..b2e06f191 100644 --- a/src/modules/m_monitor.cpp +++ b/src/modules/m_monitor.cpp @@ -285,7 +285,7 @@ class CommandMonitor : public SplitCommand if (result == IRCv3::Monitor::Manager::WR_TOOMANY) { // List is full, send error which includes the remaining nicks that were not processed - user->WriteNumeric(ERR_MONLISTFULL, "%u %s%s%s :Monitor list is full", maxmonitor, nick.c_str(), (ss.StreamEnd() ? "" : ","), ss.GetRemaining().c_str()); + user->WriteNumeric(ERR_MONLISTFULL, maxmonitor, InspIRCd::Format("%s%s%s", nick.c_str(), (ss.StreamEnd() ? "" : ","), ss.GetRemaining().c_str()), "Monitor list is full"); break; } else if (result != IRCv3::Monitor::Manager::WR_OK) @@ -346,7 +346,7 @@ class CommandMonitor : public SplitCommand out.Add(entry->GetNick()); } out.Flush(); - user->WriteNumeric(RPL_ENDOFMONLIST, ":End of MONITOR list"); + user->WriteNumeric(RPL_ENDOFMONLIST, "End of MONITOR list"); } else if (subcmd == 'S') { diff --git a/src/modules/m_muteban.cpp b/src/modules/m_muteban.cpp index 72c4acd47..c9caf6a6a 100644 --- a/src/modules/m_muteban.cpp +++ b/src/modules/m_muteban.cpp @@ -36,7 +36,7 @@ class ModuleQuietBan : public Module Channel* chan = static_cast(dest); if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE) { - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're muted)", chan->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're muted)"); return MOD_RES_DENY; } diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp index 617ee43b3..10bef981a 100644 --- a/src/modules/m_namedmodes.cpp +++ b/src/modules/m_namedmodes.cpp @@ -39,7 +39,7 @@ static void DisplayList(User* user, Channel* channel) } const std::string line = ":" + ServerInstance->Config->ServerName + " 961 " + user->nick + " " + channel->name; user->SendText(line, items); - user->WriteNumeric(960, "%s :End of mode list", channel->name.c_str()); + user->WriteNumeric(960, channel->name, "End of mode list"); } class CommandProp : public Command @@ -55,7 +55,7 @@ class CommandProp : public Command Channel* const chan = ServerInstance->FindChan(parameters[0]); if (!chan) { - src->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + src->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index cade0b1db..0af1041f9 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -91,7 +91,7 @@ class NickFlood : public ParamMode > std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { - source->WriteNumeric(608, "%s :Invalid flood parameter",channel->name.c_str()); + source->WriteNumeric(608, channel->name, "Invalid flood parameter"); return MODEACTION_DENY; } @@ -101,7 +101,7 @@ class NickFlood : public ParamMode > if ((nnicks<1) || (nsecs<1)) { - source->WriteNumeric(608, "%s :Invalid flood parameter",channel->name.c_str()); + source->WriteNumeric(608, channel->name, "Invalid flood parameter"); return MODEACTION_DENY; } @@ -142,7 +142,7 @@ class ModuleNickFlood : public Module if (f->islocked()) { - user->WriteNumeric(ERR_CANTCHANGENICK, ":%s has been locked for nickchanges for 60 seconds because there have been more than %u nick changes in %u seconds", channel->name.c_str(), f->nicks, f->secs); + user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("%s has been locked for nickchanges for 60 seconds because there have been more than %u nick changes in %u seconds", channel->name.c_str(), f->nicks, f->secs)); return MOD_RES_DENY; } diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp index a99628bf1..634982d14 100644 --- a/src/modules/m_nicklock.cpp +++ b/src/modules/m_nicklock.cpp @@ -55,7 +55,7 @@ class CommandNicklock : public Command return CMD_FAILURE; } - user->WriteNumeric(947, "%s :Nickname now locked.", parameters[1].c_str()); + user->WriteNumeric(947, parameters[1], "Nickname now locked."); } /* If we made it this far, extend the user */ @@ -159,7 +159,7 @@ class ModuleNickLock : public Module { if (locked.get(user)) { - user->WriteNumeric(ERR_CANTCHANGENICK, ":You cannot change your nickname (your nick is locked)"); + user->WriteNumeric(ERR_CANTCHANGENICK, "You cannot change your nickname (your nick is locked)"); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp index 953557d90..49b53ee95 100644 --- a/src/modules/m_noctcp.cpp +++ b/src/modules/m_noctcp.cpp @@ -56,7 +56,7 @@ class ModuleNoCTCP : public Module if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet(nc))) { - user->WriteNumeric(ERR_NOCTCPALLOWED, "%s :Can't send CTCP to channel (+C set)", c->name.c_str()); + user->WriteNumeric(ERR_NOCTCPALLOWED, c->name, "Can't send CTCP to channel (+C set)"); return MOD_RES_DENY; } } diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp index 0acf84118..fb3455567 100644 --- a/src/modules/m_nokicks.cpp +++ b/src/modules/m_nokicks.cpp @@ -48,7 +48,7 @@ class ModuleNoKicks : public Module if (!memb->chan->GetExtBanStatus(source, 'Q').check(!memb->chan->IsModeSet(nk))) { // Can't kick with Q in place, not even opers with override, and founders - source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :Can't kick user %s from channel (+Q set)", memb->chan->name.c_str(), memb->user->nick.c_str()); + source->WriteNumeric(ERR_CHANOPRIVSNEEDED, memb->chan->name, InspIRCd::Format("Can't kick user %s from channel (+Q set)", memb->user->nick.c_str())); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp index 63815f2bf..d4da3e951 100644 --- a/src/modules/m_nonicks.cpp +++ b/src/modules/m_nonicks.cpp @@ -62,8 +62,8 @@ class ModuleNoNickChange : public Module if (!curr->GetExtBanStatus(user, 'N').check(!curr->IsModeSet(nn))) { - user->WriteNumeric(ERR_CANTCHANGENICK, ":Can't change nickname while on %s (+N is set)", - curr->name.c_str()); + user->WriteNumeric(ERR_CANTCHANGENICK, InspIRCd::Format("Can't change nickname while on %s (+N is set)", + curr->name.c_str())); return MOD_RES_DENY; } } diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp index cab367ad9..3d6d0bb09 100644 --- a/src/modules/m_nonotice.cpp +++ b/src/modules/m_nonotice.cpp @@ -55,7 +55,7 @@ class ModuleNoNotice : public Module return MOD_RES_PASSTHRU; else { - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Can't send NOTICE to channel (+T set)", c->name.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send NOTICE to channel (+T set)"); return MOD_RES_DENY; } } diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index 1444f93ad..88b63bef2 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -146,7 +146,7 @@ class ModuleOjoin : public Module if (source == memb->user) return MOD_RES_PASSTHRU; - source->WriteNumeric(ERR_RESTRICTED, memb->chan->name+" :Can't kick "+memb->user->nick+" as they're on official network business."); + source->WriteNumeric(ERR_RESTRICTED, memb->chan->name, "Can't kick "+memb->user->nick+" as they're on official network business."); return MOD_RES_DENY; } diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp index 3c6b4cd59..0b074ebab 100644 --- a/src/modules/m_operchans.cpp +++ b/src/modules/m_operchans.cpp @@ -44,8 +44,7 @@ class ModuleOperChans : public Module { if (chan && chan->IsModeSet(oc) && !user->IsOper()) { - user->WriteNumeric(ERR_CANTJOINOPERSONLY, "%s :Only IRC operators may join %s (+O is set)", - chan->name.c_str(), chan->name.c_str()); + user->WriteNumeric(ERR_CANTJOINOPERSONLY, chan->name, InspIRCd::Format("Only IRC operators may join %s (+O is set)", chan->name.c_str())); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp index ac7178a93..bf758b1f7 100644 --- a/src/modules/m_operlevels.cpp +++ b/src/modules/m_operlevels.cpp @@ -44,7 +44,7 @@ class ModuleOperLevels : public Module { if (IS_LOCAL(source)) ServerInstance->SNO->WriteGlobalSno('a', "Oper %s (level %ld) attempted to /kill a higher oper: %s (level %ld): Reason: %s",source->nick.c_str(),source_level,dest->nick.c_str(),dest_level,reason.c_str()); dest->WriteNotice("*** Oper " + source->nick + " attempted to /kill you!"); - source->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - Oper %s is a higher level than you", dest->nick.c_str()); + source->WriteNumeric(ERR_NOPRIVILEGES, InspIRCd::Format("Permission Denied - Oper %s is a higher level than you", dest->nick.c_str())); return MOD_RES_DENY; } } diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index e822676bf..b14de9ff9 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -38,7 +38,7 @@ class Redirect : public ParamMode { if (!ServerInstance->IsChannel(parameter)) { - source->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :Invalid channel name", parameter.c_str()); + source->WriteNumeric(ERR_NOSUCHCHANNEL, parameter, "Invalid channel name"); return MODEACTION_DENY; } } @@ -48,12 +48,12 @@ class Redirect : public ParamMode Channel* c = ServerInstance->FindChan(parameter); if (!c) { - source->WriteNumeric(690, ":Target channel %s must exist to be set as a redirect.",parameter.c_str()); + source->WriteNumeric(690, InspIRCd::Format("Target channel %s must exist to be set as a redirect.", parameter.c_str())); return MODEACTION_DENY; } else if (c->GetPrefixValue(source) < OP_VALUE) { - source->WriteNumeric(690, ":You must be opped on %s to set it as a redirect.",parameter.c_str()); + source->WriteNumeric(690, InspIRCd::Format("You must be opped on %s to set it as a redirect.", parameter.c_str())); return MODEACTION_DENY; } } @@ -119,19 +119,19 @@ class ModuleRedirect : public Module Channel* destchan = ServerInstance->FindChan(channel); if (destchan && destchan->IsModeSet(re)) { - user->WriteNumeric(470, "%s * :You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop.", cname.c_str()); + user->WriteNumeric(470, cname, '*', "You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop."); return MOD_RES_DENY; } /* We check the bool value here to make sure we have it enabled, if we don't then usermode +L might be assigned to something else. */ if (UseUsermode && user->IsModeSet(re_u)) { - user->WriteNumeric(470, "%s %s :Force redirection stopped.", cname.c_str(), channel.c_str()); + user->WriteNumeric(470, cname, channel, "Force redirection stopped."); return MOD_RES_DENY; } else { - user->WriteNumeric(470, "%s %s :You may not join this channel, so you are automatically being transferred to the redirect channel.", cname.c_str(), channel.c_str()); + user->WriteNumeric(470, cname, channel, "You may not join this channel, so you are automatically being transferred to the redirect channel."); Channel::JoinUser(user, channel); return MOD_RES_DENY; } diff --git a/src/modules/m_regonlycreate.cpp b/src/modules/m_regonlycreate.cpp index 0ffe5e085..78b20ef6b 100644 --- a/src/modules/m_regonlycreate.cpp +++ b/src/modules/m_regonlycreate.cpp @@ -49,7 +49,7 @@ class ModuleRegOnlyCreate : public Module return MOD_RES_PASSTHRU; // XXX. there may be a better numeric for this.. - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must have a registered nickname to create a new channel", cname.c_str()); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, cname, "You must have a registered nickname to create a new channel"); return MOD_RES_DENY; } diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index 8d0009d71..5b0efe2a2 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -76,7 +76,7 @@ class RemoveBase : public Command /* Fix by brain - someone needs to learn to validate their input! */ if ((!target) || (target->registered != REG_ALL) || (!channel)) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", !channel ? channame.c_str() : username.c_str()); + user->WriteNumeric(Numerics::NoSuchNick(channel ? username.c_str() : channame.c_str())); return CMD_FAILURE; } @@ -88,7 +88,7 @@ class RemoveBase : public Command if (target->server->IsULine()) { - user->WriteNumeric(482, "%s :Only a u-line may remove a u-line from a channel.", channame.c_str()); + user->WriteNumeric(482, channame, "Only a u-line may remove a u-line from a channel."); return CMD_FAILURE; } @@ -144,7 +144,7 @@ class RemoveBase : public Command else { /* m_nokicks.so was loaded and +Q was set, block! */ - user->WriteNumeric(ERR_RESTRICTED, "%s :Can't remove user %s from channel (nokicks mode is set)", channel->name.c_str(), target->nick.c_str()); + user->WriteNumeric(ERR_RESTRICTED, channel->name, InspIRCd::Format("Can't remove user %s from channel (nokicks mode is set)", target->nick.c_str())); return CMD_FAILURE; } diff --git a/src/modules/m_restrictchans.cpp b/src/modules/m_restrictchans.cpp index 9e660e8ed..9c7ed1213 100644 --- a/src/modules/m_restrictchans.cpp +++ b/src/modules/m_restrictchans.cpp @@ -47,7 +47,7 @@ class ModuleRestrictChans : public Module // user is not an oper and its not in the allow list if ((!user->IsOper()) && (allowchans.find(cname) == allowchans.end())) { - user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s :Only IRC operators may create new channels", cname.c_str()); + user->WriteNumeric(ERR_BANNEDFROMCHAN, cname, "Only IRC operators may create new channels"); return MOD_RES_DENY; } } diff --git a/src/modules/m_restrictmsg.cpp b/src/modules/m_restrictmsg.cpp index 279775d48..8ca531ed5 100644 --- a/src/modules/m_restrictmsg.cpp +++ b/src/modules/m_restrictmsg.cpp @@ -39,7 +39,7 @@ class ModuleRestrictMsg : public Module { return MOD_RES_PASSTHRU; } - user->WriteNumeric(ERR_CANTSENDTOUSER, "%s :You are not permitted to send private messages to this user", u->nick.c_str()); + user->WriteNumeric(ERR_CANTSENDTOUSER, u->nick, "You are not permitted to send private messages to this user"); return MOD_RES_DENY; } diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp index d1321947b..9696b08a1 100644 --- a/src/modules/m_sajoin.cpp +++ b/src/modules/m_sajoin.cpp @@ -53,7 +53,7 @@ class CommandSajoin : public Command if (dest->server->IsULine()) { - user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client"); + user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client"); return CMD_FAILURE; } if (IS_LOCAL(user) && !ServerInstance->IsChannel(channel)) diff --git a/src/modules/m_sakick.cpp b/src/modules/m_sakick.cpp index 911b826dc..8fc6e741b 100644 --- a/src/modules/m_sakick.cpp +++ b/src/modules/m_sakick.cpp @@ -42,7 +42,7 @@ class CommandSakick : public Command if (dest->server->IsULine()) { - user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client"); + user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client"); return CMD_FAILURE; } diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp index 8b06118ee..bcb876d5b 100644 --- a/src/modules/m_samode.cpp +++ b/src/modules/m_samode.cpp @@ -42,7 +42,7 @@ class CommandSamode : public Command User* target = ServerInstance->FindNickOnly(parameters[0]); if ((!target) || (target->registered != REG_ALL)) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp index ba265fddd..fd9a825dd 100644 --- a/src/modules/m_sanick.cpp +++ b/src/modules/m_sanick.cpp @@ -42,7 +42,7 @@ class CommandSanick : public Command { if (target && target->server->IsULine()) { - user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client"); + user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client"); return CMD_FAILURE; } diff --git a/src/modules/m_sapart.cpp b/src/modules/m_sapart.cpp index 730bf0823..65c32cd8a 100644 --- a/src/modules/m_sapart.cpp +++ b/src/modules/m_sapart.cpp @@ -48,7 +48,7 @@ class CommandSapart : public Command if (dest->server->IsULine()) { - user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client"); + user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client"); return CMD_FAILURE; } diff --git a/src/modules/m_saquit.cpp b/src/modules/m_saquit.cpp index fb1c67564..4d5ac6e22 100644 --- a/src/modules/m_saquit.cpp +++ b/src/modules/m_saquit.cpp @@ -39,7 +39,7 @@ class CommandSaquit : public Command { if (dest->server->IsULine()) { - user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client"); + user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client"); return CMD_FAILURE; } diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 6e3086930..e749d16b4 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -142,7 +142,7 @@ class SaslAuthenticator this->result = this->GetSaslResult(msg[3]); } else if (msg[2] == "M") - this->user->WriteNumeric(908, "%s :are available SASL mechanisms", msg[3].c_str()); + this->user->WriteNumeric(908, msg[3], "are available SASL mechanisms"); else ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Services sent an unknown SASL message \"%s\" \"%s\"", msg[2].c_str(), msg[3].c_str()); @@ -194,13 +194,13 @@ class SaslAuthenticator switch (this->result) { case SASL_OK: - this->user->WriteNumeric(903, ":SASL authentication successful"); + this->user->WriteNumeric(903, "SASL authentication successful"); break; case SASL_ABORT: - this->user->WriteNumeric(906, ":SASL authentication aborted"); + this->user->WriteNumeric(906, "SASL authentication aborted"); break; case SASL_FAIL: - this->user->WriteNumeric(904, ":SASL authentication failed"); + this->user->WriteNumeric(904, "SASL authentication failed"); break; default: break; diff --git a/src/modules/m_satopic.cpp b/src/modules/m_satopic.cpp index 4a6f85536..040d86b9a 100644 --- a/src/modules/m_satopic.cpp +++ b/src/modules/m_satopic.cpp @@ -46,7 +46,7 @@ class CommandSATopic : public Command } else { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } } diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index f4042b8f6..b6c6ce174 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -66,8 +66,8 @@ class ModuleSecureList : public Module /* Some crap clients (read: mIRC, various java chat applets) muck up if they don't * receive these numerics whenever they send LIST, so give them an empty LIST to mull over. */ - user->WriteNumeric(RPL_LISTSTART, "Channel :Users Name"); - user->WriteNumeric(RPL_LISTEND, ":End of channel list."); + user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name"); + user->WriteNumeric(RPL_LISTEND, "End of channel list."); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index 48ab511f0..048e04a5a 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -46,7 +46,7 @@ class Channel_r : public ModeHandler } else { - source->WriteNumeric(500, ":Only a server may modify the +r channel mode"); + source->WriteNumeric(500, "Only a server may modify the +r channel mode"); } return MODEACTION_DENY; } @@ -72,7 +72,7 @@ class User_r : public ModeHandler } else { - source->WriteNumeric(500, ":Only a server may modify the +r user mode"); + source->WriteNumeric(500, "Only a server may modify the +r user mode"); } return MODEACTION_DENY; } @@ -128,8 +128,7 @@ class AccountExtItemImpl : public AccountExtItem // Logged in if (IS_LOCAL(user)) { - user->WriteNumeric(900, "%s %s :You are now logged in as %s", - user->GetFullHost().c_str(), value.c_str(), value.c_str()); + user->WriteNumeric(900, user->GetFullHost(), value, InspIRCd::Format("You are now logged in as %s", value.c_str())); } } // If value is empty then logged out @@ -202,7 +201,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener if (c->IsModeSet(m2) && !is_registered && res != MOD_RES_ALLOW) { // user messaging a +M channel and is not registered - user->WriteNumeric(477, c->name+" :You need to be identified to a registered account to message this channel"); + user->WriteNumeric(477, c->name, "You need to be identified to a registered account to message this channel"); return MOD_RES_DENY; } } @@ -213,7 +212,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener if (u->IsModeSet(m3) && !is_registered) { // user messaging a +R user and is not registered - user->WriteNumeric(477, u->nick +" :You need to be identified to a registered account to message this user"); + user->WriteNumeric(477, u->nick, "You need to be identified to a registered account to message this user"); return MOD_RES_DENY; } } @@ -268,7 +267,7 @@ class ModuleServicesAccount : public Module, public Whois::EventListener if (!is_registered) { // joining a +R channel and not identified - user->WriteNumeric(477, chan->name + " :You need to be identified to a registered account to join this channel"); + user->WriteNumeric(477, chan->name, "You need to be identified to a registered account to join this channel"); return MOD_RES_DENY; } } diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp index 0445235dc..34f730c62 100644 --- a/src/modules/m_servprotect.cpp +++ b/src/modules/m_servprotect.cpp @@ -86,7 +86,7 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public if (u->IsModeSet(bm) && memb && memb->hasMode(mh->GetModeChar())) { /* BZZZT, Denied! */ - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You are not permitted to remove privileges from %s services", chan->name.c_str(), ServerInstance->Config->Network.c_str()); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You are not permitted to remove privileges from %s services", ServerInstance->Config->Network.c_str())); return MOD_RES_DENY; } } @@ -102,7 +102,7 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public if (dst->IsModeSet(bm)) { - src->WriteNumeric(485, ":You are not permitted to kill %s services!", ServerInstance->Config->Network.c_str()); + src->WriteNumeric(485, InspIRCd::Format("You are not permitted to kill %s services!", ServerInstance->Config->Network.c_str())); ServerInstance->SNO->WriteGlobalSno('a', src->nick+" tried to kill service "+dst->nick+" ("+reason+")"); return MOD_RES_DENY; } @@ -113,8 +113,7 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public { if (memb->user->IsModeSet(bm)) { - src->WriteNumeric(ERR_RESTRICTED, "%s :You are not permitted to kick services", - memb->chan->name.c_str()); + src->WriteNumeric(ERR_RESTRICTED, memb->chan->name, "You are not permitted to kick services"); return MOD_RES_DENY; } diff --git a/src/modules/m_setidle.cpp b/src/modules/m_setidle.cpp index dd82aef29..4a15fd0d5 100644 --- a/src/modules/m_setidle.cpp +++ b/src/modules/m_setidle.cpp @@ -36,7 +36,7 @@ class CommandSetidle : public SplitCommand int idle = InspIRCd::Duration(parameters[0]); if (idle < 1) { - user->WriteNumeric(948, ":Invalid idle time."); + user->WriteNumeric(948, "Invalid idle time."); return CMD_FAILURE; } user->idle_lastmsg = (ServerInstance->Time() - idle); @@ -44,7 +44,7 @@ class CommandSetidle : public SplitCommand if (user->signon > user->idle_lastmsg) user->signon = user->idle_lastmsg; ServerInstance->SNO->WriteToSnoMask('a', user->nick+" used SETIDLE to set their idle time to "+ConvToStr(idle)+" seconds"); - user->WriteNumeric(944, ":Idle time set."); + user->WriteNumeric(944, "Idle time set."); return CMD_SUCCESS; } diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index f2ac26fb3..7d3b3f90c 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -125,10 +125,10 @@ class CommandSilence : public Command for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++) { std::string decomppattern = DecompPattern(c->second); - user->WriteNumeric(271, "%s %s %s", user->nick.c_str(),c->first.c_str(), decomppattern.c_str()); + user->WriteNumeric(271, user->nick, c->first, decomppattern); } } - user->WriteNumeric(272, ":End of Silence List"); + user->WriteNumeric(272, "End of Silence List"); return CMD_SUCCESS; } @@ -174,7 +174,7 @@ class CommandSilence : public Command if (listitem == mask && i->second == pattern) { sl->erase(i); - user->WriteNumeric(950, "%s :Removed %s %s from silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str()); + user->WriteNumeric(950, user->nick, InspIRCd::Format("Removed %s %s from silence list", mask.c_str(), decomppattern.c_str())); if (!sl->size()) { ext.unset(user); @@ -183,7 +183,7 @@ class CommandSilence : public Command } } } - user->WriteNumeric(952, "%s :%s %s does not exist on your silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str()); + user->WriteNumeric(952, user->nick, InspIRCd::Format("%s %s does not exist on your silence list", mask.c_str(), decomppattern.c_str())); } else if (action == '+') { @@ -196,7 +196,7 @@ class CommandSilence : public Command } if (sl->size() > maxsilence) { - user->WriteNumeric(952, "%s :Your silence list is full",user->nick.c_str()); + user->WriteNumeric(952, user->nick, "Your silence list is full"); return CMD_FAILURE; } @@ -206,7 +206,7 @@ class CommandSilence : public Command irc::string listitem = n->first.c_str(); if (listitem == mask && n->second == pattern) { - user->WriteNumeric(952, "%s :%s %s is already on your silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str()); + user->WriteNumeric(952, user->nick, InspIRCd::Format("%s %s is already on your silence list", mask.c_str(), decomppattern.c_str())); return CMD_FAILURE; } } @@ -218,7 +218,7 @@ class CommandSilence : public Command { sl->push_back(silenceset(mask,pattern)); } - user->WriteNumeric(951, "%s :Added %s %s to silence list", user->nick.c_str(), mask.c_str(), decomppattern.c_str()); + user->WriteNumeric(951, user->nick, InspIRCd::Format("Added %s %s to silence list", mask.c_str(), decomppattern.c_str())); return CMD_SUCCESS; } } diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 726376844..ade8359ba 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -127,16 +127,15 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops) else if ((Current->Hidden) && (!user->IsOper())) return; - user->WriteNumeric(RPL_LINKS, "%s %s :%d %s", Current->GetName().c_str(), - (Utils->FlatLinks && (!user->IsOper())) ? ServerInstance->Config->ServerName.c_str() : Parent.c_str(), - (Utils->FlatLinks && (!user->IsOper())) ? 0 : hops, - Current->GetDesc().c_str()); + user->WriteNumeric(RPL_LINKS, Current->GetName(), + (((Utils->FlatLinks) && (!user->IsOper())) ? ServerInstance->Config->ServerName : Parent), + InspIRCd::Format("%d %s", (((Utils->FlatLinks) && (!user->IsOper())) ? 0 : hops), Current->GetDesc().c_str())); } void ModuleSpanningTree::HandleLinks(const std::vector& parameters, User* user) { ShowLinks(Utils->TreeRoot,user,0); - user->WriteNumeric(RPL_ENDOFLINKS, "* :End of /LINKS list."); + user->WriteNumeric(RPL_ENDOFLINKS, '*', "End of /LINKS list."); } std::string ModuleSpanningTree::TimeToStr(time_t secs) @@ -304,11 +303,11 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector& para // or the server is a 2.0 server and does not send a full version. bool showfull = ((user->IsOper()) && (!found->GetFullVersion().empty())); const std::string& Version = (showfull ? found->GetFullVersion() : found->GetVersion()); - user->WriteNumeric(RPL_VERSION, ":%s", Version.c_str()); + user->WriteNumeric(RPL_VERSION, Version); } else { - user->WriteNumeric(ERR_NOSUCHSERVER, "%s :No such server", parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHSERVER, parameters[0], "No such server"); } return MOD_RES_DENY; } diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index 612df80f3..7ae6c6b4a 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -172,7 +172,7 @@ CmdResult CommandMap::Handle(const std::vector& parameters, User* u TreeServer* s = Utils->FindServerMask(parameters[0]); if (!s) { - user->WriteNumeric(ERR_NOSUCHSERVER, "%s :No such server", parameters[0].c_str()); + user->WriteNumeric(ERR_NOSUCHSERVER, parameters[0], "No such server"); return CMD_FAILURE; } diff --git a/src/modules/m_spanningtree/override_whois.cpp b/src/modules/m_spanningtree/override_whois.cpp index 430467dc7..7f7189854 100644 --- a/src/modules/m_spanningtree/override_whois.cpp +++ b/src/modules/m_spanningtree/override_whois.cpp @@ -31,8 +31,8 @@ ModResult ModuleSpanningTree::HandleRemoteWhois(const std::vector& } else if (!remote) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[1].c_str()); - user->WriteNumeric(RPL_ENDOFWHOIS, "%s :End of /WHOIS list.", parameters[1].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); + user->WriteNumeric(RPL_ENDOFWHOIS, parameters[0], "End of /WHOIS list."); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index a3b804579..01465670a 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -50,7 +50,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vectorWriteFrom(collideswith, "NICK %s", collideswith->uuid.c_str()); - collideswith->WriteNumeric(ERR_NICKNAMEINUSE, "%s :Nickname overruled.", collideswith->nick.c_str()); + collideswith->WriteNumeric(ERR_NICKNAMEINUSE, collideswith->nick, "Nickname overruled."); // Clear the bit before calling User::ChangeNick() to make it NOT run the OnUserPostNick() hook collideswith->registered &= ~REG_NICK; diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index 523d52abb..ac02908c4 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -95,7 +95,7 @@ class CommandSSLInfo : public Command if ((!target) || (target->registered != REG_ALL)) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nickname", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } bool operonlyfp = ServerInstance->Config->ConfValue("sslinfo")->getBool("operonly"); @@ -181,7 +181,7 @@ class ModuleSSLInfo : public Module, public Whois::EventListener if (ifo->oper_block->getBool("sslonly") && !cert) { - user->WriteNumeric(491, ":This oper login requires an SSL connection."); + user->WriteNumeric(491, "This oper login requires an SSL connection."); user->CommandFloodPenalty += 10000; return MOD_RES_DENY; } @@ -189,7 +189,7 @@ class ModuleSSLInfo : public Module, public Whois::EventListener std::string fingerprint; if (ifo->oper_block->readString("fingerprint", fingerprint) && (!cert || cert->GetFingerprint() != fingerprint)) { - user->WriteNumeric(491, ":This oper login requires a matching SSL certificate fingerprint."); + user->WriteNumeric(491, "This oper login requires a matching SSL certificate fingerprint."); user->CommandFloodPenalty += 10000; return MOD_RES_DENY; } diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp index 1a596f5e0..e499082ff 100644 --- a/src/modules/m_sslmodes.cpp +++ b/src/modules/m_sslmodes.cpp @@ -54,7 +54,7 @@ class SSLMode : public ModeHandler ssl_cert* cert = API->GetCertificate(i->first); if (!cert && !i->first->server->IsULine()) { - source->WriteNumeric(ERR_ALLMUSTSSL, "%s :all members of the channel must be connected via SSL", channel->name.c_str()); + source->WriteNumeric(ERR_ALLMUSTSSL, channel->name, "all members of the channel must be connected via SSL"); return MODEACTION_DENY; } } @@ -107,7 +107,7 @@ class ModuleSSLModes : public Module else { // Deny - user->WriteNumeric(489, "%s :Cannot join channel; SSL users only (+z)", cname.c_str()); + user->WriteNumeric(489, cname, "Cannot join channel; SSL users only (+z)"); return MOD_RES_DENY; } } diff --git a/src/modules/m_starttls.cpp b/src/modules/m_starttls.cpp index 054f9c334..b3cf5a263 100644 --- a/src/modules/m_starttls.cpp +++ b/src/modules/m_starttls.cpp @@ -44,23 +44,23 @@ class CommandStartTLS : public SplitCommand { if (!ssl) { - user->WriteNumeric(ERR_STARTTLS, ":STARTTLS is not enabled"); + user->WriteNumeric(ERR_STARTTLS, "STARTTLS is not enabled"); return CMD_FAILURE; } if (user->registered == REG_ALL) { - user->WriteNumeric(ERR_STARTTLS, ":STARTTLS is not permitted after client registration is complete"); + user->WriteNumeric(ERR_STARTTLS, "STARTTLS is not permitted after client registration is complete"); return CMD_FAILURE; } if (user->eh.GetIOHook()) { - user->WriteNumeric(ERR_STARTTLS, ":STARTTLS failure"); + user->WriteNumeric(ERR_STARTTLS, "STARTTLS failure"); return CMD_FAILURE; } - user->WriteNumeric(RPL_STARTTLS, ":STARTTLS successful, go ahead with TLS handshake"); + user->WriteNumeric(RPL_STARTTLS, "STARTTLS successful, go ahead with TLS handshake"); /* We need to flush the write buffer prior to adding the IOHook, * otherwise we'll be sending this line inside the SSL session - which * won't start its handshake until the client gets this line. Currently, diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index a623e1553..b95a847a5 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -198,7 +198,7 @@ class ModuleSVSHold : public Module if (rl) { - user->WriteNumeric(ERR_ERRONEUSNICKNAME, "%s :Services reserved nickname: %s", newnick.c_str(), rl->reason.c_str()); + user->WriteNumeric(ERR_ERRONEUSNICKNAME, newnick, InspIRCd::Format("Services reserved nickname: %s", rl->reason.c_str())); return MOD_RES_DENY; } diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index 80c7ddd3b..46d96a952 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -45,7 +45,7 @@ class CommandSwhois : public Command if (!dest) // allow setting swhois using SWHOIS before reg { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 8196d37ba..8a627b9a6 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -72,14 +72,13 @@ class CommandTban : public Command Channel* channel = ServerInstance->FindChan(parameters[0]); if (!channel) { - user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } int cm = channel->GetPrefixValue(user); if (cm < HALFOP_VALUE) { - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You do not have permission to set bans on this channel", - channel->name.c_str()); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, "You do not have permission to set bans on this channel"); return CMD_FAILURE; } diff --git a/src/modules/m_topiclock.cpp b/src/modules/m_topiclock.cpp index 6053bc849..eba2b33f0 100644 --- a/src/modules/m_topiclock.cpp +++ b/src/modules/m_topiclock.cpp @@ -150,7 +150,7 @@ class ModuleTopicLock : public Module // Only fired for local users currently, but added a check anyway if ((IS_LOCAL(user)) && (topiclock.get(chan))) { - user->WriteNumeric(744, "%s :TOPIC cannot be changed due to topic lock being active on the channel", chan->name.c_str()); + user->WriteNumeric(744, chan->name, "TOPIC cannot be changed due to topic lock being active on the channel"); return MOD_RES_DENY; } diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp index e92688d1d..94f71d9c1 100644 --- a/src/modules/m_uninvite.cpp +++ b/src/modules/m_uninvite.cpp @@ -51,11 +51,11 @@ class CommandUninvite : public Command { if (!c) { - user->WriteNumeric(401, "%s :No such nick/channel", parameters[1].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[1])); } else { - user->WriteNumeric(401, "%s :No such nick/channel", parameters[0].c_str()); + user->WriteNumeric(Numerics::NoSuchNick(parameters[0])); } return CMD_FAILURE; @@ -65,7 +65,7 @@ class CommandUninvite : public Command { if (c->GetPrefixValue(user) < HALFOP_VALUE) { - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator", c->name.c_str(), c->GetPrefixValue(u) == HALFOP_VALUE ? "" : "half-"); + user->WriteNumeric(ERR_CHANOPRIVSNEEDED, c->name, InspIRCd::Format("You must be a channel %soperator", c->GetPrefixValue(u) == HALFOP_VALUE ? "" : "half-")); return CMD_FAILURE; } } @@ -84,7 +84,7 @@ class CommandUninvite : public Command } user->SendText(":%s 494 %s %s %s :Uninvited", user->server->GetName().c_str(), user->nick.c_str(), c->name.c_str(), u->nick.c_str()); - lu->WriteNumeric(493, ":You were uninvited from %s by %s", c->name.c_str(), user->nick.c_str()); + lu->WriteNumeric(493, InspIRCd::Format("You were uninvited from %s by %s", c->name.c_str(), user->nick.c_str())); std::string msg = "*** " + user->nick + " uninvited " + u->nick + "."; c->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE " + c->name + " :" + msg); diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp index 043967393..1b2ce9b13 100644 --- a/src/modules/m_userip.cpp +++ b/src/modules/m_userip.cpp @@ -52,7 +52,7 @@ class CommandUserip : public Command checked_privs = true; has_privs = user->HasPrivPermission("users/auspex"); if (!has_privs) - user->WriteNumeric(ERR_NOPRIVILEGES, ":Permission Denied - You do not have the required operator privileges"); + user->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges"); } if (!has_privs) diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index bdd4b2b15..6e9a6f9ed 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -53,12 +53,12 @@ class CommandWatch : public SplitCommand { // The away state should only be sent if the client requests away notifications for a nick but 2.0 always sends them so we do that too if (target->IsAway()) - user->WriteNumeric(RPL_NOWISAWAY, "%s %s %s %lu :is away", target->nick.c_str(), target->ident.c_str(), target->dhost.c_str(), (unsigned long)target->awaytime); + user->WriteNumeric(RPL_NOWISAWAY, target->nick, target->ident, target->dhost, (unsigned long)target->awaytime, "is away"); else - user->WriteNumeric(RPL_NOWON, "%s %s %s %lu :is online", target->nick.c_str(), target->ident.c_str(), target->dhost.c_str(), (unsigned long)target->age); + user->WriteNumeric(RPL_NOWON, target->nick, target->ident, target->dhost, (unsigned long)target->age, "is online"); } else if (show_offline) - user->WriteNumeric(RPL_NOWOFF, "%s * * 0 :is offline", nick.c_str()); + user->WriteNumeric(RPL_NOWOFF, nick, "*", "*", "0", "is offline"); } void HandlePlus(LocalUser* user, const std::string& nick) @@ -67,12 +67,12 @@ class CommandWatch : public SplitCommand if (result == IRCv3::Monitor::Manager::WR_TOOMANY) { // List is full, send error numeric - user->WriteNumeric(ERR_TOOMANYWATCH, "%s :Too many WATCH entries", nick.c_str()); + user->WriteNumeric(ERR_TOOMANYWATCH, nick, "Too many WATCH entries"); return; } else if (result == IRCv3::Monitor::Manager::WR_INVALIDNICK) { - user->WriteNumeric(942, "%s :Invalid nickname", nick.c_str()); + user->WriteNumeric(942, nick, "Invalid nickname"); return; } else if (result != IRCv3::Monitor::Manager::WR_OK) @@ -88,9 +88,9 @@ class CommandWatch : public SplitCommand User* target = IRCv3::Monitor::Manager::FindNick(nick); if (target) - user->WriteNumeric(RPL_WATCHOFF, "%s %s %s %lu :stopped watching", target->nick.c_str(), target->ident.c_str(), target->dhost.c_str(), (unsigned long)target->age); + user->WriteNumeric(RPL_WATCHOFF, target->nick, target->ident, target->dhost, (unsigned long)target->age, "stopped watching"); else - user->WriteNumeric(RPL_WATCHOFF, "%s * * 0 :stopped watching", nick.c_str()); + user->WriteNumeric(RPL_WATCHOFF, nick, "*", "*", "0", "stopped watching"); } void HandleList(LocalUser* user, bool show_offline) @@ -102,7 +102,7 @@ class CommandWatch : public SplitCommand const IRCv3::Monitor::Entry* entry = *i; SendOnlineOffline(user, entry->GetNick(), show_offline); } - user->WriteNumeric(RPL_ENDOFWATCHLIST, ":End of WATCH list"); + user->WriteNumeric(RPL_ENDOFWATCHLIST, "End of WATCH list"); } void HandleStats(LocalUser* user) @@ -111,7 +111,7 @@ class CommandWatch : public SplitCommand // Do not show how many clients are watching this nick, it's pointless const IRCv3::Monitor::WatchedList& list = manager.GetWatched(user); - user->WriteNumeric(RPL_WATCHSTAT, ":You have %lu and are on 0 WATCH entries", (unsigned long)list.size()); + user->WriteNumeric(RPL_WATCHSTAT, InspIRCd::Format("You have %lu and are on 0 WATCH entries", (unsigned long)list.size())); Numeric::Builder<' '> out(user, RPL_WATCHLIST); for (IRCv3::Monitor::WatchedList::const_iterator i = list.begin(); i != list.end(); ++i) @@ -120,7 +120,7 @@ class CommandWatch : public SplitCommand out.Add(entry->GetNick()); } out.Flush(); - user->WriteNumeric(RPL_ENDOFWATCHLIST, ":End of WATCH S"); + user->WriteNumeric(RPL_ENDOFWATCHLIST, "End of WATCH S"); } public: @@ -189,11 +189,12 @@ class ModuleWatch : public Module if (!list) return; - std::string text = InspIRCd::Format("%s %s %s %lu :%s", nick.c_str(), user->ident.c_str(), user->dhost.c_str(), (unsigned long) shownts, numerictext); + Numeric::Numeric num(numeric); + num.push(nick).push(user->ident).push(user->dhost).push(ConvToStr(shownts)).push(numerictext); for (IRCv3::Monitor::WatcherList::const_iterator i = list->begin(); i != list->end(); ++i) { LocalUser* curr = *i; - curr->WriteNumeric(numeric, text); + curr->WriteNumeric(num); } } diff --git a/src/server.cpp b/src/server.cpp index 191a3d30f..f22cf1ad4 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -194,35 +194,34 @@ void ISupportManager::Build() } // Transform the map into a list of lines, ready to be sent to clients - std::string line; + Numeric::Numeric numeric(RPL_ISUPPORT); unsigned int token_count = 0; cachedlines.clear(); for (std::map::const_iterator it = tokens.begin(); it != tokens.end(); ++it) { - line.append(it->first); + numeric.push(it->first); + std::string& token = numeric.GetParams().back(); // If this token has a value then append a '=' char after the name and then the value itself if (!it->second.empty()) - line.append(1, '=').append(it->second); + token.append(1, '=').append(it->second); - // Always append a space, even if it's the last token because all lines will be suffixed - line.push_back(' '); token_count++; if (token_count % 13 == 12 || it == --tokens.end()) { // Reached maximum number of tokens for this line or the current token // is the last one; finalize the line and store it for later use - line.append(":are supported by this server"); - cachedlines.push_back(line); - line.clear(); + numeric.push("are supported by this server"); + cachedlines.push_back(numeric); + numeric.GetParams().clear(); } } } void ISupportManager::SendTo(LocalUser* user) { - for (std::vector::const_iterator i = cachedlines.begin(); i != cachedlines.end(); ++i) - user->WriteNumeric(RPL_ISUPPORT, *i); + for (std::vector::const_iterator i = cachedlines.begin(); i != cachedlines.end(); ++i) + user->WriteNumeric(*i); } diff --git a/src/usermanager.cpp b/src/usermanager.cpp index ba6bbf36b..fe052fcfc 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -127,7 +127,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs /* user banned */ ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Positive hit for " + New->GetIPString()); if (!ServerInstance->Config->XLineMessage.empty()) - New->WriteNumeric(ERR_YOUREBANNEDCREEP, ":" + ServerInstance->Config->XLineMessage); + New->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage); this->QuitUser(New, b->Reason); return; } diff --git a/src/users.cpp b/src/users.cpp index 915afd8b8..b6fbc38a0 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -348,7 +348,7 @@ void User::Oper(OperInfo* info) ServerInstance->SNO->WriteToSnoMask('o',"%s (%s@%s) is now an IRC operator of type %s (using oper '%s')", nick.c_str(), ident.c_str(), host.c_str(), oper->name.c_str(), opername.c_str()); - this->WriteNumeric(RPL_YOUAREOPER, ":You are now %s %s", strchr("aeiouAEIOU", oper->name[0]) ? "an" : "a", oper->name.c_str()); + this->WriteNumeric(RPL_YOUAREOPER, InspIRCd::Format("You are now %s %s", strchr("aeiouAEIOU", oper->name[0]) ? "an" : "a", oper->name.c_str())); ServerInstance->Logs->Log("OPER", LOG_DEFAULT, "%s opered as type: %s", GetFullRealHost().c_str(), oper->name.c_str()); ServerInstance->Users->all_opers.push_back(this); @@ -524,12 +524,12 @@ void LocalUser::FullConnect() if (quitting) return; - this->WriteNumeric(RPL_WELCOME, ":Welcome to the %s IRC Network %s", ServerInstance->Config->Network.c_str(), GetFullRealHost().c_str()); - this->WriteNumeric(RPL_YOURHOSTIS, ":Your host is %s, running version %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH); - this->WriteNumeric(RPL_SERVERCREATED, ":This server was created %s %s", __TIME__, __DATE__); + this->WriteNumeric(RPL_WELCOME, InspIRCd::Format("Welcome to the %s IRC Network %s", ServerInstance->Config->Network.c_str(), GetFullRealHost().c_str())); + this->WriteNumeric(RPL_YOURHOSTIS, InspIRCd::Format("Your host is %s, running version %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH)); + this->WriteNumeric(RPL_SERVERCREATED, InspIRCd::Format("This server was created %s %s", __TIME__, __DATE__)); const std::string& modelist = ServerInstance->Modes->GetModeListFor004Numeric(); - this->WriteNumeric(RPL_SERVERVERSION, "%s %s %s", ServerInstance->Config->ServerName.c_str(), INSPIRCD_BRANCH, modelist.c_str()); + this->WriteNumeric(RPL_SERVERVERSION, ServerInstance->Config->ServerName, INSPIRCD_BRANCH, modelist); ServerInstance->ISupport.SendTo(this); @@ -615,7 +615,7 @@ bool User::ChangeNick(const std::string& newnick, time_t newts) { /* force the camper to their UUID, and ask them to re-send a NICK. */ InUse->WriteFrom(InUse, "NICK %s", InUse->uuid.c_str()); - InUse->WriteNumeric(ERR_NICKNAMEINUSE, "%s :Nickname overruled.", InUse->nick.c_str()); + InUse->WriteNumeric(ERR_NICKNAMEINUSE, InUse->nick, "Nickname overruled."); InUse->registered &= ~REG_NICK; InUse->ChangeNick(InUse->uuid); @@ -623,7 +623,7 @@ bool User::ChangeNick(const std::string& newnick, time_t newts) else { /* No camping, tell the incoming user to stop trying to change nick ;p */ - this->WriteNumeric(ERR_NICKNAMEINUSE, "%s :Nickname is already in use.", newnick.c_str()); + this->WriteNumeric(ERR_NICKNAMEINUSE, newnick, "Nickname is already in use."); return false; } } @@ -802,25 +802,16 @@ namespace } } -void User::WriteNumeric(unsigned int numeric, const char* text, ...) -{ - std::string textbuffer; - VAFORMAT(textbuffer, text, text); - this->WriteNumeric(numeric, textbuffer); -} - -void User::WriteNumeric(unsigned int numeric, const std::string &text) +void User::WriteNumeric(const Numeric::Numeric& numeric) { ModResult MOD_RESULT; - FIRST_MOD_RESULT(OnNumeric, MOD_RESULT, (this, numeric, text)); + FIRST_MOD_RESULT(OnNumeric, MOD_RESULT, (this, numeric)); if (MOD_RESULT == MOD_RES_DENY) return; - const std::string message = InspIRCd::Format(":%s %03u %s %s", ServerInstance->Config->ServerName.c_str(), - numeric, this->registered & REG_NICK ? this->nick.c_str() : "*", text.c_str()); - this->Write(message); + this->Write(BuildNumeric(ServerInstance->Config->ServerName, this, numeric.GetNumeric(), numeric.GetParams())); } void User::WriteFrom(User *user, const std::string &text) @@ -1026,7 +1017,7 @@ bool User::ChangeDisplayedHost(const std::string& shost) this->InvalidateCache(); if (IS_LOCAL(this)) - this->WriteNumeric(RPL_YOURDISPLAYEDHOST, "%s :is now your displayed host", this->dhost.c_str()); + this->WriteNumeric(RPL_YOURDISPLAYEDHOST, this->dhost, "is now your displayed host"); return true; } diff --git a/src/xline.cpp b/src/xline.cpp index dedf8c7a9..003d77e80 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -531,7 +531,7 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache) const std::string banReason = line + "-Lined: " + reason; if (!ServerInstance->Config->XLineMessage.empty()) - u->WriteNumeric(ERR_YOUREBANNEDCREEP, ":" + ServerInstance->Config->XLineMessage); + u->WriteNumeric(ERR_YOUREBANNEDCREEP, ServerInstance->Config->XLineMessage); if (ServerInstance->Config->HideBans) ServerInstance->Users->QuitUser(u, line + "-Lined", &banReason); -- 2.39.2