* +------------------------------------+
*
* InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ * See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
* the file COPYING for details.
* @param regex Pattern to match with
* @
*/
- RLine(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char* regexs) : XLine(Instance, s_time, d, src, re, "R")
+ RLine(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string regexs)
+ : XLine(Instance, s_time, d, src, re, "R")
{
matchtext = regexs;
if (!rxengine)
{
- ServerInstance->SNO->WriteToSnoMask('x', "Cannot create regexes until engine is set to a loaded provider!");
+ ServerInstance->SNO->WriteToSnoMask('a', "Cannot create regexes until engine is set to a loaded provider!");
throw ModuleException("Regex engine not set or loaded!");
}
bool Matches(User *u)
{
+ if (u->exempt)
+ return false;
+
std::string compare = u->nick + "!" + u->ident + "@" + u->host + " " + u->fullname;
return regex->Matches(compare);
}
void DisplayExpiry()
{
- 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));
+ ServerInstance->SNO->WriteToSnoMask('x',"Removing expired R-line %s (set by %s %ld seconds ago)",
+ this->matchtext.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time));
}
const char* Displayable()
/** Generate a RLine
*/
- XLine* Generate(time_t set_time, long duration, const char* source, const char* reason, const char* xline_specific_mask)
+ XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask)
{
return new RLine(ServerInstance, set_time, duration, source, reason, xline_specific_mask);
}
std::string rxengine;
public:
- CommandRLine (InspIRCd* Instance) : Command(Instance,"RLINE", "o", 1, 3)
+ CommandRLine(Module* Creator) : Command(Creator,"RLINE", 1, 3)
{
- this->source = "m_rline.so";
- this->syntax = "<regex> [<rline-duration>] :<reason>";
+ flags_needed = 'o'; this->syntax = "<regex> [<rline-duration>] :<reason>";
}
CmdResult Handle (const std::vector<std::string>& parameters, User *user)
}
catch (ModuleException &e)
{
- ServerInstance->SNO->WriteToSnoMask('x',"Could not add RLINE: %s", e.GetReason());
+ ServerInstance->SNO->WriteToSnoMask('a',"Could not add RLINE: %s", e.GetReason());
}
if (r)
{
if (!duration)
{
- 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 permanent R-line for %s: %s", user->nick.c_str(), parameters[0].c_str(), parameters[2].c_str());
}
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
- 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());
+ ServerInstance->SNO->WriteToSnoMask('x', "%s added timed R-line for %s to expire on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
}
ServerInstance->XLines->ApplyLines();
{
if (ServerInstance->XLines->DelLine(parameters[0].c_str(), "R", user))
{
- ServerInstance->SNO->WriteToSnoMask('x',"%s Removed R-Line on %s.",user->nick.c_str(),parameters[0].c_str());
+ ServerInstance->SNO->WriteToSnoMask('x',"%s removed R-line on %s",user->nick.c_str(),parameters[0].c_str());
}
else
{
return CMD_SUCCESS;
}
+
+ RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+ {
+ return ROUTE_BROADCAST;
+ }
};
class ModuleRLine : public Module
{
private:
- CommandRLine *r;
- RLineFactory *f;
+ CommandRLine r;
+ RLineFactory f;
bool MatchOnNickChange;
std::string RegexEngine;
public:
- ModuleRLine(InspIRCd* Me) : Module(Me)
+ ModuleRLine(InspIRCd* Me) : Module(Me), r(this), f(Me)
{
mymodule = this;
- OnRehash(NULL, "");
+ OnRehash(NULL);
Me->Modules->UseInterface("RegularExpression");
- // 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, I_OnStats };
ServerInstance->Modules->Attach(eventlist, this, 5);
{
ServerInstance->Modules->DoneWithInterface("RegularExpression");
ServerInstance->XLines->DelAll("R");
- ServerInstance->XLines->UnregisterFactory(f);
+ ServerInstance->XLines->UnregisterFactory(&f);
}
virtual Version GetVersion()
}
}
- virtual void OnRehash(User *user, const std::string ¶meter)
+ virtual void OnRehash(User *user)
{
ConfigReader Conf(ServerInstance);
{
if (RegexNameRequest(this, *i).Send() == newrxengine)
{
- ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str());
+ ServerInstance->SNO->WriteToSnoMask('a', "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());
+ ServerInstance->SNO->WriteToSnoMask('a', "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)
+ virtual ModResult OnStats(char symbol, User* user, string_list &results)
{
if (symbol != 'R')
- return 0;
+ return MOD_RES_PASSTHRU;
ServerInstance->XLines->InvokeStats("R", 223, user, results);
- return 1;
+ return MOD_RES_DENY;
}
virtual void OnLoadModule(Module* mod, const std::string& name)
std::string rxname = RegexNameRequest(this, mod).Send();
if (rxname == RegexEngine)
{
- ServerInstance->SNO->WriteToSnoMask('x', "R-Line now using engine '%s'", RegexEngine.c_str());
+ ServerInstance->SNO->WriteToSnoMask('a', "R-Line now using engine '%s'", RegexEngine.c_str());
rxengine = mod;
}
}