diff options
| author | 2023-08-09 06:17:18 +0100 | |
|---|---|---|
| committer | 2023-08-09 06:19:24 +0100 | |
| commit | 161aef18486a0852a6a1d63bba5d58f23558b429 (patch) | |
| tree | cebd794a3b96cbc3c7397d72ec43833f73e50ae2 /src/modules/m_operchans.cpp | |
| parent | Rename the O: extban to opertype. (diff) | |
Add an extban for matching against an operator account.
Diffstat (limited to 'src/modules/m_operchans.cpp')
| -rw-r--r-- | src/modules/m_operchans.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp index 663addb39..41995c14f 100644 --- a/src/modules/m_operchans.cpp +++ b/src/modules/m_operchans.cpp @@ -32,6 +32,28 @@ enum ERR_CANTJOINOPERSONLY = 520 }; +class OperAccountExtBan final + : public ExtBan::MatchingBase +{ +public: + OperAccountExtBan(Module* Creator) + : ExtBan::MatchingBase(Creator, "oper", 'o') + { + } + + bool IsMatch(User* user, Channel* channel, const std::string& text) override + { + // If the user is not an oper they can't match this. + if (!user->IsOper()) + return false; + + // Replace spaces with underscores as they're prohibited in mode parameters. + std::string opername(user->oper->GetName()); + std::replace(opername.begin(), opername.end(), ' ', '_'); + return InspIRCd::Match(opername, text); + } +}; + class OperTypeExtBan final : public ExtBan::MatchingBase { @@ -59,12 +81,14 @@ class ModuleOperChans final { private: SimpleChannelMode oc; + OperAccountExtBan operaccount; OperTypeExtBan opertype; public: ModuleOperChans() : Module(VF_VENDOR, "Adds channel mode O (operonly) which prevents non-server operators from joining the channel.") , oc(this, "operonly", 'O', true) + , operaccount(this) , opertype(this) { } |
