diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-10-26 20:03:06 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-10-26 20:03:06 +0000 |
commit | 371030bca712400eaca6c92b92d07d11a0c83dbb (patch) | |
tree | c4ed55cfbd450aec3b3acae5e152b2320b6ede52 /src/modules | |
parent | 7a2a85535c14a66c2dd7e1c2c281bfe6fcbaf7ad (diff) |
Might work might not. dont know yet
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8372 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_delayjoin.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index 6a0481465..8a596d5dc 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -47,7 +47,6 @@ class ModuleDelayJoin : public Module private: DelayJoinMode* djm; CUList nl; - CUList except_list; public: ModuleDelayJoin(InspIRCd* Me) : Module(Me) @@ -82,8 +81,12 @@ class ModuleDelayJoin : public Module virtual int OnUserList(User* user, Channel* Ptr, CUList* &nameslist) { + /* For +D channels ... */ if (Ptr->IsModeSet('D')) { + /* Modify the names list, erasing users with the delay join metadata + * for this channel (havent spoken yet) + */ nl = *nameslist; for (CUListIter n = nameslist->begin(); n != nameslist->end(); ++n) @@ -105,8 +108,15 @@ class ModuleDelayJoin : public Module silent = true; /* Because we silenced the event, make sure it reaches the user whos joining (but only them of course) */ user->WriteFrom(user, "JOIN %s", channel->name); + + /* This metadata tells the module the user is delayed join on this specific channel */ user->Extend(std::string("delayjoin_")+channel->name); - user->Extend("delayjoin"); + + /* This metadata tells the module the user is delayed join on at least one (or more) channels. + * It is only cleared when the user is no longer on ANY +D channels. + */ + if (!user->GetExt("delayjoin")) + user->Extend("delayjoin"); } } @@ -157,6 +167,39 @@ class ModuleDelayJoin : public Module } } } + + int OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) + { + if (target_type != TYPE_CHANNEL) + return 0; + + Channel* channel = (Channel*) dest; + + if (!user->GetExt(std::string("delayjoin_")+channel->name)) + return 0; + + /* Display the join to everyone else (the user who joined got it earlier) */ + channel->WriteAllExcept(user, false, 0, exempt_list, "JOIN %s", channel->name); + + /* Shrink off the neccessary metadata for a specific channel */ + user->Shrink(std::string("delayjoin_")+channel->name); + + /* Check if the user is left on any other +D channels, if so don't take away the + * metadata that says theyre on one or more channels + */ + for (UCListIter f = user->chans.begin(); f != user->chans.end(); f++) + if (f->first->IsModeSet('D')) + return 0; + + user->Shrink("delayjoin"); + + return 0; + } + + int OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) + { + return OnUserPreMessage(user, dest, target_type, text, status, exempt_list); + } }; MODULE_INIT(ModuleDelayJoin) |