1
0
mirror of https://github.com/anope/anope.git synced 2026-06-27 21:26:37 +02:00

Add support for numerics associated with cs_set_misc entries.

This is mainly to allow the URL entry to use RPL_CHANNELURL.
This commit is contained in:
Sadie Powell
2024-11-29 20:35:44 +00:00
parent 026d6c461d
commit ea8a692191
3 changed files with 26 additions and 1 deletions
+24
View File
@@ -15,6 +15,7 @@
static Module *me;
static Anope::map<Anope::string> descriptions;
static Anope::map<uint16_t> numerics;
struct CSMiscData;
static Anope::map<ExtensibleItem<CSMiscData> *> items;
@@ -189,6 +190,7 @@ public:
void OnReload(Configuration::Conf *conf) override
{
descriptions.clear();
numerics.clear();
for (int i = 0; i < conf->CountBlock("command"); ++i)
{
@@ -204,9 +206,31 @@ public:
continue;
descriptions[cname] = desc;
auto numeric = block->Get<unsigned>("misc_numeric");
if (numeric >= 1 && numeric <= 999)
numerics["cs_set_misc:" + GetAttribute(cname)] = numeric;
}
}
void OnJoinChannel(User *user, Channel *c) override
{
if (!c->ci || !user->server->IsSynced() || numerics.empty())
return;
for (const auto &[name, ext] : items)
{
auto *data = ext->Get(c->ci);
if (!data)
continue;
auto numeric = numerics.find(name);
if (numeric != numerics.end())
IRCD->SendNumeric(numeric->second, user->GetUID(), c->ci->name, data->data);
}
}
void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool) override
{
for (const auto &[_, e] : items)