]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_delaymsg.cpp
m_spanningtree Remove unneeded #includes
[user/henk/code/inspircd.git] / src / modules / m_delaymsg.cpp
index cc09629e358f434385f215104991241caf9e90c4..dd54ea362d8a0c059a80598b53d4a76c1c3b8fbd 100644 (file)
@@ -41,16 +41,18 @@ class DelayMsgMode : public ModeHandler
 
 class ModuleDelayMsg : public Module
 {
- private:
        DelayMsgMode djm;
  public:
        ModuleDelayMsg() : djm(this)
        {
-               if (!ServerInstance->Modes->AddMode(&djm))
-                       throw ModuleException("Could not add new modes!");
-               ServerInstance->Extensions.Register(&djm.jointime);
+       }
+
+       void init()
+       {
+               ServerInstance->Modules->AddService(djm);
+               ServerInstance->Modules->AddService(djm.jointime);
                Implementation eventlist[] = { I_OnUserJoin, I_OnUserPreMessage};
-               ServerInstance->Modules->Attach(eventlist, this, 2);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
        Version GetVersion();
        void OnUserJoin(Membership* memb, bool sync, bool created, CUList&);
@@ -96,7 +98,7 @@ Version ModuleDelayMsg::GetVersion()
 
 void ModuleDelayMsg::OnUserJoin(Membership* memb, bool sync, bool created, CUList&)
 {
-       if (memb->chan->IsModeSet('d'))
+       if ((IS_LOCAL(memb->user)) && (memb->chan->IsModeSet('d')))
        {
                djm.jointime.set(memb, ServerInstance->Time());
        }
@@ -105,7 +107,7 @@ void ModuleDelayMsg::OnUserJoin(Membership* memb, bool sync, bool created, CULis
 ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
 {
        /* Server origin */
-       if (!user)
+       if ((!user) || (!IS_LOCAL(user)))
                return MOD_RES_PASSTHRU;
 
        if (target_type != TYPE_CHANNEL)
@@ -142,4 +144,3 @@ ModResult ModuleDelayMsg::OnUserPreMessage(User* user, void* dest, int target_ty
 }
 
 MODULE_INIT(ModuleDelayMsg)
-