mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Add an extban for matching against an operator account.
This commit is contained in:
parent
ce74cf9659
commit
161aef1848
@ -1715,11 +1715,9 @@
|
||||
#<ojoin prefix="!" notice="yes" op="yes">
|
||||
|
||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||
# Oper channels mode: Adds the +O channel mode and extban O:<mask>
|
||||
# to ban, except, etc. specific oper types. For example
|
||||
# /MODE #channel +iI O:* is equivalent to channel mode +O, but you
|
||||
# may also set +iI O:AdminTypeOnly to only allow admins.
|
||||
# Modes +I and +e work in a similar fashion.
|
||||
# Oper channels mode: Adds the +O channel mode which restricts channel
|
||||
# access to server operators and extbans O:<type> and o:<account> that
|
||||
# match against an oper type and oper account respectively.
|
||||
#<module name="operchans">
|
||||
|
||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user