mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Optionally do not notify users if their messages are blocked by certain modules (#1134).
Closes #711.
This commit is contained in:
parent
49c35af6af
commit
46e71e2f50
@ -402,7 +402,10 @@
|
||||
# his/her message is blocked.
|
||||
#
|
||||
# If maxlen is set then it defines the maximum length of a filter entry.
|
||||
#<chanfilter hidemask="yes" maxlen="50">
|
||||
#
|
||||
# If notifyuser is set to no, the user will not be notified when
|
||||
# his/her message is blocked.
|
||||
#<chanfilter hidemask="yes" maxlen="50" notifyuser="yes">
|
||||
|
||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||
# Channel history module: Displays the last 'X' lines of chat to a user
|
||||
@ -785,14 +788,16 @@
|
||||
# stdlib - stdlib regexps, provided via regex_stdlib, see comment #
|
||||
# at the <module> tag for info on availability. #
|
||||
# #
|
||||
#<filteropts engine="glob"> #
|
||||
# If notifyuser is set to no, the user will not be notified when #
|
||||
# his/her message is blocked. #
|
||||
#<filteropts engine="glob" notifyuser="yes">
|
||||
# #
|
||||
# Your choice of regex engine must match on all servers network-wide. #
|
||||
# #
|
||||
# Your choice of regex engine must match on all servers network-wide.
|
||||
#
|
||||
# To learn more about the configuration of this module, read #
|
||||
# examples/filter.conf.example, which covers the various types of #
|
||||
# filters and shows how to add exemptions. #
|
||||
#
|
||||
# #
|
||||
#-#-#-#-#-#-#-#-#-#-#- FILTER CONFIGURATION -#-#-#-#-#-#-#-#-#-#-#-#
|
||||
# #
|
||||
# Optional - If you specify to use the filter module, then #
|
||||
@ -1536,6 +1541,10 @@
|
||||
# Muteban: Implements extended ban 'm', which stops anyone matching
|
||||
# a mask like +b m:nick!user@host from speaking on channel.
|
||||
#<module name="muteban">
|
||||
#
|
||||
# If notifyuser is set to no, the user will not be notified when
|
||||
# his/her message is blocked.
|
||||
#<muteban notifyuser="yes">
|
||||
|
||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||
# Random quote module: Provides a random quote on connect.
|
||||
|
@ -46,7 +46,7 @@ class ChanFilter : public ListModeBase
|
||||
|
||||
bool ValidateParam(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE
|
||||
{
|
||||
if (word.length() > maxlen)
|
||||
if (word.length() > maxlen)
|
||||
{
|
||||
user->WriteNumeric(Numerics::InvalidModeParameter(chan, this, word, "Word is too long for the spamfilter list"));
|
||||
return false;
|
||||
@ -76,6 +76,7 @@ class ModuleChanFilter : public Module
|
||||
CheckExemption::EventProvider exemptionprov;
|
||||
ChanFilter cf;
|
||||
bool hidemask;
|
||||
bool notifyuser;
|
||||
|
||||
public:
|
||||
|
||||
@ -90,6 +91,7 @@ class ModuleChanFilter : public Module
|
||||
ConfigTag* tag = ServerInstance->Config->ConfValue("chanfilter");
|
||||
hidemask = tag->getBool("hidemask");
|
||||
cf.maxlen = tag->getUInt("maxlen", 35, 10, 100);
|
||||
notifyuser = tag->getBool("notifyuser", true);
|
||||
cf.DoRehash();
|
||||
}
|
||||
|
||||
@ -112,6 +114,12 @@ class ModuleChanFilter : public Module
|
||||
{
|
||||
if (InspIRCd::Match(details.text, i->mask))
|
||||
{
|
||||
if (!notifyuser)
|
||||
{
|
||||
details.echooriginal = true;
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
||||
if (hidemask)
|
||||
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (your message contained a censored word)");
|
||||
else
|
||||
|
@ -166,6 +166,7 @@ class ModuleFilter : public Module, public ServerEventListener, public Stats::Ev
|
||||
typedef insp::flat_set<std::string, irc::insensitive_swo> ExemptTargetSet;
|
||||
|
||||
bool initing;
|
||||
bool notifyuser;
|
||||
RegexFactory* factory;
|
||||
void FreeFilters();
|
||||
|
||||
@ -356,17 +357,27 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
|
||||
if (f->action == FA_BLOCK)
|
||||
{
|
||||
ServerInstance->SNO->WriteGlobalSno('a', "FILTER: "+user->nick+" had their message filtered, target was "+target+": "+f->reason);
|
||||
if (msgtarget.type == MessageTarget::TYPE_CHANNEL)
|
||||
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked and opers notified (%s)", f->reason.c_str()));
|
||||
if (notifyuser)
|
||||
{
|
||||
if (msgtarget.type == MessageTarget::TYPE_CHANNEL)
|
||||
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked and opers notified (%s)", f->reason.c_str()));
|
||||
else
|
||||
user->WriteNotice("Your message to "+target+" was blocked and opers notified: "+f->reason);
|
||||
}
|
||||
else
|
||||
user->WriteNotice("Your message to "+target+" was blocked and opers notified: "+f->reason);
|
||||
details.echooriginal = true;
|
||||
}
|
||||
else if (f->action == FA_SILENT)
|
||||
{
|
||||
if (msgtarget.type == MessageTarget::TYPE_CHANNEL)
|
||||
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked (%s)", f->reason.c_str()));
|
||||
if (notifyuser)
|
||||
{
|
||||
if (msgtarget.type == MessageTarget::TYPE_CHANNEL)
|
||||
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked (%s)", f->reason.c_str()));
|
||||
else
|
||||
user->WriteNotice("Your message to "+target+" was blocked: "+f->reason);
|
||||
}
|
||||
else
|
||||
user->WriteNotice("Your message to "+target+" was blocked: "+f->reason);
|
||||
details.echooriginal = true;
|
||||
}
|
||||
else if (f->action == FA_KILL)
|
||||
{
|
||||
@ -508,7 +519,9 @@ void ModuleFilter::ReadConfig(ConfigStatus& status)
|
||||
}
|
||||
}
|
||||
|
||||
std::string newrxengine = ServerInstance->Config->ConfValue("filteropts")->getString("engine");
|
||||
ConfigTag* tag = ServerInstance->Config->ConfValue("filteropts");
|
||||
std::string newrxengine = tag->getString("engine");
|
||||
notifyuser = tag->getBool("notifyuser", true);
|
||||
|
||||
factory = RegexEngine ? (RegexEngine.operator->()) : NULL;
|
||||
|
||||
|
@ -36,6 +36,13 @@ class ModuleQuietBan : public Module
|
||||
Channel* chan = target.Get<Channel>();
|
||||
if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE)
|
||||
{
|
||||
bool notifyuser = ServerInstance->Config->ConfValue("muteban")->getBool("notifyuser", true);
|
||||
if (!notifyuser)
|
||||
{
|
||||
details.echooriginal = true;
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
||||
user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're muted)");
|
||||
return MOD_RES_DENY;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user