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 "client.h"
00031 #include "common.h"
00032 #include "hash.h"
00033 #include "irc_string.h"
00034 #include "ircd.h"
00035 #include "list.h"
00036 #include "numeric.h"
00037 #include "send.h"
00038 #include "s_serv.h"
00039 #include "msg.h"
00040 #include "parse.h"
00041 #include "modules.h"
00042 #include "s_conf.h"
00043 #include "packet.h"
00044
00045 static void m_part(struct Client *, struct Client *, int, char *[]);
00046
00047 struct Message part_msgtab = {
00048 "PART", 0, 0, 2, 0, MFLG_SLOW, 0,
00049 { m_unregistered, m_part, m_part, m_ignore, m_part, m_ignore }
00050 };
00051
00052 #ifndef STATIC_MODULES
00053 void
00054 _modinit(void)
00055 {
00056 mod_add_cmd(&part_msgtab);
00057 }
00058
00059 void
00060 _moddeinit(void)
00061 {
00062 mod_del_cmd(&part_msgtab);
00063 }
00064
00065 const char *_version = "$Revision: 454 $";
00066 #endif
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077 static void
00078 part_one_client(struct Client *client_p, struct Client *source_p,
00079 char *name, char *reason)
00080 {
00081 struct Channel *chptr = NULL;
00082 struct Membership *ms = NULL;
00083
00084 if ((chptr = hash_find_channel(name)) == NULL)
00085 {
00086 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
00087 me.name, source_p->name, name);
00088 return;
00089 }
00090
00091 if ((ms = find_channel_link(source_p, chptr)) == NULL)
00092 {
00093 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
00094 me.name, source_p->name, name);
00095 return;
00096 }
00097
00098 if (MyConnect(source_p) && !IsOper(source_p))
00099 check_spambot_warning(source_p, NULL);
00100
00101
00102
00103
00104
00105 if (reason[0] && (!MyConnect(source_p) ||
00106 ((can_send(chptr, source_p, ms) &&
00107 (source_p->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
00108 < CurrentTime))))
00109 {
00110 sendto_server(client_p, NULL, chptr, CAP_TS6, NOCAPS, NOFLAGS,
00111 ":%s PART %s :%s", ID(source_p), chptr->chname,
00112 reason);
00113 sendto_server(client_p, NULL, chptr, NOCAPS, CAP_TS6, NOFLAGS,
00114 ":%s PART %s :%s", source_p->name, chptr->chname,
00115 reason);
00116 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s PART %s :%s",
00117 source_p->name, source_p->username,
00118 source_p->host, chptr->chname, reason);
00119 }
00120 else
00121 {
00122 sendto_server(client_p, NULL, chptr, CAP_TS6, NOCAPS, NOFLAGS,
00123 ":%s PART %s", ID(source_p), chptr->chname);
00124 sendto_server(client_p, NULL, chptr, NOCAPS, CAP_TS6, NOFLAGS,
00125 ":%s PART %s", source_p->name, chptr->chname);
00126 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s PART %s",
00127 source_p->name, source_p->username,
00128 source_p->host, chptr->chname);
00129 }
00130
00131 remove_user_from_channel(ms);
00132 }
00133
00134
00135
00136
00137
00138
00139
00140 static void
00141 m_part(struct Client *client_p, struct Client *source_p,
00142 int parc, char *parv[])
00143 {
00144 char *p, *name;
00145 char reason[KICKLEN + 1];
00146
00147 if (IsServer(source_p))
00148 return;
00149
00150 if (*parv[1] == '\0')
00151 {
00152 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
00153 me.name, source_p->name, "PART");
00154 return;
00155 }
00156
00157 reason[0] = '\0';
00158
00159 if (parc > 2)
00160 strlcpy(reason, parv[2], sizeof(reason));
00161
00162 name = strtoken(&p, parv[1], ",");
00163
00164
00165 if (MyClient(source_p) && !IsFloodDone(source_p))
00166 flood_endgrace(source_p);
00167
00168 while (name)
00169 {
00170 part_one_client(client_p, source_p, name, reason);
00171 name = strtoken(&p, NULL, ",");
00172 }
00173 }