X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_filter.cpp;h=c0798f7d0353452a9b8a8d89bd6fa37cfcd92386;hb=43e31bba5429849fdebeddc65f7e6f267211181f;hp=49553545ca747c7a662c7e774be1ca0ae540f02d;hpb=e57d1b19ff4823b7885eb7f4d3b37c84d2edca0e;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 49553545c..c0798f7d0 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 { @@ -63,6 +64,7 @@ class FilterResult bool flag_privmsg; bool flag_notice; bool flag_strip_color; + bool flag_no_registered; FilterResult(dynamic_reference& RegexEngine, const std::string& free, const std::string& rea, FilterAction act, unsigned long gt, const std::string& fla, bool cfg) : freeform(free) @@ -80,7 +82,7 @@ class FilterResult char FillFlags(const std::string &fl) { flag_no_opers = flag_part_message = flag_quit_message = flag_privmsg = - flag_notice = flag_strip_color = false; + flag_notice = flag_strip_color = flag_no_registered = 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; @@ -130,12 +135,15 @@ class FilterResult 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. + /* Order is important here, as the logic in FillFlags() stops parsing when it encounters + * an unknown character. So the following characters must be last in the string. + * 'c' is unsupported on < 2.0.10 + * 'r' is unsupported on < 3.2.0 */ if (flag_strip_color) flags.push_back('c'); + if (flag_no_registered) + flags.push_back('r'); if (flags.empty()) flags.push_back('-'); @@ -305,8 +313,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)) @@ -629,7 +641,7 @@ void ModuleFilter::ReadConfig(ConfigStatus& status) Version ModuleFilter::GetVersion() { - return Version("Text (spam) filtering", VF_VENDOR | VF_COMMON, RegexEngine ? RegexEngine->name : ""); + return Version("Provides text (spam) filtering", VF_VENDOR | VF_COMMON, RegexEngine ? RegexEngine->name : ""); } std::string ModuleFilter::EncodeFilter(FilterResult* filter)