From 161aef18486a0852a6a1d63bba5d58f23558b429 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 9 Aug 2023 06:17:18 +0100 Subject: Add an extban for matching against an operator account. --- src/modules/m_operchans.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/modules/m_operchans.cpp') 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) { } -- cgit v1.3.1-10-gc9f91