diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-02-25 16:40:50 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-02-25 16:40:50 +0100 |
commit | dbe5a1fc6f9e18765863f332a3e79d7c918d3e65 (patch) | |
tree | eb53116004bf80b3621da7e654207e508377f9a2 /src/modules | |
parent | ee7567584e4792166a4d6455ca306731d8b5f28a (diff) |
Add User::WriteRemoteNumeric() and switch code using SendText() to send numerics to it
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_callerid.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_globalload.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_nicklock.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_opermotd.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_showfile.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_map.cpp | 11 | ||||
-rw-r--r-- | src/modules/m_uninvite.cpp | 13 |
7 files changed, 28 insertions, 26 deletions
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 149767f18..e11b326de 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -399,8 +399,8 @@ public: if (now > (dat->lastnotify + (time_t)notify_cooldown)) { 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()); + dest->WriteRemoteNumeric(RPL_UMODEGMSG, user->nick, InspIRCd::Format("%s@%s", user->ident.c_str(), user->dhost.c_str()), InspIRCd::Format("is messaging you, and you have umode +g. Use /ACCEPT +%s to allow.", + user->nick.c_str())); dat->lastnotify = now; } return MOD_RES_DENY; diff --git a/src/modules/m_globalload.cpp b/src/modules/m_globalload.cpp index 2355cc979..b71f29fcc 100644 --- a/src/modules/m_globalload.cpp +++ b/src/modules/m_globalload.cpp @@ -93,8 +93,7 @@ class CommandGunloadmodule : public Command if (ServerInstance->Modules->Unload(m)) { ServerInstance->SNO->WriteToSnoMask('a', "MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0].c_str(), user->nick.c_str()); - user->SendText(":%s 973 %s %s :Module successfully unloaded.", - ServerInstance->Config->ServerName.c_str(), user->nick.c_str(), parameters[0].c_str()); + user->WriteRemoteNumeric(973, parameters[0], "Module successfully unloaded."); } else { @@ -102,7 +101,7 @@ class CommandGunloadmodule : public Command } } else - user->SendText(":%s %03d %s %s :No such module", ServerInstance->Config->ServerName.c_str(), ERR_CANTUNLOADMODULE, user->nick.c_str(), parameters[0].c_str()); + user->WriteRemoteNumeric(ERR_CANTUNLOADMODULE, parameters[0], "No such module"); } else ServerInstance->SNO->WriteToSnoMask('a', "MODULE '%s' GLOBAL UNLOAD BY '%s' (not unloaded here)",parameters[0].c_str(), user->nick.c_str()); diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp index 634982d14..a517e95ac 100644 --- a/src/modules/m_nicklock.cpp +++ b/src/modules/m_nicklock.cpp @@ -114,13 +114,11 @@ class CommandNickunlock : public Command if (locked.set(target, 0)) { ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used NICKUNLOCK on "+target->nick); - user->SendText(":%s 945 %s %s :Nickname now unlocked.", - ServerInstance->Config->ServerName.c_str(),user->nick.c_str(),target->nick.c_str()); + user->WriteRemoteNumeric(945, target->nick, "Nickname now unlocked."); } else { - user->SendText(":%s 946 %s %s :This user's nickname is not locked.", - ServerInstance->Config->ServerName.c_str(),user->nick.c_str(),target->nick.c_str()); + user->WriteRemoteNumeric(946, target->nick, "This user's nickname is not locked."); return CMD_FAILURE; } } diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp index bd1853d43..010f4ae58 100644 --- a/src/modules/m_opermotd.cpp +++ b/src/modules/m_opermotd.cpp @@ -50,21 +50,20 @@ class CommandOpermotd : public Command void ShowOperMOTD(User* user) { - const std::string& servername = ServerInstance->Config->ServerName; if (opermotd.empty()) { - user->SendText(":%s 455 %s :OPERMOTD file is missing", servername.c_str(), user->nick.c_str()); + user->WriteRemoteNumeric(455, "OPERMOTD file is missing"); return; } - user->SendText(":%s 375 %s :- IRC Operators Message of the Day", servername.c_str(), user->nick.c_str()); + user->WriteRemoteNumeric(375, "- IRC Operators Message of the Day"); for (file_cache::const_iterator i = opermotd.begin(); i != opermotd.end(); ++i) { - user->SendText(":%s 372 %s :- %s", servername.c_str(), user->nick.c_str(), i->c_str()); + user->WriteRemoteNumeric(372, InspIRCd::Format("- %s", i->c_str())); } - user->SendText(":%s 376 %s :- End of OPERMOTD", servername.c_str(), user->nick.c_str()); + user->WriteRemoteNumeric(376, "- End of OPERMOTD"); } }; diff --git a/src/modules/m_showfile.cpp b/src/modules/m_showfile.cpp index cb51c4387..9973bf2b6 100644 --- a/src/modules/m_showfile.cpp +++ b/src/modules/m_showfile.cpp @@ -48,12 +48,12 @@ class CommandShowFile : public Command if (method == SF_NUMERIC) { if (!introtext.empty()) - user->SendText(":%s %03d %s :%s %s", sn.c_str(), intronumeric, user->nick.c_str(), sn.c_str(), introtext.c_str()); + user->WriteRemoteNumeric(intronumeric, introtext); for (file_cache::const_iterator i = contents.begin(); i != contents.end(); ++i) - user->SendText(":%s %03d %s :- %s", sn.c_str(), textnumeric, user->nick.c_str(), i->c_str()); + user->WriteRemoteNumeric(textnumeric, InspIRCd::Format("- %s", i->c_str())); - user->SendText(":%s %03d %s :%s", sn.c_str(), endnumeric, user->nick.c_str(), endtext.c_str()); + user->WriteRemoteNumeric(endnumeric, endtext.c_str()); } else { diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index 7ae6c6b4a..660d738e9 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -199,17 +199,14 @@ CmdResult CommandMap::Handle(const std::vector<std::string>& parameters, User* u std::vector<std::string> map = GetMap(user, Utils->TreeRoot, max, 0); for (std::vector<std::string>::const_iterator i = map.begin(); i != map.end(); ++i) - user->SendText(":%s %03d %s :%s", ServerInstance->Config->ServerName.c_str(), - RPL_MAP, user->nick.c_str(), i->c_str()); + user->WriteRemoteNumeric(RPL_MAP, *i); size_t totusers = ServerInstance->Users->GetUsers().size(); float avg_users = (float) totusers / Utils->serverlist.size(); - user->SendText(":%s %03d %s :%u server%s and %u user%s, average %.2f users per server", - ServerInstance->Config->ServerName.c_str(), RPL_MAPUSERS, user->nick.c_str(), - (unsigned int)Utils->serverlist.size(), (Utils->serverlist.size() > 1 ? "s" : ""), (unsigned int)totusers, (totusers > 1 ? "s" : ""), avg_users); - user->SendText(":%s %03d %s :End of /MAP", ServerInstance->Config->ServerName.c_str(), - RPL_ENDMAP, user->nick.c_str()); + user->WriteRemoteNumeric(RPL_MAPUSERS, InspIRCd::Format("%u server%s and %u user%s, average %.2f users per server", + (unsigned int)Utils->serverlist.size(), (Utils->serverlist.size() > 1 ? "s" : ""), (unsigned int)totusers, (totusers > 1 ? "s" : ""), avg_users)); + user->WriteRemoteNumeric(RPL_ENDMAP, "End of /MAP"); return CMD_SUCCESS; } diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp index 94f71d9c1..d3045eadc 100644 --- a/src/modules/m_uninvite.cpp +++ b/src/modules/m_uninvite.cpp @@ -77,13 +77,22 @@ class CommandUninvite : public Command LocalUser* lu = IS_LOCAL(u); if (lu) { + // XXX: The source of the numeric we send must be the server of the user doing the /UNINVITE, + // so they don't see where the target user is connected to if (!invapi->Remove(lu, c)) { - user->SendText(":%s 505 %s %s %s :Is not invited to channel %s", user->server->GetName().c_str(), user->nick.c_str(), u->nick.c_str(), c->name.c_str(), c->name.c_str()); + Numeric::Numeric n(505); + n.SetServer(user->server); + n.push(u->nick).push(c->name).push(InspIRCd::Format("Is not invited to channel %s", c->name.c_str())); + user->WriteRemoteNumeric(n); return CMD_FAILURE; } - 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()); + Numeric::Numeric n(494); + n.SetServer(user->server); + n.push(c->name).push(u->nick).push("Uninvited"); + user->WriteRemoteNumeric(n); + 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 + "."; |