* See: http://www.inspircd.org/wiki/index.php/Credits
*
* This program is free but copyrighted software; see
- * the file COPYING for details.
+ * the file COPYING for details.
*
* ---------------------------------------------------
*/
private:
CommandRLine *r;
RLineFactory *f;
+ bool MatchOnNickChange;
+
public:
ModuleRLine(InspIRCd* Me) : Module(Me)
{
+ OnRehash(NULL, "");
+
// Create a new command
r = new CommandRLine(ServerInstance);
ServerInstance->AddCommand(r);
f = new RLineFactory(ServerInstance);
ServerInstance->XLines->RegisterFactory(f);
- Implementation eventlist[] = { I_OnUserConnect };
- ServerInstance->Modules->Attach(eventlist, this, 1);
+ Implementation eventlist[] = { I_OnUserConnect, I_OnRehash, I_OnUserPostNick };
+ ServerInstance->Modules->Attach(eventlist, this, 3);
}
virtual void OnUserConnect(User* user)
{
// Apply lines on user connect
- XLine *r = ServerInstance->XLines->MatchesLine("R", user);
+ XLine *rl = ServerInstance->XLines->MatchesLine("R", user);
- if (r)
+ if (rl)
{
// Bang. :P
- r->Apply(user);
+ rl->Apply(user);
}
}
+
+ virtual void OnRehash(User *user, const std::string ¶meter)
+ {
+ ConfigReader Conf(ServerInstance);
+
+ MatchOnNickChange = Conf.ReadFlag("rline", "matchonnickchange", 1);
+ }
+
+ 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);
+ }
+ }
+
};
MODULE_INIT(ModuleRLine)