aboutsummaryrefslogtreecommitdiff
path: root/modules/helpmode.cpp
diff options
context:
space:
mode:
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;
}