// List of channel names excluded from filtering.
ExemptTargetSet exemptedchans;
+ // List of target nicknames excluded from filtering.
+ ExemptTargetSet exemptednicks;
+
ModuleFilter();
CullResult cull();
ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE;
if (target_type == TYPE_USER)
{
User* t = (User*)dest;
+ // Check if the target nick is exempted, if yes, ignore this message
+ if (exemptednicks.count(t->nick))
+ return MOD_RES_PASSTHRU;
+
target = t->nick;
}
else if (target_type == TYPE_CHANNEL)
ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line)
{
- if (validated && IS_LOCAL(user))
+ if (validated)
{
flags = 0;
bool parting;
{
ConfigTagList tags = ServerInstance->Config->ConfTags("exemptfromfilter");
exemptedchans.clear();
+ exemptednicks.clear();
+
for (ConfigIter i = tags.first; i != tags.second; ++i)
{
- std::string chan = i->second->getString("channel");
- if (!chan.empty())
- exemptedchans.insert(chan);
+ ConfigTag* tag = i->second;
+
+ // If "target" is not found, try the old "channel" key to keep compatibility with 2.0 configs
+ const std::string target = tag->getString("target", tag->getString("channel"));
+ if (!target.empty())
+ {
+ if (target[0] == '#')
+ exemptedchans.insert(target);
+ else
+ exemptednicks.insert(target);
+ }
}
std::string newrxengine = ServerInstance->Config->ConfValue("filteropts")->getString("engine");
{
results.push_back("223 "+user->nick+" :EXEMPT "+(*i));
}
+ for (ExemptTargetSet::const_iterator i = exemptednicks.begin(); i != exemptednicks.end(); ++i)
+ {
+ results.push_back("223 "+user->nick+" :EXEMPT "+(*i));
+ }
}
return MOD_RES_PASSTHRU;
}