diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-02-25 16:27:30 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-02-25 16:27:30 +0100 |
commit | 0c42bcde16c3141ccd4bb8c5f7b22d65cc8e1909 (patch) | |
tree | f80ce6d1bd6346c9d9b4daa5350e6703e2738808 /src | |
parent | da29af8cba49d51e53d6e68237ccbf6370b6dd1f (diff) |
Convert WhoisContext::SendLine() calls to pass the parameters of the numeric as method parameters
Diffstat (limited to 'src')
-rw-r--r-- | src/coremods/core_whois.cpp | 36 | ||||
-rw-r--r-- | src/modules/m_botmode.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_customtitle.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_helpop.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_hidechans.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_hideoper.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_services_account.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_servprotect.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_sslinfo.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_swhois.cpp | 6 |
10 files changed, 35 insertions, 39 deletions
diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp index 0645eda4c..90a630f9c 100644 --- a/src/coremods/core_whois.cpp +++ b/src/coremods/core_whois.cpp @@ -33,20 +33,16 @@ class WhoisContextImpl : public Whois::Context } using Whois::Context::SendLine; - void SendLine(unsigned int numeric, const std::string& text) CXX11_OVERRIDE; + void SendLine(Numeric::Numeric& numeric) CXX11_OVERRIDE; }; -void WhoisContextImpl::SendLine(unsigned int numeric, const std::string& text) +void WhoisContextImpl::SendLine(Numeric::Numeric& numeric) { - std::string copy_text = target->nick; - copy_text.push_back(' '); - copy_text.append(text); - ModResult MOD_RESULT; - FIRST_MOD_RESULT_CUSTOM(lineevprov, Whois::LineEventListener, OnWhoisLine, MOD_RESULT, (*this, numeric, copy_text)); + FIRST_MOD_RESULT_CUSTOM(lineevprov, Whois::LineEventListener, OnWhoisLine, MOD_RESULT, (*this, numeric)); if (MOD_RESULT != MOD_RES_DENY) - source->WriteNumeric(numeric, copy_text); + source->WriteNumeric(numeric); } /** Handle /WHOIS. @@ -150,7 +146,7 @@ class WhoisChanList { num.Flush(); if (!spynum.IsEmpty()) - whois.SendLine(336, ":is on private/secret channels:"); + whois.SendLine(336, "is on private/secret channels:"); spynum.Flush(); } }; @@ -180,45 +176,45 @@ void CommandWhois::DoWhois(LocalUser* user, User* dest, unsigned long signon, un { WhoisContextImpl whois(user, dest, lineevprov); - whois.SendLine(311, "%s %s * :%s", dest->ident.c_str(), dest->dhost.c_str(), dest->fullname.c_str()); + whois.SendLine(311, dest->ident, dest->dhost, '*', dest->fullname); if (whois.IsSelfWhois() || user->HasPrivPermission("users/auspex")) { - whois.SendLine(378, ":is connecting from %s@%s %s", dest->ident.c_str(), dest->host.c_str(), dest->GetIPString().c_str()); + whois.SendLine(378, InspIRCd::Format("is connecting from %s@%s %s", dest->ident.c_str(), dest->host.c_str(), dest->GetIPString().c_str())); } SendChanList(whois); if (!whois.IsSelfWhois() && !ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")) { - whois.SendLine(312, "%s :%s", ServerInstance->Config->HideWhoisServer.c_str(), ServerInstance->Config->Network.c_str()); + whois.SendLine(312, ServerInstance->Config->HideWhoisServer, ServerInstance->Config->Network); } else { - whois.SendLine(312, "%s :%s", dest->server->GetName().c_str(), dest->server->GetDesc().c_str()); + whois.SendLine(312, dest->server->GetName(), dest->server->GetDesc()); } if (dest->IsAway()) { - whois.SendLine(301, ":%s", dest->awaymsg.c_str()); + whois.SendLine(301, dest->awaymsg); } if (dest->IsOper()) { if (ServerInstance->Config->GenericOper) - whois.SendLine(313, ":is an IRC operator"); + whois.SendLine(313, "is an IRC operator"); else - whois.SendLine(313, ":is %s %s on %s", (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"),dest->oper->name.c_str(), ServerInstance->Config->Network.c_str()); + whois.SendLine(313, InspIRCd::Format("is %s %s on %s", (strchr("AEIOUaeiou",dest->oper->name[0]) ? "an" : "a"), dest->oper->name.c_str(), ServerInstance->Config->Network.c_str())); } if (whois.IsSelfWhois() || user->HasPrivPermission("users/auspex")) { if (dest->IsModeSet(snomaskmode)) { - whois.SendLine(379, ":is using modes +%s %s", dest->FormatModes(), snomaskmode->GetUserParameter(dest).c_str()); + whois.SendLine(379, InspIRCd::Format("is using modes +%s %s", dest->FormatModes(), snomaskmode->GetUserParameter(dest).c_str())); } else { - whois.SendLine(379, ":is using modes +%s", dest->FormatModes()); + whois.SendLine(379, InspIRCd::Format("is using modes +%s", dest->FormatModes())); } } @@ -230,10 +226,10 @@ void CommandWhois::DoWhois(LocalUser* user, User* dest, unsigned long signon, un */ if ((idle) || (signon)) { - whois.SendLine(317, "%lu %lu :seconds idle, signon time", idle, signon); + whois.SendLine(317, idle, signon, "seconds idle, signon time"); } - whois.SendLine(318, ":End of /WHOIS list."); + whois.SendLine(318, "End of /WHOIS list."); } CmdResult CommandWhois::HandleRemote(const std::vector<std::string>& parameters, RemoteUser* target) diff --git a/src/modules/m_botmode.cpp b/src/modules/m_botmode.cpp index 419af0153..e0236bc17 100644 --- a/src/modules/m_botmode.cpp +++ b/src/modules/m_botmode.cpp @@ -48,7 +48,7 @@ class ModuleBotMode : public Module, public Whois::EventListener { if (whois.GetTarget()->IsModeSet(bm)) { - whois.SendLine(335, ":is a bot on " + ServerInstance->Config->Network); + whois.SendLine(335, "is a bot on " + ServerInstance->Config->Network); } } }; diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp index b86bf1809..30c0aa4f2 100644 --- a/src/modules/m_customtitle.cpp +++ b/src/modules/m_customtitle.cpp @@ -82,16 +82,16 @@ class ModuleCustomTitle : public Module, public Whois::LineEventListener } // :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games. - ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE + ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { /* We use this and not OnWhois because this triggers for remote, too */ - if (numeric == 312) + if (numeric.GetNumeric() == 312) { /* Insert our numeric before 312 */ const std::string* ctitle = cmd.ctitle.get(whois.GetTarget()); if (ctitle) { - whois.SendLine(320, ":%s", ctitle->c_str()); + whois.SendLine(320, ctitle); } } /* Don't block anything */ diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index f567aa076..95f69774b 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -145,7 +145,7 @@ class ModuleHelpop : public Module, public Whois::EventListener { if (whois.GetTarget()->IsModeSet(ho)) { - whois.SendLine(310, ":is available for help."); + whois.SendLine(310, "is available for help."); } } diff --git a/src/modules/m_hidechans.cpp b/src/modules/m_hidechans.cpp index 431b7b968..08caae6b2 100644 --- a/src/modules/m_hidechans.cpp +++ b/src/modules/m_hidechans.cpp @@ -49,14 +49,14 @@ class ModuleHideChans : public Module, public Whois::LineEventListener AffectsOpers = ServerInstance->Config->ConfValue("hidechans")->getBool("affectsopers"); } - ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE + ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { /* always show to self */ if (whois.IsSelfWhois()) return MOD_RES_PASSTHRU; /* don't touch anything except 319 */ - if (numeric != 319) + if (numeric.GetNumeric() != 319) return MOD_RES_PASSTHRU; /* don't touch if -I */ diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index b90f3f234..92af045d5 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -87,12 +87,12 @@ class ModuleHideOper : public Module, public Whois::LineEventListener return MOD_RES_DENY; } - ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE + ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { /* Dont display numeric 313 (RPL_WHOISOPER) if they have +H set and the * person doing the WHOIS is not an oper */ - if (numeric != 313) + if (numeric.GetNumeric() != 313) return MOD_RES_PASSTHRU; if (!whois.GetTarget()->IsModeSet(hm)) diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index 048e04a5a..559f28ea8 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -168,13 +168,13 @@ class ModuleServicesAccount : public Module, public Whois::EventListener if (account) { - whois.SendLine(330, "%s :is logged in as", account->c_str()); + whois.SendLine(330, *account, "is logged in as"); } if (whois.GetTarget()->IsModeSet(m5)) { /* user is registered */ - whois.SendLine(307, ":is a registered nick"); + whois.SendLine(307, "is a registered nick"); } } diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp index 34f730c62..88bde9b57 100644 --- a/src/modules/m_servprotect.cpp +++ b/src/modules/m_servprotect.cpp @@ -62,7 +62,7 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public { if (whois.GetTarget()->IsModeSet(bm)) { - whois.SendLine(310, ":is a Network Service on " + ServerInstance->Config->Network); + whois.SendLine(310, "is a Network Service on " + ServerInstance->Config->Network); } } @@ -120,9 +120,9 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public return MOD_RES_PASSTHRU; } - ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE + ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { - return ((numeric == 319) && whois.GetTarget()->IsModeSet(bm)) ? MOD_RES_DENY : MOD_RES_PASSTHRU; + return ((numeric.GetNumeric() == 319) && whois.GetTarget()->IsModeSet(bm)) ? MOD_RES_DENY : MOD_RES_PASSTHRU; } }; diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index ac02908c4..6a29d3bde 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -162,10 +162,10 @@ class ModuleSSLInfo : public Module, public Whois::EventListener ssl_cert* cert = cmd.CertExt.get(whois.GetTarget()); if (cert) { - whois.SendLine(671, ":is using a secure connection"); + whois.SendLine(671, "is using a secure connection"); bool operonlyfp = ServerInstance->Config->ConfValue("sslinfo")->getBool("operonly"); if ((!operonlyfp || whois.IsSelfWhois() || whois.GetSource()->IsOper()) && !cert->fingerprint.empty()) - whois.SendLine(276, ":has client certificate fingerprint %s", cert->fingerprint.c_str()); + whois.SendLine(276, InspIRCd::Format("has client certificate fingerprint %s", cert->fingerprint.c_str())); } } diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index 46d96a952..9a433e154 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -93,16 +93,16 @@ class ModuleSWhois : public Module, public Whois::LineEventListener } // :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games. - ModResult OnWhoisLine(Whois::Context& whois, unsigned int& numeric, std::string& text) CXX11_OVERRIDE + ModResult OnWhoisLine(Whois::Context& whois, Numeric::Numeric& numeric) CXX11_OVERRIDE { /* We use this and not OnWhois because this triggers for remote, too */ - if (numeric == 312) + if (numeric.GetNumeric() == 312) { /* Insert our numeric before 312 */ std::string* swhois = cmd.swhois.get(whois.GetTarget()); if (swhois) { - whois.SendLine(320, ":%s", swhois->c_str()); + whois.SendLine(320, *swhois); } } |