Skip to content

Commit

Permalink
Allow inverting the purpose of the blockhighlight mode.
Browse files Browse the repository at this point in the history
When inverted the mode will DISABLE mass highlight blockin g.
  • Loading branch information
SadieCat committed Jul 5, 2023
1 parent 530a46b commit a78ed68
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions 3/m_blockhighlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/// $ModAuthor: Sadie Powell
/// $ModAuthorMail: sadie@witchery.services
/// $ModConfig: <blockhighlight ignoreextmsg="yes" minlen="50" minusernum="10" reason="Mass highlight spam is not allowed" stripcolor="yes" modechar="V">
/// $ModConfig: <blockhighlight ignoreextmsg="yes" minlen="50" minusernum="10" reason="Mass highlight spam is not allowed" stripcolor="yes" modechar="V" invertmode="no">
/// $ModDesc: Adds a channel mode which kills clients that mass highlight spam.
/// $ModDepends: core 3

Expand All @@ -33,6 +33,7 @@ class ModuleBlockHighlight : public Module
CheckExemption::EventProvider exemptionprov;

bool ignoreextmsg;
bool invertmode;
unsigned int minlen;
unsigned int minusers;
std::string reason;
Expand All @@ -50,6 +51,7 @@ class ModuleBlockHighlight : public Module
{
ConfigTag* tag = ServerInstance->Config->ConfValue("blockhighlight");
ignoreextmsg = tag->getBool("ignoreextmsg", true);
invertmode = tag->getBool("invertmode");
minlen = tag->getUInt("minlen", 50, 1, ServerInstance->Config->Limits.MaxLine);
minusers = tag->getUInt("minusernum", 10, 2);
reason = tag->getString("reason", "Mass highlight spam is not allowed");
Expand All @@ -69,8 +71,8 @@ class ModuleBlockHighlight : public Module
if (chan->GetUsers().size() < minusers)
return MOD_RES_PASSTHRU;

// We only work if the channel mode is enabled.
if (!chan->IsModeSet(mode))
// We only work if the channel mode is in the right state.
if (chan->IsModeSet(mode) == invertmode)
return MOD_RES_PASSTHRU;

// Exempt operators with the channels/mass-highlight privilege.
Expand Down Expand Up @@ -118,7 +120,8 @@ class ModuleBlockHighlight : public Module

Version GetVersion() CXX11_OVERRIDE
{
return Version("Adds a channel mode which kills clients that mass highlight spam.");
const std::string linkdata = invertmode ? "inverted" : "";
return Version("Adds a channel mode which kills clients that mass highlight spam.", VF_NONE, linkdata);
}
};

Expand Down

0 comments on commit a78ed68

Please sign in to comment.