]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_delayjoin.cpp
Fix m_chanlog crashing.
[user/henk/code/inspircd.git] / src / modules / m_delayjoin.cpp
index ff6f7966fe0840c0dd145e8096c78c97f88b4269..1077e65a720e293d0915f5675c729b60a117fdfc 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -65,20 +65,23 @@ class ModuleDelayJoin : public Module
                : Module(Me)
        {
                djm = new DelayJoinMode(ServerInstance, this);
-               if (!ServerInstance->AddMode(djm))
+               if (!ServerInstance->Modes->AddMode(djm))
                        throw ModuleException("Could not add new modes!");
+               Implementation eventlist[] = { I_OnUserJoin, I_OnUserPart, I_OnUserKick, I_OnUserQuit, I_OnUserList, I_OnText };
+               ServerInstance->Modules->Attach(eventlist, this, 6);
        }
        
        virtual ~ModuleDelayJoin()
        {
                ServerInstance->Modes->DelMode(djm);
-               DELETE(djm);
+               delete djm;
        }
 
-       Priority Prioritize()
+       void Prioritize()
        {
-               /* To ensure that we get priority over namesx for names list generation on +u channels */
-               return (Priority)ServerInstance->Modules->PriorityBefore("m_namesx.so");
+               /* To ensure that we get priority over namesx for names list generation */
+               Module* namesx = ServerInstance->Modules->Find("m_namesx.so");
+               ServerInstance->Modules->SetPriority(this, I_OnUserList, PRIO_BEFORE, &namesx);
        }
 
        virtual Version GetVersion()
@@ -86,10 +89,6 @@ class ModuleDelayJoin : public Module
                return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
        }
 
-       void Implements(char* List)
-       {
-               List[I_OnUserJoin] = List[I_OnUserPart] = List[I_OnUserKick] = List[I_OnUserQuit] = List[I_OnUserList] = List[I_OnText] = 1;
-       }
 
        virtual int OnUserList(User* user, Channel* Ptr, CUList* &nameslist)
        {
@@ -119,7 +118,7 @@ class ModuleDelayJoin : public Module
                return 0;
        }
 
-       virtual void OnUserJoin(User* user, Channel* channel, bool &silent)
+       virtual void OnUserJoin(User* user, Channel* channel, bool sync, bool &silent)
        {
                if (channel->IsModeSet('D'))
                {
@@ -192,6 +191,10 @@ class ModuleDelayJoin : public Module
                /* Display the join to everyone else (the user who joined got it earlier) */
                this->WriteCommonFrom(user, channel, "JOIN %s", channel->name);
 
+               std::string n = this->ServerInstance->Modes->ModeString(user, channel);
+               if (n.length() > 0)
+                       this->WriteCommonFrom(user, channel, "MODE %s +%s", channel->name, n.c_str());
+
                /* Shrink off the neccessary metadata for a specific channel */
                user->Shrink(std::string("delayjoin_")+channel->name);
 
@@ -220,11 +223,15 @@ class ModuleDelayJoin : public Module
 
                for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
                {
-                       /* User only appears to vanish for non-opers */
-                       if (user->Visibility && user->Visibility->VisibleTo(i->first))
-                       {
-                               i->first->Write(std::string(tb));
-                       }
+                       /* User doesnt get a JOIN sent to themselves */
+                       if (user == i->first)
+                               continue;
+
+                       /* Users with a visibility state that hides them dont appear */
+                       if (user->Visibility && !user->Visibility->VisibleTo(i->first))
+                               continue;
+
+                       i->first->Write(std::string(tb));
                }
        }