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 "handlers.h"
00028 #include "channel.h"
00029 #include "channel_mode.h"
00030 #include "common.h"
00031 #include "client.h"
00032 #include "irc_string.h"
00033 #include "ircd.h"
00034 #include "numeric.h"
00035 #include "send.h"
00036 #include "msg.h"
00037 #include "modules.h"
00038 #include "parse.h"
00039 #include "hash.h"
00040 #include "packet.h"
00041 #include "s_serv.h"
00042
00043
00044 static void m_kick(struct Client *, struct Client *, int, char *[]);
00045
00046 struct Message kick_msgtab = {
00047 "KICK", 0, 0, 3, 0, MFLG_SLOW, 0,
00048 {m_unregistered, m_kick, m_kick, m_ignore, m_kick, m_ignore}
00049 };
00050
00051 #ifndef STATIC_MODULES
00052 void
00053 _modinit(void)
00054 {
00055 mod_add_cmd(&kick_msgtab);
00056 }
00057
00058 void
00059 _moddeinit(void)
00060 {
00061 mod_del_cmd(&kick_msgtab);
00062 }
00063
00064 const char *_version = "$Revision: 33 $";
00065 #endif
00066
00067
00068
00069
00070
00071
00072
00073 static void
00074 m_kick(struct Client *client_p, struct Client *source_p,
00075 int parc, char *parv[])
00076 {
00077 struct Client *who;
00078 struct Channel *chptr;
00079 int chasing = 0;
00080 char *comment;
00081 char *name;
00082 char *p = NULL;
00083 char *user;
00084 const char *from, *to;
00085 struct Membership *ms = NULL;
00086 struct Membership *ms_target;
00087
00088 if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
00089 {
00090 from = me.id;
00091 to = source_p->id;
00092 }
00093 else
00094 {
00095 from = me.name;
00096 to = source_p->name;
00097 }
00098
00099 if (*parv[2] == '\0')
00100 {
00101 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
00102 from, to, "KICK");
00103 return;
00104 }
00105
00106 if (MyClient(source_p) && !IsFloodDone(source_p))
00107 flood_endgrace(source_p);
00108
00109 comment = (EmptyString(parv[3])) ? parv[2] : parv[3];
00110 if (strlen(comment) > (size_t)KICKLEN)
00111 comment[KICKLEN] = '\0';
00112
00113 name = parv[1];
00114 while (*name == ',')
00115 name++;
00116
00117 if ((p = strchr(name,',')) != NULL)
00118 *p = '\0';
00119 if (*name == '\0')
00120 return;
00121
00122 if ((chptr = hash_find_channel(name)) == NULL)
00123 {
00124 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
00125 from, to, name);
00126 return;
00127 }
00128
00129 if (!IsServer(source_p))
00130 {
00131 if ((ms = find_channel_link(source_p, chptr)) == NULL)
00132 {
00133 if (MyConnect(source_p))
00134 {
00135 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
00136 me.name, source_p->name, name);
00137 return;
00138 }
00139 }
00140
00141 if (!has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
00142 {
00143
00144 if (MyConnect(source_p))
00145 {
00146
00147 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
00148 me.name, source_p->name, name);
00149 return;
00150 }
00151
00152 if (chptr->channelts == 0)
00153 {
00154
00155 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
00156 from, to, name);
00157 return;
00158 }
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 }
00181 }
00182
00183 user = parv[2];
00184
00185 while (*user == ',')
00186 user++;
00187
00188 if ((p = strchr(user, ',')) != NULL)
00189 *p = '\0';
00190
00191 if (*user == '\0')
00192 return;
00193
00194 if ((who = find_chasing(client_p, source_p, user, &chasing)) == NULL)
00195 return;
00196
00197 if ((ms_target = find_channel_link(who, chptr)) != NULL)
00198 {
00199 #ifdef HALFOPS
00200
00201 if (has_member_flags(ms, CHFL_HALFOP) && !has_member_flags(ms, CHFL_CHANOP))
00202 {
00203 if (((chptr->mode.mode & MODE_PRIVATE) && has_member_flags(ms_target,
00204 CHFL_CHANOP|CHFL_HALFOP)) || has_member_flags(ms_target, CHFL_CHANOP))
00205 {
00206 sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
00207 me.name, source_p->name, name);
00208 return;
00209 }
00210 }
00211 #endif
00212
00213
00214
00215
00216
00217
00218
00219
00220 if (IsServer(source_p))
00221 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s KICK %s %s :%s",
00222 source_p->name, name, who->name, comment);
00223 else
00224 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s KICK %s %s :%s",
00225 source_p->name, source_p->username,
00226 source_p->host, name, who->name, comment);
00227
00228 sendto_server(client_p, NULL, chptr, CAP_TS6, NOCAPS, NOFLAGS,
00229 ":%s KICK %s %s :%s",
00230 ID(source_p), chptr->chname, ID(who), comment);
00231 sendto_server(client_p, NULL, chptr, NOCAPS, CAP_TS6, NOFLAGS,
00232 ":%s KICK %s %s :%s", source_p->name, chptr->chname,
00233 who->name, comment);
00234
00235 remove_user_from_channel(ms_target);
00236 }
00237 else
00238 sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
00239 from, to, user, name);
00240 }