Add <helpchan> for granting privs to helpers on join.

This commit is contained in:
Sadie Powell 2025-03-08 17:32:23 +00:00
parent 41124e1ad1
commit ad85c6cb42
2 changed files with 28 additions and 1 deletions

View File

@ -830,7 +830,7 @@ using their cloak when they quit.
g In combination with /ACCEPT, provides for server-side
ignore (requires the callerid module).
h Marks as 'available for help' in WHOIS (server operators
only, requires the helpmsg module).
only, requires the helpmode module).
i Makes invisible to /WHO if the user using /WHO is not in
a common channel.
k Prevents the user from being kicked from channels, or

View File

@ -57,6 +57,8 @@ private:
HelpOp helpop;
UserModeReference hideoper;
bool markhelpers;
std::string helpchanmodes;
insp::flat_map<std::string, std::string> 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, "<helpchan:name> 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))