1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 07:56:39 +02:00

Change the return type of ircdmessage to void now that we don't use it, add an ircd message module event, and a few more fixups

This commit is contained in:
Adam
2012-11-23 16:56:06 -05:00
parent 0e7bd9f3ba
commit 36b1166cf6
17 changed files with 227 additions and 345 deletions
+31 -56
View File
@@ -418,7 +418,7 @@ struct IRCDMessageCapab : Message::Capab
{
IRCDMessageCapab(Module *creator) : Message::Capab(creator, "CAPAB") { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
if (params[0].equals_cs("START"))
{
@@ -726,21 +726,21 @@ struct IRCDMessageCapab : Message::Capab
UplinkSocket::Message() << "ERROR :m_globops is not loaded. This is required by Anope";
Anope::QuitReason = "Remote server does not have the m_globops module loaded, and this is required.";
Anope::Quitting = true;
return false;
return;
}
if (!has_servicesmod)
{
UplinkSocket::Message() << "ERROR :m_services_account.so is not loaded. This is required by Anope";
Anope::QuitReason = "ERROR: Remote server does not have the m_services_account module loaded, and this is required.";
Anope::Quitting = true;
return false;
return;
}
if (!has_hidechansmod)
{
UplinkSocket::Message() << "ERROR :m_hidechans.so is not loaded. This is required by Anope";
Anope::QuitReason = "ERROR: Remote server does not have the m_hidechans module loaded, and this is required.";
Anope::Quitting = true;
return false;
return;
}
if (!IRCD->CanSVSHold)
Log() << "SVSHOLD missing, Usage disabled until module is loaded.";
@@ -750,9 +750,7 @@ struct IRCDMessageCapab : Message::Capab
Log() << "CHGIDENT missing, Usage disabled until module is loaded.";
}
Servers::Capab.insert("NOQUIT");
return Message::Capab::Run(source, params);
Message::Capab::Run(source, params);
}
};
@@ -760,12 +758,11 @@ struct IRCDMessageChgIdent : IRCDMessage
{
IRCDMessageChgIdent(Module *creator) : IRCDMessage(creator, "CHGIDENT", 2) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
User *u = User::Find(params[0]);
if (u)
u->SetIdent(params[1]);
return true;
}
};
@@ -773,10 +770,9 @@ struct IRCDMessageChgName : IRCDMessage
{
IRCDMessageChgName(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
source.GetUser()->SetRealname(params[0]);
return true;
}
};
@@ -784,14 +780,13 @@ struct IRCDMessageEndburst : IRCDMessage
{
IRCDMessageEndburst(Module *creator) : IRCDMessage(creator, "ENDBURST", 0) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
Server *s = source.GetServer();
Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName();
s->Sync(true);
return true;
}
};
@@ -799,10 +794,9 @@ struct IRCDMessageFHost : IRCDMessage
{
IRCDMessageFHost(Module *creator, const Anope::string &n) : IRCDMessage(creator, n, 1) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
source.GetUser()->SetDisplayedHost(params[0]);
return true;
}
};
@@ -810,7 +804,7 @@ struct IRCDMessageFJoin : IRCDMessage
{
IRCDMessageFJoin(Module *creator) : IRCDMessage(creator, "FJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
Anope::string modes;
if (params.size() >= 3)
@@ -856,8 +850,6 @@ struct IRCDMessageFJoin : IRCDMessage
time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime;
Message::Join::SJoin(source, params[0], ts, "", users);
return true;
}
};
@@ -865,7 +857,7 @@ struct IRCDMessageFMode : IRCDMessage
{
IRCDMessageFMode(Module *creator) : IRCDMessage(creator, "FMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
/* :source FMODE #test 12345678 +nto foo */
@@ -887,8 +879,6 @@ struct IRCDMessageFMode : IRCDMessage
if (c)
c->SetModesInternal(source, modes, ts);
return true;
}
};
@@ -896,15 +886,13 @@ struct IRCDMessageFTopic : IRCDMessage
{
IRCDMessageFTopic(Module *creator) : IRCDMessage(creator, "FTOPIC", 4) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
/* :source FTOPIC channel topicts setby :topic */
Channel *c = Channel::Find(params[0]);
if (c)
c->ChangeTopicInternal(params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime);
return true;
}
};
@@ -912,12 +900,11 @@ struct IRCDMessageIdle : IRCDMessage
{
IRCDMessageIdle(Module *creator) : IRCDMessage(creator, "IDLE", 1) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
const BotInfo *bi = BotInfo::Find(params[0]);
if (bi)
UplinkSocket::Message(bi) << "IDLE " << source.GetSource() << " " << Anope::StartTime << " " << (Anope::CurTime - bi->lastmsg);
return true;
}
};
@@ -931,7 +918,7 @@ struct IRCDMessageMetadata : IRCDMessage
{
IRCDMessageMetadata(Module *creator) : IRCDMessage(creator, "METADATA", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
if (isdigit(params[0][0]))
{
@@ -964,7 +951,7 @@ struct IRCDMessageMetadata : IRCDMessage
{
User *u = User::Find(params[0]);
if (!u)
return true;
return;
std::string data = params[2].c_str();
size_t pos1 = data.find(' ') + 1;
size_t pos2 = data.find(' ', pos1);
@@ -987,11 +974,11 @@ struct IRCDMessageMetadata : IRCDMessage
// only interested when it comes from our uplink
Server* server = source.GetServer();
if (!server || server->GetUplink() != Me)
return true;
return;
bool plus = (params[2][0] == '+');
if (!plus && params[2][0] != '-')
return true;
return;
bool required = false;
Anope::string module = params[2].substr(1);
@@ -1011,7 +998,7 @@ struct IRCDMessageMetadata : IRCDMessage
else if (module.equals_cs("m_topiclock.so"))
has_svstopic_topiclock = plus;
else
return true;
return;
if (required)
{
@@ -1025,8 +1012,6 @@ struct IRCDMessageMetadata : IRCDMessage
}
}
return true;
}
};
@@ -1034,7 +1019,7 @@ struct IRCDMessageMode : IRCDMessage
{
IRCDMessageMode(Module *creator) : IRCDMessage(creator, "MODE", 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
if (IRCD->IsChannelValid(params[0]))
{
@@ -1062,8 +1047,6 @@ struct IRCDMessageMode : IRCDMessage
if (u)
u->SetModesInternal("%s", params[1].c_str());
}
return true;
}
};
@@ -1071,10 +1054,9 @@ struct IRCDMessageNick : IRCDMessage
{
IRCDMessageNick(Module *creator) : IRCDMessage(creator, "NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
source.GetUser()->ChangeNick(params[0]);
return true;
}
};
@@ -1082,27 +1064,25 @@ struct IRCDMessageOperType : IRCDMessage
{
IRCDMessageOperType(Module *creator) : IRCDMessage(creator, "OPERTYPE", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_USER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
/* opertype is equivalent to mode +o because servers
dont do this directly */
User *u = source.GetUser();
if (!u->HasMode(UMODE_OPER))
u->SetModesInternal("+o");
return true;
}
}
;
};
struct IRCDMessageRSQuit : IRCDMessage
{
IRCDMessageRSQuit(Module *creator) : IRCDMessage(creator, "RSQUIT", 1) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
Server *s = Server::Find(params[0]);
if (!s)
return true;
return;
/* On InspIRCd we must send a SQUIT when we recieve RSQUIT for a server we have juped */
if (s->HasFlag(SERVER_JUPED))
@@ -1111,8 +1091,6 @@ struct IRCDMessageRSQuit : IRCDMessage
FOREACH_MOD(I_OnServerQuit, OnServerQuit(s));
s->Delete(s->GetName() + " " + s->GetUplink()->GetName());
return true;
}
};
@@ -1120,10 +1098,9 @@ struct IRCDMessageSetIdent : IRCDMessage
{
IRCDMessageSetIdent(Module *creator) : IRCDMessage(creator, "SETIDENT", 0) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
source.GetUser()->SetIdent(params[0]);
return true;
}
};
@@ -1139,11 +1116,10 @@ struct IRCDMessageServer : IRCDMessage
* 3: numeric
* 4: desc
*/
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
unsigned int hops = Anope::string(params[2]).is_pos_number_only() ? convertTo<unsigned>(params[2]) : 0;
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[4], params[3]);
return true;
}
};
@@ -1151,10 +1127,9 @@ struct IRCDMessageTime : IRCDMessage
{
IRCDMessageTime(Module *creator) : IRCDMessage(creator, "TIME", 2) { }
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
UplinkSocket::Message(Me) << "TIME " << source.GetSource() << " " << params[1] << " " << Anope::CurTime;
return true;
}
};
@@ -1175,7 +1150,7 @@ struct IRCDMessageUID : IRCDMessage
* 8+: modes and params -- IMPORTANT, some modes (e.g. +s) may have parameters. So don't assume a fixed position of realname!
* last: realname
*/
bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
time_t ts = convertTo<time_t>(params[1]);
@@ -1186,8 +1161,6 @@ struct IRCDMessageUID : IRCDMessage
User *u = new User(params[2], params[5], params[3], params[4], params[6], source.GetServer(), params[params.size() - 1], ts, modes, params[0]);
if (u->server->IsSynced() && NickServService)
NickServService->Validate(u);
return true;
}
};
@@ -1247,6 +1220,8 @@ class ProtoInspIRCd : public Module
Implementation i[] = { I_OnUserNickChange, I_OnServerSync };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
Servers::Capab.insert("NOQUIT");
if (Config->Numeric.empty())
{
Anope::string numeric = Servers::TS6_SID_Retrieve();