aboutsummaryrefslogtreecommitdiff
path: root/modules/helpmode.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2026-03-12 15:15:38 +0000
committerGravatar Sadie Powell2026-03-12 15:38:54 +0000
commit7ed7c7ba0dfd3f73a7d8a621988d7e99f07a23ef (patch)
tree1f98a809b4018a6cabfe17aa2549507072840438 /modules/helpmode.cpp
parentMove channel settings to the <channels> tag. (diff)
Move <options:defaultmodes> to <channels> and rework.
- The default prefix modes are now separate from the default channel modes. This should result in less accidentally broken configs. - The privs are now pre-parsed to a list of mode references. This should improve performance slightly as the repeated mode lookups are gone. It also allows us to write warnings to the debug log when the default privs are invalid. - Channels can now have a default topic.
Diffstat (limited to 'modules/helpmode.cpp')
-rw-r--r--modules/helpmode.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/modules/helpmode.cpp b/modules/helpmode.cpp
index 6bca93ba5..635905129 100644
--- a/modules/helpmode.cpp
+++ b/modules/helpmode.cpp
@@ -57,8 +57,10 @@ private:
HelpOp helpop;
UserModeReference hideoper;
bool markhelpers;
- std::string helpchanmodes;
- insp::flat_map<std::string, std::string> helpchans;
+
+ // <helpchan:prefix>
+ using HelpChanMap = insp::flat_map<std::string, std::vector<ChanModeReference>>;
+ HelpChanMap helpchans;
public:
ModuleHelpMode()
@@ -72,14 +74,22 @@ public:
void ReadConfig(ConfigStatus& status) override
{
+ HelpChanMap newhelpchans;
for (const auto& [_, tag] : ServerInstance->Config->ConfTags("helpchan"))
{
const auto name = tag->getString("name");
if (name.empty())
throw ModuleException(this, "<helpchan:name> must not be empty at " + tag->source.str());
- helpchans[name] = tag->getString("prefix", "o", 1);
+ auto& newhelpchan = newhelpchans[name];
+ for (const auto modechr : tag->getString("prefix", "o", 1))
+ {
+ auto* mh = ServerInstance->Modes.FindPrefixMode(modechr);
+ if (mh)
+ newhelpchan.push_back(ChanModeReference(this, mh->service_name));
+ }
}
+ std::swap(helpchans, newhelpchans);
const auto& tag = ServerInstance->Config->ConfValue("helpmode");
ignorehideoper = tag->getBool("ignorehideoper");
@@ -125,18 +135,22 @@ public:
return MOD_RES_PASSTHRU;
}
- ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven, bool override) override
+ ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, PrefixMode::Set& privs, const std::string& keygiven, bool override) override
{
if (!user->IsModeSet(helpop))
return MOD_RES_PASSTHRU;
- for (const auto& [helpchan, prefix] : helpchans)
+ for (auto& [helpchan, prefixes] : helpchans)
{
- if (InspIRCd::Match(cname, helpchan))
+ if (!InspIRCd::Match(cname, helpchan))
+ continue;
+
+ for (auto& prefix : prefixes)
{
- privs.append(prefix);
- break;
+ if (prefix && prefix->IsPrefixMode())
+ privs.insert(prefix->IsPrefixMode());
}
+ break;
}
return MOD_RES_PASSTHRU;
}