- * InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
-static Module* rxengine = 0;
-static Module* mymodule = 0; /* Needed to let RLine send request! */
+static Module* rxengine = NULL;
+static Module* mymodule = NULL; /* Needed to let RLine send request! */
- try {
- regex = RegexFactoryRequest(mymodule, rxengine, regexs).Create();
- } catch (ModuleException& ex) {
- ServerInstance->SNO->WriteToSnoMask('x', "Bad regex: %s", ex.GetReason());
- throw;
- }
+ /* This can throw on failure, but if it does we DONT catch it here, we catch it and display it
+ * where the object is created, we might not ALWAYS want it to output stuff to snomask x all the time
+ */
+ regex = RegexFactoryRequest(mymodule, rxengine, regexs).Create();
- std::string compare = std::string(u->nick) + "!" + u->ident + "@" + u->host + " " + u->fullname;
-
- ServerInstance->Logs->Log("m_rline",DEBUG, "Matching " + matchtext + " against string " + compare);
-
- if (regex->Matches(compare))
- {
- // Bang. :D
- return true;
- }
+ if (u->exempt)
+ return false;
- ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed R-Line %s (set by %s %ld seconds ago)", this->matchtext.c_str(), this->source, this->duration);
+ ServerInstance->SNO->WriteToSnoMask('x',"Removing expired R-Line %s (set by %s %ld seconds ago)", this->matchtext.c_str(), this->source, (long int)(ServerInstance->Time() - this->set_time));
{
return new RLine(ServerInstance, set_time, duration, source, reason, xline_specific_mask);
}
{
return new RLine(ServerInstance, set_time, duration, source, reason, xline_specific_mask);
}
- CommandRLine (InspIRCd* Instance) : Command(Instance,"RLINE", "o", 1)
+ CommandRLine (InspIRCd* Instance) : Command(Instance,"RLINE", "o", 1, 3)
{
r = new RLine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
}
{
r = new RLine(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), parameters[2].c_str(), parameters[0].c_str());
}
- ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent R-Line for %s.", user->nick.c_str(), parameters[0].c_str());
+ ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent R-Line for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
- ServerInstance->SNO->WriteToSnoMask('x', "%s added timed R-Line for %s, expires on %s", user->nick.c_str(), parameters[0].c_str(),
- ServerInstance->TimeString(c_requires_crap).c_str());
+ ServerInstance->SNO->WriteToSnoMask('x', "%s added timed R-Line for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
- // XXX todo implement stats
- user->WriteServ("NOTICE %s :*** R-Line %s not found in list, try /stats g.",user->nick.c_str(),parameters[0].c_str());
+ user->WriteServ("NOTICE %s :*** R-Line %s not found in list, try /stats R.",user->nick.c_str(),parameters[0].c_str());
- // Create a new command
- r = new CommandRLine(ServerInstance);
- ServerInstance->AddCommand(r);
-
- f = new RLineFactory(ServerInstance);
- ServerInstance->XLines->RegisterFactory(f);
+ ServerInstance->AddCommand(&r);
+ ServerInstance->XLines->RegisterFactory(&f);
- Implementation eventlist[] = { I_OnUserConnect, I_OnRehash, I_OnUserPostNick, I_OnLoadModule };
- ServerInstance->Modules->Attach(eventlist, this, 3);
+ Implementation eventlist[] = { I_OnUserConnect, I_OnRehash, I_OnUserPostNick, I_OnLoadModule, I_OnStats };
+ ServerInstance->Modules->Attach(eventlist, this, 5);
{
ServerInstance->Modules->DoneWithInterface("RegularExpression");
ServerInstance->XLines->DelAll("R");
{
ServerInstance->Modules->DoneWithInterface("RegularExpression");
ServerInstance->XLines->DelAll("R");
{
ConfigReader Conf(ServerInstance);
MatchOnNickChange = Conf.ReadFlag("rline", "matchonnickchange", 0);
{
ConfigReader Conf(ServerInstance);
MatchOnNickChange = Conf.ReadFlag("rline", "matchonnickchange", 0);
-
- std::string newrxengine;
-
- newrxengine = Conf.ReadValue("rline", "engine", 0);
+ std::string newrxengine = Conf.ReadValue("rline", "engine", 0);
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");
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");
- ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str());
- rxengine = *i;
+ if (RegexNameRequest(this, *i).Send() == newrxengine)
+ {
+ ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str());
+ rxengine = *i;
+ }
+ 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"))
virtual void OnLoadModule(Module* mod, const std::string& name)
{
if (ServerInstance->Modules->ModuleHasInterface(mod, "RegularExpression"))