+ return Version("RLINE: Regexp user banning.", VF_COMMON | VF_VENDOR, rxfactory ? rxfactory->name : "");
+ }
+
+ ModResult OnUserRegister(LocalUser* user) CXX11_OVERRIDE
+ {
+ // Apply lines on user connect
+ XLine *rl = ServerInstance->XLines->MatchesLine("R", user);
+
+ if (rl)
+ {
+ // Bang. :P
+ rl->Apply(user);
+ return MOD_RES_DENY;
+ }
+ return MOD_RES_PASSTHRU;
+ }
+
+ void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
+ {
+ ConfigTag* tag = ServerInstance->Config->ConfValue("rline");
+
+ MatchOnNickChange = tag->getBool("matchonnickchange");
+ ZlineOnMatch = tag->getBool("zlineonmatch");
+ std::string newrxengine = tag->getString("engine");
+
+ factory = rxfactory ? (rxfactory.operator->()) : NULL;
+
+ if (newrxengine.empty())
+ rxfactory.SetProvider("regex");
+ else
+ rxfactory.SetProvider("regex/" + newrxengine);
+
+ if (!rxfactory)
+ {
+ if (newrxengine.empty())
+ ServerInstance->SNO->WriteToSnoMask('a', "WARNING: No regex engine loaded - R-Line functionality disabled until this is corrected.");
+ else
+ ServerInstance->SNO->WriteToSnoMask('a', "WARNING: Regex engine '%s' is not loaded - R-Line functionality disabled until this is corrected.", newrxengine.c_str());
+
+ ServerInstance->XLines->DelAll(f.GetType());
+ }
+ else if ((!initing) && (rxfactory.operator->() != factory))
+ {
+ ServerInstance->SNO->WriteToSnoMask('a', "Regex engine has changed, removing all R-Lines");
+ ServerInstance->XLines->DelAll(f.GetType());
+ }
+
+ initing = false;
+ }
+
+ ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE
+ {
+ if (stats.GetSymbol() != 'R')
+ return MOD_RES_PASSTHRU;
+
+ ServerInstance->XLines->InvokeStats("R", 223, stats);
+ return MOD_RES_DENY;
+ }
+
+ void OnUserPostNick(User *user, const std::string &oldnick) CXX11_OVERRIDE
+ {
+ if (!IS_LOCAL(user))
+ return;
+
+ if (!MatchOnNickChange)
+ return;
+
+ XLine *rl = ServerInstance->XLines->MatchesLine("R", user);
+
+ if (rl)
+ {
+ // Bang! :D
+ rl->Apply(user);
+ }
+ }
+
+ void OnBackgroundTimer(time_t curtime) CXX11_OVERRIDE
+ {
+ if (added_zline)
+ {
+ added_zline = false;
+ ServerInstance->XLines->ApplyLines();
+ }
+ }
+
+ void OnUnloadModule(Module* mod) CXX11_OVERRIDE
+ {
+ // If the regex engine became unavailable or has changed, remove all rlines
+ if (!rxfactory)
+ {
+ ServerInstance->XLines->DelAll(f.GetType());
+ }
+ else if (rxfactory.operator->() != factory)
+ {
+ factory = rxfactory.operator->();
+ ServerInstance->XLines->DelAll(f.GetType());
+ }
+ }
+
+ void Prioritize()
+ {
+ Module* mod = ServerInstance->Modules->Find("m_cgiirc.so");
+ ServerInstance->Modules->SetPriority(this, I_OnUserRegister, PRIORITY_AFTER, mod);