summaryrefslogtreecommitdiff
path: root/modules/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'modules/protocol')
-rw-r--r--modules/protocol/bahamut.cpp18
-rw-r--r--modules/protocol/charybdis.cpp10
-rw-r--r--modules/protocol/hybrid.cpp16
-rw-r--r--modules/protocol/inspircd20.cpp22
-rw-r--r--modules/protocol/ngircd.cpp37
-rw-r--r--modules/protocol/plexus.cpp12
-rw-r--r--modules/protocol/ratbox.cpp12
-rw-r--r--modules/protocol/rfc1459.cpp67
-rw-r--r--modules/protocol/unreal.cpp18
9 files changed, 93 insertions, 119 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index 8e753b443..7ab9dd9b2 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -57,7 +57,7 @@ class BahamutIRCdProto : public IRCDProto
MaxModes = 60;
}
- void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) override
+ void SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf) override
{
if (Servers::Capab.count("TSMODE") > 0)
{
@@ -67,23 +67,23 @@ class BahamutIRCdProto : public IRCDProto
}
else
{
- IRCDProto::SendModeInternal(source, dest, buf);
+ IRCDProto::SendMode(source, dest, buf);
}
}
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override
+ void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override
{
IRCMessage message(source, "SVSMODE", u->nick, u->timestamp);
message.TokenizeAndPush(buf);
Uplink::SendMessage(message);
}
- void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override
+ void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override
{
Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg);
}
- void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override
+ void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override
{
Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg);
}
@@ -135,7 +135,7 @@ class BahamutIRCdProto : public IRCDProto
}
/* SVSNOOP */
- void SendSVSNOOP(const Server *server, bool set) override
+ void SendSVSNOOP(Server *server, bool set) override
{
Uplink::Send("SVSNOOP", server->GetName(), set ? "+" : "-");
}
@@ -255,7 +255,7 @@ class BahamutIRCdProto : public IRCDProto
/*
Note: if the stamp is null 0, the below usage is correct of Bahamut
*/
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override
+ void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override
{
Uplink::Send(source, "SVSKILL", user->nick, buf);
}
@@ -277,7 +277,7 @@ class BahamutIRCdProto : public IRCDProto
}
/* SERVER */
- void SendServer(const Server *server) override
+ void SendServer(Server *server) override
{
Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription());
}
@@ -309,7 +309,7 @@ class BahamutIRCdProto : public IRCDProto
void SendLogin(User *u, NickServ::Nick *) override
{
- IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %d", u->signon);
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", u->signon);
}
void SendLogout(User *u) override
diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp
index 5cc9f4c62..c111a31d3 100644
--- a/modules/protocol/charybdis.cpp
+++ b/modules/protocol/charybdis.cpp
@@ -61,10 +61,10 @@ class CharybdisProto : public IRCDProto
MaxModes = 4;
}
- void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) override { ratbox->SendSVSKillInternal(source, targ, reason); }
- void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { ratbox->SendGlobalNotice(bi, dest, msg); }
- void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { ratbox->SendGlobalPrivmsg(bi, dest, msg); }
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override { ratbox->SendGlobopsInternal(source, buf); }
+ void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { ratbox->SendSVSKill(source, targ, reason); }
+ void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { ratbox->SendGlobalNotice(bi, dest, msg); }
+ void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { ratbox->SendGlobalPrivmsg(bi, dest, msg); }
+ void SendGlobops(const MessageSource &source, const Anope::string &buf) override { ratbox->SendGlobops(source, buf); }
void SendSGLine(User *u, XLine *x) override { ratbox->SendSGLine(u, x); }
void SendSGLineDel(XLine *x) override { ratbox->SendSGLineDel(x); }
void SendAkill(User *u, XLine *x) override { ratbox->SendAkill(u, x); }
@@ -72,7 +72,7 @@ class CharybdisProto : public IRCDProto
void SendSQLine(User *u, XLine *x) override { ratbox->SendSQLine(u, x); }
void SendSQLineDel(XLine *x) override { ratbox->SendSQLineDel(x); }
void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { ratbox->SendJoin(user, c, status); }
- void SendServer(const Server *server) override { ratbox->SendServer(server); }
+ void SendServer(Server *server) override { ratbox->SendServer(server); }
void SendChannel(Channel *c) override { ratbox->SendChannel(c); }
void SendTopic(const MessageSource &source, Channel *c) override { ratbox->SendTopic(source, c); }
bool IsIdentValid(const Anope::string &ident) override { return ratbox->IsIdentValid(ident); }
diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp
index c28c9ebf5..2af72ed4c 100644
--- a/modules/protocol/hybrid.cpp
+++ b/modules/protocol/hybrid.cpp
@@ -47,9 +47,9 @@ class HybridProto : public IRCDProto
return NULL;
}
- void SendSVSKillInternal(const MessageSource &source, User *u, const Anope::string &buf) override
+ void SendSVSKill(const MessageSource &source, User *u, const Anope::string &buf) override
{
- IRCDProto::SendSVSKillInternal(source, u, buf);
+ IRCDProto::SendSVSKill(source, u, buf);
u->KillInternal(source, buf);
}
@@ -70,17 +70,17 @@ class HybridProto : public IRCDProto
MaxModes = 6;
}
- void SendInvite(const MessageSource &source, const Channel *c, User *u) override
+ void SendInvite(const MessageSource &source, Channel *c, User *u) override
{
Uplink::Send(source, "INVITE", u->GetUID(), c->name, c->creation_time);
}
- void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override
+ void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override
{
Uplink::Send(bi, "NOTICE", "$$" + dest->GetName(), msg);
}
- void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override
+ void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override
{
Uplink::Send(bi, "PRIVMSG", "$$" + dest->GetName(), msg);
}
@@ -193,7 +193,7 @@ class HybridProto : public IRCDProto
Uplink::Send(Config->GetClient("OperServ"), "KLINE", timeleft, x->GetUser(), x->GetHost(), x->GetReason());
}
- void SendServer(const Server *server) override
+ void SendServer(Server *server) override
{
if (server == Me)
Uplink::Send("SERVER", server->GetName(), server->GetHops() + 1, server->GetDescription());
@@ -238,7 +238,7 @@ class HybridProto : public IRCDProto
Uplink::Send(Me, "EOB");
}
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override
+ void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override
{
IRCMessage message(source, "SVSMODE", u->GetUID(), u->timestamp);
message.TokenizeAndPush(buf);
@@ -247,7 +247,7 @@ class HybridProto : public IRCDProto
void SendLogin(User *u, NickServ::Nick *na) override
{
- IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", na->GetAccount()->GetDisplay().c_str());
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", na->GetAccount()->GetDisplay());
}
void SendLogout(User *u) override
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 0f5469cea..d7bff8be0 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -40,9 +40,9 @@ static unsigned int spanningtree_proto_ver = 0;
class InspIRCd20Proto : public IRCDProto
{
private:
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override
+ void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override
{
- IRCDProto::SendSVSKillInternal(source, user, buf);
+ IRCDProto::SendSVSKill(source, user, buf);
user->KillInternal(source, buf);
}
@@ -96,12 +96,12 @@ class InspIRCd20Proto : public IRCDProto
SendServer(Me);
}
- void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override
+ void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override
{
Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg);
}
- void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override
+ void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override
{
Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg);
}
@@ -221,13 +221,12 @@ class InspIRCd20Proto : public IRCDProto
SendAddLine("G", x->GetUser() + "@" + x->GetHost(), timeleft, x->GetBy(), x->GetReason());
}
- void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf) override
+ void SendNumeric(int numeric, User *dest, IRCMessage &message)
{
- User *u = User::Find(dest);
- Uplink::Send("PUSH", dest, ":" + Me->GetName() + " " + numeric + " " + (u ? u->nick : dest) + " " + buf);
+ Uplink::Send("PUSH", dest->GetUID(), Format(message));
}
- void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) override
+ void SendMode(const MessageSource &source, Channel *dest, const Anope::string &buf) override
{
IRCMessage message(source, "FMODE", dest->name, dest->creation_time);
message.TokenizeAndPush(buf);
@@ -243,7 +242,7 @@ class InspIRCd20Proto : public IRCDProto
}
/* SERVER services-dev.chatspike.net password 0 :Description here */
- void SendServer(const Server *server) override
+ void SendServer(Server *server) override
{
/* if rsquit is set then we are waiting on a squit */
if (rsquit_id.empty() && rsquit_server.empty())
@@ -370,7 +369,8 @@ class InspIRCd20Proto : public IRCDProto
{
Uplink::Send(Me, "BURST", Anope::CurTime);
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- Uplink::Send(Me, "VERSION", "Anope-" + Anope::Version() + " " + Me->GetName() + " :" + IRCD->GetProtocolName() + " - (" + (enc ? enc->name : "none") + ") -- " + Anope::VersionBuildString());
+ Uplink::Send(Me, "VERSION", Anope::Format("Anope-{0} {1} {2} - {3} - Built: {4} - Flags: {5}",
+ Anope::Version(), Me->GetName(), IRCD->GetProtocolName(), enc ? enc->name : "(none)", Anope::VersionBuildTime(), Anope::VersionFlags()));
}
void SendEOB() override
@@ -378,7 +378,7 @@ class InspIRCd20Proto : public IRCDProto
Uplink::Send(Me, "ENDBURST");
}
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
+ void SendGlobops(const MessageSource &source, const Anope::string &buf) override
{
if (Servers::Capab.count("GLOBOPS"))
Uplink::Send(source, "SNONOTICE", "g", buf);
diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp
index 6ce997e2a..98509f9a1 100644
--- a/modules/protocol/ngircd.cpp
+++ b/modules/protocol/ngircd.cpp
@@ -26,9 +26,9 @@
class ngIRCdProto : public IRCDProto
{
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override
+ void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override
{
- IRCDProto::SendSVSKillInternal(source, user, buf);
+ IRCDProto::SendSVSKill(source, user, buf);
user->KillInternal(source, buf);
}
@@ -75,7 +75,7 @@ class ngIRCdProto : public IRCDProto
/* Make myself known to myself in the serverlist */
SendServer(Me);
/* finish the enhanced server handshake and register the connection */
- this->SendNumeric(376, "*", ":End of MOTD command");
+ Uplink::Send("376", "*", "End of MOTD command");
}
void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) override
@@ -83,17 +83,17 @@ class ngIRCdProto : public IRCDProto
Uplink::Send(Me, "SVSNICK", u->nick, newnick);
}
- void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override
+ void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override
{
Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg);
}
- void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override
+ void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override
{
Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg);
}
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
+ void SendGlobops(const MessageSource &source, const Anope::string &buf) override
{
Uplink::Send(source, "WALLOPS", buf);
}
@@ -121,14 +121,6 @@ class ngIRCdProto : public IRCDProto
}
}
- void SendKickInternal(const MessageSource &source, const Channel *chan, User *user, const Anope::string &buf) override
- {
- if (!buf.empty())
- Uplink::Send(source, "KICK", chan->name, user->nick, buf);
- else
- Uplink::Send(source, "KICK", chan->name, user->nick);
- }
-
void SendLogin(User *u, NickServ::Nick *na) override
{
Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", na->GetAccount()->GetDisplay());
@@ -139,23 +131,8 @@ class ngIRCdProto : public IRCDProto
Uplink::Send(Me, "METADATA", u->GetUID(), "accountname", "");
}
- void SendModeInternal(const MessageSource &source, const Channel *dest, const Anope::string &buf) override
- {
- IRCMessage message(source, "MODE", dest->name);
- message.TokenizeAndPush(buf);
- Uplink::SendMessage(message);
- }
-
- void SendPartInternal(User *u, const Channel *chan, const Anope::string &buf) override
- {
- if (!buf.empty())
- Uplink::Send(u, "PART", chan->name, buf);
- else
- Uplink::Send(u, "PART", chan->name);
- }
-
/* SERVER name hop descript */
- void SendServer(const Server *server) override
+ void SendServer(Server *server) override
{
Uplink::Send("SERVER", server->GetName(), server->GetHops(), server->GetDescription());
}
diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp
index f3d147be8..cb1509a5e 100644
--- a/modules/protocol/plexus.cpp
+++ b/modules/protocol/plexus.cpp
@@ -47,21 +47,21 @@ class PlexusProto : public IRCDProto
MaxModes = 4;
}
- void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKillInternal(source, targ, reason); }
- void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); }
- void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }
+ void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKill(source, targ, reason); }
+ void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); }
+ void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }
void SendSQLine(User *u, XLine *x) override { hybrid->SendSQLine(u, x); }
void SendSQLineDel(XLine *x) override { hybrid->SendSQLineDel(x); }
void SendSGLineDel(XLine *x) override { hybrid->SendSGLineDel(x); }
void SendSGLine(User *u, XLine *x) override { hybrid->SendSGLine(u, x); }
void SendAkillDel(XLine *x) override { hybrid->SendAkillDel(x); }
void SendAkill(User *u, XLine *x) override { hybrid->SendAkill(u, x); }
- void SendServer(const Server *server) override { hybrid->SendServer(server); }
+ void SendServer(Server *server) override { hybrid->SendServer(server); }
void SendChannel(Channel *c) override { hybrid->SendChannel(c); }
void SendSVSHold(const Anope::string &nick, time_t t) override { hybrid->SendSVSHold(nick, t); }
void SendSVSHoldDel(const Anope::string &nick) override { hybrid->SendSVSHoldDel(nick); }
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
+ void SendGlobops(const MessageSource &source, const Anope::string &buf) override
{
Uplink::Send(source, "OPERWALL", buf);
}
@@ -153,7 +153,7 @@ class PlexusProto : public IRCDProto
Uplink::Send(Me, "UID", u->nick, 1, u->timestamp, modes, u->GetIdent(), u->host, "255.255.255.255", u->GetUID(), 0, u->host, u->realname);
}
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override
+ void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override
{
Uplink::Send(source, "ENCAP", "*", "SVSMODE", u->GetUID(), u->timestamp, buf);
}
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index 6d4c29f03..04f1314cc 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -62,20 +62,20 @@ class RatboxProto : public IRCDProto
MaxModes = 4;
}
- void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKillInternal(source, targ, reason); }
- void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); }
- void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }
+ void SendSVSKill(const MessageSource &source, User *targ, const Anope::string &reason) override { hybrid->SendSVSKill(source, targ, reason); }
+ void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalNotice(bi, dest, msg); }
+ void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override { hybrid->SendGlobalPrivmsg(bi, dest, msg); }
void SendSGLine(User *u, XLine *x) override { hybrid->SendSGLine(u, x); }
void SendSGLineDel(XLine *x) override { hybrid->SendSGLineDel(x); }
void SendAkill(User *u, XLine *x) override { hybrid->SendAkill(u, x); }
void SendAkillDel(XLine *x) override { hybrid->SendAkillDel(x); }
void SendJoin(User *user, Channel *c, const ChannelStatus *status) override { hybrid->SendJoin(user, c, status); }
- void SendServer(const Server *server) override { hybrid->SendServer(server); }
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override { hybrid->SendModeInternal(source, u, buf); }
+ void SendServer(Server *server) override { hybrid->SendServer(server); }
+ void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override { hybrid->SendMode(source, u, buf); }
void SendChannel(Channel *c) override { hybrid->SendChannel(c); }
bool IsIdentValid(const Anope::string &ident) override { return hybrid->IsIdentValid(ident); }
- void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) override
+ void SendGlobops(const MessageSource &source, const Anope::string &buf) override
{
Uplink::Send(source, "OPERWALL", buf);
}
diff --git a/modules/protocol/rfc1459.cpp b/modules/protocol/rfc1459.cpp
index 5d48691dc..1314f7d39 100644
--- a/modules/protocol/rfc1459.cpp
+++ b/modules/protocol/rfc1459.cpp
@@ -235,28 +235,28 @@ void rfc1459::Mode::Run(MessageSource &source, const std::vector<Anope::string>
}
}
-/* XXX We should cache the file somewhere not open/read/close it on every request */
void MOTD::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
Server *s = Server::Find(params[0]);
if (s != Me)
return;
+ /* XXX We should cache the file somewhere not open/read/close it on every request */
FILE *f = fopen(Config->GetBlock("serverinfo")->Get<Anope::string>("motd").c_str(), "r");
if (f)
{
- IRCD->SendNumeric(375, source.GetSource(), ":- %s Message of the Day", s->GetName().c_str());
+ IRCD->SendNumeric(RPL_MOTDSTART, source.GetUser(), Anope::Format("- {0} Message of the Day", s->GetName()));
char buf[BUFSIZE];
while (fgets(buf, sizeof(buf), f))
{
buf[strlen(buf) - 1] = 0;
- IRCD->SendNumeric(372, source.GetSource(), ":- %s", buf);
+ IRCD->SendNumeric(RPL_MOTD, source.GetUser(), Anope::Format("- {0}", buf));
}
fclose(f);
- IRCD->SendNumeric(376, source.GetSource(), ":End of /MOTD command.");
+ IRCD->SendNumeric(RPL_YOUREOPER, source.GetUser(), "End of /MOTD command.");
}
else
- IRCD->SendNumeric(422, source.GetSource(), ":- MOTD file not found! Please contact your IRC administrator.");
+ IRCD->SendNumeric(ERR_NOMOTD, source.GetUser(), "- MOTD file not found! Please contact your IRC administrator.");
}
void Notice::Run(MessageSource &source, const std::vector<Anope::string> &params)
@@ -354,12 +354,12 @@ void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> &param
Anope::string buf = message;
buf.erase(buf.begin());
buf.erase(buf.end() - 1);
- IRCD->SendCTCP(bi, u->nick, "%s", buf.c_str());
+ IRCD->SendCTCPReply(bi, u->nick, buf);
}
else if (message.substr(0, 9).equals_ci("\1VERSION\1"))
{
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- IRCD->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str());
+ IRCD->SendCTCPReply(bi, u->nick, "VERSION Anope-{0}", Anope::Version());
}
return;
}
@@ -413,50 +413,42 @@ void rfc1459::Stats::Run(MessageSource &source, const std::vector<Anope::string>
case 'l':
if (u->HasMode("OPER"))
{
- IRCD->SendNumeric(211, source.GetSource(), "Server SendBuf SentBytes SentMsgs RecvBuf RecvBytes RecvMsgs ConnTime");
- IRCD->SendNumeric(211, source.GetSource(), "%s %d %d %d %d %d %d %ld", Config->Uplinks[Anope::CurrentUplink].host.c_str(), UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, static_cast<long>(Anope::CurTime - Anope::StartTime));
+ IRCD->SendNumeric(RPL_STATSLINKINFO, u, "Server", "SendBuf", "SentBytes", "SentMsgs", "RecvBuf", "RecvBytes", "RecvMsgs", "ConnTime");
+ IRCD->SendNumeric(RPL_STATSLINKINFO, u, Config->Uplinks[Anope::CurrentUplink].host, UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, Anope::CurTime - Anope::StartTime);
}
-
- IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]);
break;
case 'o':
case 'O':
/* Check whether the user is an operator */
- if (!u->HasMode("OPER") && Config->GetBlock("options")->Get<bool>("hidestatso"))
- IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]);
- else
+ if (u->HasMode("OPER") || !Config->GetBlock("options")->Get<bool>("hidestatso"))
{
for (Oper *o : Serialize::GetObjects<Oper *>())
- IRCD->SendNumeric(243, source.GetSource(), "O * * %s %s 0", o->GetName().c_str(), o->GetType()->GetName().replace_all_cs(" ", "_").c_str());
-
- IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]);
+ IRCD->SendNumeric(RPL_STATSOLINE, u, "O", "*", "*", o->GetName(), o->GetType()->GetName().replace_all_cs(" ", "_"), "0");
}
-
break;
case 'u':
{
::Stats *s = Serialize::GetObject<::Stats *>();
long uptime = static_cast<long>(Anope::CurTime - Anope::StartTime);
- IRCD->SendNumeric(242, source.GetSource(), ":Services up %d day%s, %02d:%02d:%02d", uptime / 86400, uptime / 86400 == 1 ? "" : "s", (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60);
- IRCD->SendNumeric(250, source.GetSource(), ":Current users: %d (%d ops); maximum %d", UserListByNick.size(), OperCount, s ? s->GetMaxUserCount() : 0);
- IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]);
+ IRCD->SendNumeric(RPL_STATSUPTIME, u, Anope::Format("Services up {0} day{1}, {2}",
+ uptime / 86400, uptime / 86400 == 1 ? "" : "s",
+ Anope::printf("%02d:%02d:%02d", (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60)));
+ IRCD->SendNumeric(RPL_STATSCONN, u, Anope::Format("Current users: {0} ({1} ops); maximum {2}", UserListByNick.size(), OperCount, s ? s->GetMaxUserCount() : 0));
break;
- } /* case 'u' */
-
- default:
- IRCD->SendNumeric(219, source.GetSource(), "%c :End of /STATS report.", params[0][0]);
+ }
}
+
+ IRCD->SendNumeric(RPL_ENDOFSTATS, u, params[0][0], "End of /STATS report.");
}
void Time::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
- time_t t;
- time(&t);
+ time_t t = time(NULL);
struct tm *tm = localtime(&t);
char buf[64];
strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm);
- IRCD->SendNumeric(391, source.GetSource(), "%s :%s", Me->GetName().c_str(), buf);
+ IRCD->SendNumeric(RPL_TIME, source.GetUser(), Me->GetName(), buf);
}
void Topic::Run(MessageSource &source, const std::vector<Anope::string> &params)
@@ -469,26 +461,31 @@ void Topic::Run(MessageSource &source, const std::vector<Anope::string> &params)
void Version::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
- IRCD->SendNumeric(351, source.GetSource(), "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str());
+ IRCD->SendNumeric(RPL_VERSION, source.GetUser(), "Anope-" + Anope::Version(), Me->GetName(),
+ Anope::Format("{0} - {1} - Built: {2} - Flags: {3}",
+ IRCD->GetProtocolName(), enc ? enc->name : "(none)", Anope::VersionBuildTime(), Anope::VersionFlags()));
}
void Whois::Run(MessageSource &source, const std::vector<Anope::string> &params)
{
+ User *src = source.GetUser();
User *u = User::Find(params[0]);
if (u && u->server == Me)
{
const ServiceBot *bi = ServiceBot::Find(u->GetUID());
- IRCD->SendNumeric(311, source.GetSource(), "%s %s %s * :%s", u->nick.c_str(), u->GetIdent().c_str(), u->host.c_str(), u->realname.c_str());
+ IRCD->SendNumeric(RPL_WHOISUSER, src, u->nick, u->GetIdent(), u->host, "*", u->realname);
if (bi)
- IRCD->SendNumeric(307, source.GetSource(), "%s :is a registered nick", bi->nick.c_str());
- IRCD->SendNumeric(312, source.GetSource(), "%s %s :%s", u->nick.c_str(), Me->GetName().c_str(), Config->GetBlock("serverinfo")->Get<Anope::string>("description").c_str());
+ IRCD->SendNumeric(RPL_WHOISREGNICK, src, bi->nick, "is a registered nick");
+ IRCD->SendNumeric(RPL_WHOISSERVER, src, u->nick, Me->GetName(), Config->GetBlock("serverinfo")->Get<Anope::string>("description"));
if (bi)
- IRCD->SendNumeric(317, source.GetSource(), "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), static_cast<long>(Anope::CurTime - bi->lastmsg), static_cast<long>(bi->signon));
- IRCD->SendNumeric(318, source.GetSource(), "%s :End of /WHOIS list.", u->nick.c_str());
+ IRCD->SendNumeric(RPL_WHOISIDLE, src, bi->nick, Anope::CurTime - bi->lastmsg, bi->signon, "seconds idle, signon time");
+ IRCD->SendNumeric(RPL_ENDOFWHOIS, src, u->nick, "End of /WHOIS list.");
}
else
- IRCD->SendNumeric(401, source.GetSource(), "%s :No such user.", params[0].c_str());
+ {
+ IRCD->SendNumeric(ERR_NOSUCHNICK, src, params[0], "No such user.");
+ }
}
class ProtoRFC1459 : public Module
diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp
index d601b0479..259a64c9c 100644
--- a/modules/protocol/unreal.cpp
+++ b/modules/protocol/unreal.cpp
@@ -49,7 +49,7 @@ class UnrealIRCdProto : public IRCDProto
private:
/* SVSNOOP */
- void SendSVSNOOP(const Server *server, bool set) override
+ void SendSVSNOOP(Server *server, bool set) override
{
Uplink::Send("SVSNOOP", server->GetSID(), set ? "+" : "-");
}
@@ -78,12 +78,12 @@ class UnrealIRCdProto : public IRCDProto
Uplink::Send(source, "TOPIC", c->name, c->topic_setter, c->topic_ts, c->topic);
}
- void SendGlobalNotice(ServiceBot *bi, const Server *dest, const Anope::string &msg) override
+ void SendGlobalNotice(ServiceBot *bi, Server *dest, const Anope::string &msg) override
{
Uplink::Send(bi, "NOTICE", "$" + dest->GetName(), msg);
}
- void SendGlobalPrivmsg(ServiceBot *bi, const Server *dest, const Anope::string &msg) override
+ void SendGlobalPrivmsg(ServiceBot *bi, Server *dest, const Anope::string &msg) override
{
Uplink::Send(bi, "PRIVMSG", "$" + dest->GetName(), msg);
}
@@ -147,13 +147,13 @@ class UnrealIRCdProto : public IRCDProto
Uplink::Send("TKL", "+", "G", x->GetUser(), x->GetHost(), x->GetBy(), Anope::CurTime + timeleft, x->GetCreated(), x->GetReason());
}
- void SendSVSKillInternal(const MessageSource &source, User *user, const Anope::string &buf) override
+ void SendSVSKill(const MessageSource &source, User *user, const Anope::string &buf) override
{
Uplink::Send(source, "SVSKILL", user->GetUID(), buf);
user->KillInternal(source, buf);
}
- void SendModeInternal(const MessageSource &source, User *u, const Anope::string &buf) override
+ void SendMode(const MessageSource &source, User *u, const Anope::string &buf) override
{
IRCMessage message(source, "SVS2MODE", u->GetUID());
message.TokenizeAndPush(buf);
@@ -168,7 +168,7 @@ class UnrealIRCdProto : public IRCDProto
/* SERVER name hop descript */
/* Unreal 3.2 actually sends some info about itself in the descript area */
- void SendServer(const Server *server) override
+ void SendServer(Server *server) override
{
if (!server->GetSID().empty() && server == Me)
Uplink::Send("SERVER", server->GetName(), server->GetHops() + 1, server->GetDescription());
@@ -356,9 +356,9 @@ class UnrealIRCdProto : public IRCDProto
{
/* 3.2.10.4+ treats users logged in with accounts as fully registered, even if -r, so we can not set this here. Just use the timestamp. */
if (Servers::Capab.count("ESVID") > 0 && !na->GetAccount()->IsUnconfirmed())
- IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %s", na->GetAccount()->GetDisplay().c_str());
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", na->GetAccount()->GetDisplay());
else
- IRCD->SendMode(Config->GetClient("NickServ"), u, "+d %d", u->signon);
+ IRCD->SendMode(Config->GetClient("NickServ"), u, "+d {0}", u->signon);
}
void SendLogout(User *u) override
@@ -582,7 +582,7 @@ class ChannelModeFlood : public ChannelModeParam
try
{
Anope::string rest;
- if (value[0] != ':' && convertTo<unsigned>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<unsigned>(rest.substr(1), rest, false) > 0 && rest.empty())
+ if (value[0] != ':' && convertTo<unsigned int>(value[0] == '*' ? value.substr(1) : value, rest, false) > 0 && rest[0] == ':' && rest.length() > 1 && convertTo<unsigned int>(rest.substr(1), rest, false) > 0 && rest.empty())
return true;
}
catch (const ConvertException &) { }