]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_rline.cpp
Remove calls to deprecated InspIRCd::Log(), thanks danieldg for reporting.
[user/henk/code/inspircd.git] / src / modules / extra / m_rline.cpp
index 1b2cad8fde2ffbcbf22c6a7c523403eda353148a..146087ec0cbe111bdd5a4af893db650bf4d9f19e 100644 (file)
@@ -6,7 +6,7 @@
  * 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.
  *
  * ---------------------------------------------------
  */
@@ -91,7 +91,7 @@ class CoreExport RLine : public XLine
 
        void DisplayExpiry()
        {
-               ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed R-Line %s (set by %s %d seconds ago)", this->matchtext.c_str(), this->source, this->duration);
+               ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed R-Line %s (set by %s %ld seconds ago)", this->matchtext.c_str(), this->source, this->duration);
        }
 
        const char* Displayable()
@@ -196,15 +196,23 @@ class ModuleRLine : public Module
  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, I_OnRehash, I_OnUserPostNick };
+               ServerInstance->Modules->Attach(eventlist, this, 3);
+
        }
 
        virtual ~ModuleRLine()
@@ -216,6 +224,43 @@ class ModuleRLine : public Module
        {
                return Version(1,2,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
        }
+
+       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, const std::string &parameter)
+       {
+               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)