summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFilippo Cortigiani <simos@simosnap.org>2019-05-20 15:15:00 +0200
committerPeter Powell <petpow@saberuk.com>2019-05-20 14:15:00 +0100
commit96cc17f65196391a64c38ffcbfb57b8f54ced4b3 (patch)
treee593f7c0e5630d55a81821b700b21336a905b10c /src
parent232332e064312b30de81230fbb7805e38a57c8f1 (diff)
Add an option to the filter module to exclude registered users from a filter.
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_filter.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp
index b2febf810..cad26be62 100644
--- a/src/modules/m_filter.cpp
+++ b/src/modules/m_filter.cpp
@@ -26,6 +26,7 @@
#include "modules/server.h"
#include "modules/shun.h"
#include "modules/stats.h"
+#include "modules/account.h"
enum FilterFlags
{
@@ -58,6 +59,7 @@ class FilterResult
bool from_config;
bool flag_no_opers;
+ bool flag_no_registered;
bool flag_part_message;
bool flag_quit_message;
bool flag_privmsg;
@@ -79,7 +81,7 @@ class FilterResult
char FillFlags(const std::string &fl)
{
- flag_no_opers = flag_part_message = flag_quit_message = flag_privmsg =
+ flag_no_opers = flag_no_registered = flag_part_message = flag_quit_message = flag_privmsg =
flag_notice = flag_strip_color = false;
for (std::string::const_iterator n = fl.begin(); n != fl.end(); ++n)
@@ -104,6 +106,9 @@ class FilterResult
case 'c':
flag_strip_color = true;
break;
+ case 'r':
+ flag_no_registered = true;
+ break;
case '*':
flag_no_opers = flag_part_message = flag_quit_message =
flag_privmsg = flag_notice = flag_strip_color = true;
@@ -129,13 +134,14 @@ class FilterResult
flags.push_back('p');
if (flag_notice)
flags.push_back('n');
-
/* Order is important here, 'c' must be the last char in the string as it is unsupported
* on < 2.0.10, and the logic in FillFlags() stops parsing when it ecounters an unknown
* character.
*/
if (flag_strip_color)
flags.push_back('c');
+ if (flag_no_registered)
+ flags.push_back('r');
if (flags.empty())
flags.push_back('-');
@@ -305,8 +311,12 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters)
bool ModuleFilter::AppliesToMe(User* user, FilterResult* filter, int iflags)
{
+ const AccountExtItem* accountext = GetAccountExtItem();
+
if ((filter->flag_no_opers) && user->IsOper())
return false;
+ if ((filter->flag_no_registered) && accountext && accountext->get(user))
+ return false;
if ((iflags & FLAG_PRIVMSG) && (!filter->flag_privmsg))
return false;
if ((iflags & FLAG_NOTICE) && (!filter->flag_notice))