- if(moduledata.approved != 0)
- {
- sendto_one(source_p, form_str(moduledata.approved),
- me.name, source_p->name, name);
- continue;
- }
-
- if(splitmode && !IsOper(source_p) && (*name != '&') &&
- ConfigChannel.no_create_on_split)
- {
- sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
- me.name, source_p->name, name);
- continue;
- }
-
- flags = CHFL_CHANOP;
- }
-
- if((rb_dlink_list_length(&source_p->user->channel) >=
- (unsigned long) ConfigChannel.max_chans_per_user) &&
- (!IsOper(source_p) ||
- (rb_dlink_list_length(&source_p->user->channel) >=
- (unsigned long) ConfigChannel.max_chans_per_user * 3)))
- {
- sendto_one(source_p, form_str(ERR_TOOMANYCHANNELS),
- me.name, source_p->name, name);
- if(successful_join_count)
- source_p->localClient->last_join_time = rb_current_time();
- return 0;
- }
-
- if(flags == 0) /* if channel doesn't exist, don't penalize */
- successful_join_count++;
-
- if(chptr == NULL) /* If I already have a chptr, no point doing this */
- {
- chptr = get_or_create_channel(source_p, name, NULL);
-
- if(chptr == NULL)
- {
- sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
- me.name, source_p->name, name);
- if(successful_join_count > 0)
- successful_join_count--;
- continue;
- }
- }
-
- if(!IsOper(source_p) && !IsExemptSpambot(source_p))
- check_spambot_warning(source_p, name);
-
- /* can_join checks for +i key, bans etc */
- if((i = can_join(source_p, chptr, key)))
- {
- if ((i != ERR_NEEDREGGEDNICK && i != ERR_THROTTLE && i != ERR_INVITEONLYCHAN && i != ERR_CHANNELISFULL) ||
- (!ConfigChannel.use_forward || (chptr = check_forward(source_p, chptr, key)) == NULL))
- {
- sendto_one(source_p, form_str(i), me.name, source_p->name, name);
- if(successful_join_count > 0)
- successful_join_count--;
- continue;
- }
- sendto_one_numeric(source_p, ERR_LINKCHANNEL, form_str(ERR_LINKCHANNEL), name, chptr->chname);
- }
-
- /* add the user to the channel */
- add_user_to_channel(chptr, source_p, flags);
- if (chptr->mode.join_num &&
- rb_current_time() - chptr->join_delta >= chptr->mode.join_time)
- {
- chptr->join_count = 0;
- chptr->join_delta = rb_current_time();
- }
- chptr->join_count++;
-
- /* we send the user their join here, because we could have to
- * send a mode out next.
- */
- sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
- source_p->name,
- source_p->username, source_p->host, chptr->chname);
-
- /* its a new channel, set +nt and burst. */
- if(flags & CHFL_CHANOP)
- {
- chptr->channelts = rb_current_time();
- chptr->mode.mode |= MODE_TOPICLIMIT;
- chptr->mode.mode |= MODE_NOPRIVMSGS;
-
- sendto_channel_local(ONLY_CHANOPS, chptr, ":%s MODE %s +nt",
- me.name, chptr->chname);
-
- if(*chptr->chname == '#')
- {
- sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
- ":%s SJOIN %ld %s +nt :@%s",
- me.id, (long) chptr->channelts,
- chptr->chname, source_p->id);
- sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
- ":%s SJOIN %ld %s +nt :@%s",
- me.name, (long) chptr->channelts,
- chptr->chname, source_p->name);
- }
- }
- else
- {
- sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
- ":%s JOIN %ld %s +",
- use_id(source_p), (long) chptr->channelts,
- chptr->chname);
-
- sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
- ":%s SJOIN %ld %s + :%s",
- me.name, (long) chptr->channelts,
- chptr->chname, source_p->name);
- }
-
- del_invite(chptr, source_p);
-
- if(chptr->topic != NULL)
- {
- sendto_one(source_p, form_str(RPL_TOPIC), me.name,
- source_p->name, chptr->chname, chptr->topic);
-
- sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
- me.name, source_p->name, chptr->chname,
- chptr->topic_info, chptr->topic_time);
- }