+
+ virtual void OnUserConnect(User* user)
+ {
+ // Apply lines on user connect
+ XLine *rl = ServerInstance->XLines->MatchesLine("R", user);
+
+ if (rl)
+ {
+ // Bang. :P
+ rl->Apply(user);
+ }
+ }
+
+ virtual void OnRehash(User *user)
+ {
+ ConfigReader Conf(ServerInstance);
+
+ MatchOnNickChange = Conf.ReadFlag("rline", "matchonnickchange", 0);
+ std::string newrxengine = Conf.ReadValue("rline", "engine", 0);
+
+ if (!RegexEngine.empty())
+ {
+ if (RegexEngine == newrxengine)
+ return;
+
+ ServerInstance->SNO->WriteToSnoMask('x', "Dumping all R-Lines due to regex engine change (was '%s', now '%s')", RegexEngine.c_str(), newrxengine.c_str());
+ ServerInstance->XLines->DelAll("R");
+ }
+ rxengine = 0;
+ RegexEngine = newrxengine;
+ modulelist* ml = ServerInstance->Modules->FindInterface("RegularExpression");
+ if (ml)
+ {
+ for (modulelist::iterator i = ml->begin(); i != ml->end(); ++i)
+ {
+ if (RegexNameRequest(this, *i).Send() == newrxengine)
+ {
+ ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str());
+ rxengine = *i;
+ }
+ }
+ }
+ if (!rxengine)
+ {
+ ServerInstance->SNO->WriteToSnoMask('x', "WARNING: Regex engine '%s' is not loaded - R-Line functionality disabled until this is corrected.", RegexEngine.c_str());
+ }
+ }
+
+ virtual int OnStats(char symbol, User* user, string_list &results)
+ {
+ if (symbol != 'R')
+ return 0;
+
+ ServerInstance->XLines->InvokeStats("R", 223, user, results);
+ return 1;
+ }
+
+ virtual void OnLoadModule(Module* mod, const std::string& name)
+ {
+ if (ServerInstance->Modules->ModuleHasInterface(mod, "RegularExpression"))
+ {
+ std::string rxname = RegexNameRequest(this, mod).Send();
+ if (rxname == RegexEngine)
+ {
+ ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str());
+ rxengine = mod;
+ }
+ }
+ }
+
+ virtual void OnUserPostNick(User *user, const std::string &oldnick)
+ {
+ if (!IS_LOCAL(user))
+ return;
+
+ if (!MatchOnNickChange)
+ return;
+
+ XLine *rl = ServerInstance->XLines->MatchesLine("R", user);
+
+ if (rl)
+ {
+ // Bang! :D
+ rl->Apply(user);
+ }
+ }
+