From ad85c6cb42c007e3a13d6ada08a52487e855ed28 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 8 Mar 2025 17:32:23 +0000 Subject: Add for granting privs to helpers on join. --- src/modules/m_helpmode.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/modules/m_helpmode.cpp') diff --git a/src/modules/m_helpmode.cpp b/src/modules/m_helpmode.cpp index 095e35ecc..7083aec48 100644 --- a/src/modules/m_helpmode.cpp +++ b/src/modules/m_helpmode.cpp @@ -57,6 +57,8 @@ private: HelpOp helpop; UserModeReference hideoper; bool markhelpers; + std::string helpchanmodes; + insp::flat_map helpchans; public: ModuleHelpMode() @@ -70,6 +72,15 @@ public: void ReadConfig(ConfigStatus& status) override { + for (const auto& [_, tag] : ServerInstance->Config->ConfTags("helpchan")) + { + const auto name = tag->getString("name"); + if (name.empty()) + throw ModuleException(this, " must not be empty at " + tag->source.str()); + + helpchans[name] = tag->getString("prefix", "o", 1); + } + const auto& tag = ServerInstance->Config->ConfValue("helpmode"); ignorehideoper = tag->getBool("ignorehideoper"); markhelpers = tag->getBool("markhelpers", true); @@ -114,6 +125,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 + { + if (!user->IsModeSet(helpop)) + return MOD_RES_PASSTHRU; + + for (const auto& [helpchan, prefix] : helpchans) + { + if (InspIRCd::Match(cname, helpchan)) + { + privs.append(prefix); + break; + } + } + return MOD_RES_PASSTHRU; + } + void OnUserQuit(User* user, const std::string& message, const std::string& opermessage) override { if (user->IsModeSet(helpop)) -- cgit v1.3.1-10-gc9f91