aboutsummaryrefslogtreecommitdiffstats
path: root/modules/helpmode.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2025-03-10 19:41:57 +0000
committerGravatar Sadie Powell2025-03-10 19:41:57 +0000
commitb3f973085679009d43e1c06b9d9de0ca031474a9 (patch)
tree057b76a3ef62a649137cf80794379fd4e34e4423 /modules/helpmode.cpp
parentMerge branch 'insp4' into master. (diff)
parentAdd <helpchan> for granting privs to helpers on join. (diff)
Merge branch 'insp4' into master.
Diffstat (limited to 'modules/helpmode.cpp')
-rw-r--r--modules/helpmode.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/modules/helpmode.cpp b/modules/helpmode.cpp
index 96304b477..1241b17f0 100644
--- a/modules/helpmode.cpp
+++ b/modules/helpmode.cpp
@@ -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);
@@ -91,7 +102,7 @@ public:
std::string extra;
if (helper->IsAway())
{
- const std::string awayperiod = Duration::ToHuman(ServerInstance->Time() - helper->away->time);
+ const std::string awayperiod = Duration::ToHuman(ServerInstance->Time() - helper->away->time, true);
const std::string awaytime = Time::ToString(helper->away->time);
extra = FMT::format(": away for {} [since {}] ({})", awayperiod, awaytime, helper->away->message);
@@ -100,7 +111,7 @@ public:
auto* lhelper = IS_LOCAL(helper);
if (lhelper)
{
- const std::string idleperiod = Duration::ToHuman(ServerInstance->Time() - lhelper->idle_lastmsg);
+ const std::string idleperiod = Duration::ToHuman(ServerInstance->Time() - lhelper->idle_lastmsg, true);
const std::string idletime = Time::ToString(lhelper->idle_lastmsg);
extra += FMT::format("{} idle for {} [since {}]", extra.empty() ? ':' : ',', idleperiod, idletime);
@@ -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))