00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdinc.h"
00026 #include "tools.h"
00027 #include "channel.h"
00028 #include "channel_mode.h"
00029 #include "client.h"
00030 #include "hash.h"
00031 #include "common.h"
00032 #include "irc_string.h"
00033 #include "ircd.h"
00034 #include "list.h"
00035 #include "numeric.h"
00036 #include "s_serv.h"
00037 #include "s_conf.h"
00038 #include "send.h"
00039 #include "handlers.h"
00040 #include "msg.h"
00041 #include "parse.h"
00042 #include "modules.h"
00043
00044
00045 static void ms_lljoin(struct Client *,struct Client *,int,char **);
00046
00047 struct Message lljoin_msgtab = {
00048 "LLJOIN", 0, 0, 3, 0, MFLG_SLOW | MFLG_UNREG, 0L,
00049 {m_unregistered, m_ignore, ms_lljoin, m_ignore, m_ignore, m_ignore}
00050 };
00051 #ifndef STATIC_MODULES
00052
00053 void
00054 _modinit(void)
00055 {
00056 mod_add_cmd(&lljoin_msgtab);
00057 }
00058
00059 void
00060 _moddeinit(void)
00061 {
00062 mod_del_cmd(&lljoin_msgtab);
00063 }
00064
00065 const char *_version = "$Revision: 632 $";
00066 #endif
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 static void
00086 ms_lljoin(struct Client *client_p, struct Client *source_p,
00087 int parc, char *parv[])
00088 {
00089 char *chname = NULL;
00090 char *nick = NULL;
00091 char *key = NULL;
00092 int flags;
00093 int i;
00094 struct Client *target_p;
00095 struct Channel *chptr;
00096
00097 if (uplink && !IsCapable(uplink,CAP_LL))
00098 {
00099 sendto_realops_flags(UMODE_ALL, L_ALL,
00100 "*** LLJOIN requested from non LL server %s",
00101 client_p->name);
00102 return;
00103 }
00104
00105 chname = parv[1];
00106 if(chname == NULL)
00107 return;
00108
00109 nick = parv[2];
00110 if(nick == NULL)
00111 return;
00112
00113 if (parc >3)
00114 key = parv[3];
00115
00116 flags = 0;
00117
00118 target_p = find_person(client_p, nick);
00119
00120 if (!target_p)
00121 return;
00122
00123 if (!MyClient(target_p))
00124 return;
00125
00126 if (!check_channel_name(chname, 0))
00127 {
00128 sendto_realops_flags(UMODE_DEBUG, L_ALL,
00129 "*** Too long or invalid channel name from %s: %s",
00130 target_p->name, chname);
00131 return;
00132 }
00133
00134 chptr = make_channel(chname);
00135 flags = CHFL_CHANOP;
00136
00137 if(!chptr)
00138 return;
00139
00140 if (dlink_list_length(&chptr->members) == 0)
00141 flags = CHFL_CHANOP;
00142 else
00143 flags = 0;
00144
00145
00146
00147
00148
00149 if(chptr)
00150 {
00151 if (IsMember(target_p, chptr))
00152 return;
00153 }
00154 else
00155 {
00156 sendto_one(target_p, form_str(ERR_UNAVAILRESOURCE),
00157 me.name, nick, chptr->chname);
00158 return;
00159 }
00160
00161 if ((i = can_join(target_p, chptr, key)))
00162 {
00163 sendto_one(target_p, form_str(i),
00164 me.name, nick, chptr->chname);
00165 return;
00166 }
00167
00168 if ((dlink_list_length(&target_p->channel) >= ConfigChannel.max_chans_per_user) &&
00169 (!IsOper(target_p) || (dlink_list_length(&target_p->channel) >=
00170 ConfigChannel.max_chans_per_user*3)))
00171 {
00172 sendto_one(target_p, form_str(ERR_TOOMANYCHANNELS),
00173 me.name, nick, chptr->chname );
00174 return;
00175 }
00176
00177 if (flags == CHFL_CHANOP)
00178 {
00179 chptr->channelts = CurrentTime;
00180
00181 sendto_one(uplink,
00182 ":%s SJOIN %lu %s + :@%s",
00183 me.name,
00184 (unsigned long) chptr->channelts,
00185 chptr->chname,
00186 nick);
00187 }
00188
00189 sendto_one(uplink,
00190 ":%s SJOIN %lu %s + :%s",
00191 me.name,
00192 (unsigned long) chptr->channelts,
00193 chptr->chname,
00194 nick);
00195
00196 add_user_to_channel(chptr, target_p, flags, YES);
00197
00198 sendto_channel_local(ALL_MEMBERS, NO, chptr,
00199 ":%s!%s@%s JOIN :%s",
00200 target_p->name,
00201 target_p->username,
00202 target_p->host,
00203 chptr->chname);
00204
00205 if (flags & CHFL_CHANOP)
00206 {
00207 chptr->mode.mode |= MODE_TOPICLIMIT;
00208 chptr->mode.mode |= MODE_NOPRIVMSGS;
00209
00210 sendto_channel_local(ALL_MEMBERS, NO, chptr,
00211 ":%s MODE %s +nt",
00212 me.name, chptr->chname);
00213 sendto_one(uplink,
00214 ":%s MODE %s +nt",
00215 me.name, chptr->chname);
00216 }
00217
00218 channel_member_names(target_p, chptr, 1);
00219 }