1
0
mirror of https://github.com/anope/anope.git synced 2026-06-25 10:16:39 +02:00

Make CTCP support more modular.

This commit is contained in:
Sadie Powell
2025-05-10 14:15:27 +01:00
parent 7b2f0f5790
commit 50030e07fa
3 changed files with 35 additions and 10 deletions
+30
View File
@@ -34,6 +34,36 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
if (!this->uid.empty())
(*BotListByUID)[this->uid] = this;
ctcps.emplace("CLIENTINFO", [this](auto *bi, auto *u, const auto &)
{
Anope::string buf;
for (const auto &[ctcp, _] : this->ctcps)
{
if (!buf.empty())
buf.push_back(' ');
buf.append(ctcp.upper());
}
IRCD->SendNotice(bi, u->GetUID(), Anope::FormatCTCP("CLIENTINFO", buf));
});
ctcps.emplace("PING", [](auto *bi, auto *u, const auto &ctcpbody)
{
IRCD->SendNotice(bi, u->GetUID(), Anope::FormatCTCP("PING", ctcpbody));
});
ctcps.emplace("SOURCE", [](auto *bi, auto *u, const auto &)
{
IRCD->SendNotice(bi, u->GetUID(), Anope::FormatCTCP("SOURCE", "https://www.anope.org/"));
});
ctcps.emplace("TIME", [](auto *bi, auto *u, const auto &)
{
IRCD->SendNotice(bi, u->GetUID(), Anope::FormatCTCP("TIME", Anope::strftime(Anope::CurTime, nullptr, true)));
});
ctcps.emplace("VERSION", [](auto *bi, auto *u, const auto &)
{
auto *enc = ModuleManager::FindFirstOf(ENCRYPTION);
IRCD->SendNotice(bi, u->GetUID(), Anope::FormatCTCP("VERSION", Anope::printf("Anope-%s %s -- %s -- %s", Anope::Version().c_str(),
Anope::VersionBuildString().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)")));
});
FOREACH_MOD(OnCreateBot, (this));
// If we're synchronised with the uplink already, send the bot.