summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-06-07 20:11:40 +0100
committerPeter Powell <petpow@saberuk.com>2019-06-07 20:22:43 +0100
commit8bbd67b1f7b87df9b36a950b3b699c5b76a1748f (patch)
tree87ee05f2fc6781a5fbf2ec2f51e4905a62dd48da /src
parentf6b33a8facd6ca200292786c1061782c41cdd278 (diff)
Add an option to the filter module to ignore self messages.
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_filter.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index c0798f7d0..a036052f6 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -179,6 +179,7 @@ class ModuleFilter : public Module, public ServerEventListener, public Stats::Ev
bool initing;
bool notifyuser;
+ bool warnonselfmsg;
RegexFactory* factory;
void FreeFilters();
@@ -369,6 +370,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
FilterResult* f = this->FilterMatch(user, details.text, flags);
if (f)
{
+ bool is_selfmsg = false;
std::string target;
if (msgtarget.type == MessageTarget::TYPE_USER)
{
@@ -377,6 +379,9 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
if (exemptednicks.count(t->nick))
return MOD_RES_PASSTHRU;
+ if (user == t)
+ is_selfmsg = true;
+
target = t->nick;
}
else if (msgtarget.type == MessageTarget::TYPE_CHANNEL)
@@ -387,13 +392,20 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar
target = t->name;
}
- if (f->action == FA_WARN)
+
+ if (is_selfmsg & warnonselfmsg)
+ {
+ ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("WARNING: %s's self message matched %s (%s)",
+ user->nick.c_str(), f->freeform.c_str(), f->reason.c_str()));
+ return MOD_RES_PASSTHRU;
+ }
+ else if (f->action == FA_WARN)
{
ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("WARNING: %s's message to %s matched %s (%s)",
user->nick.c_str(), target.c_str(), f->freeform.c_str(), f->reason.c_str()));
return MOD_RES_PASSTHRU;
}
- if (f->action == FA_BLOCK)
+ else if (f->action == FA_BLOCK)
{
ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("%s had their message to %s filtered as it matched %s (%s)",
user->nick.c_str(), target.c_str(), f->freeform.c_str(), f->reason.c_str()));
@@ -609,6 +621,7 @@ void ModuleFilter::ReadConfig(ConfigStatus& status)
ConfigTag* tag = ServerInstance->Config->ConfValue("filteropts");
std::string newrxengine = tag->getString("engine");
notifyuser = tag->getBool("notifyuser", true);
+ warnonselfmsg = tag->getBool("warnonselfmsg");
factory = RegexEngine ? (RegexEngine.operator->()) : NULL;