+
+ void OnText(User* user, void* dest, int target_type, const std::string &text, char status, CUList &exempt_list)
+ {
+ if (target_type != TYPE_CHANNEL)
+ return;
+
+ Channel* channel = (Channel*) dest;
+
+ if (!user->GetExt(std::string("delayjoin_")+channel->name))
+ return;
+
+ /* Display the join to everyone else (the user who joined got it earlier) */
+ this->WriteCommonFrom(user, channel, "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;
+
+ user->Shrink("delayjoin");
+ }
+
+ void WriteCommonFrom(User *user, Channel* channel, const char* text, ...)
+ {
+ va_list argsPtr;
+ char textbuffer[MAXBUF];
+ char tb[MAXBUF];
+
+ va_start(argsPtr, text);
+ vsnprintf(textbuffer, MAXBUF, text, argsPtr);
+ va_end(argsPtr);
+ snprintf(tb,MAXBUF,":%s %s",user->GetFullHost(),textbuffer);
+
+ CUList *ulist = channel->GetUsers();
+
+ for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ /* 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));
+ }
+ }
+