/[svn]/ircd-hybrid/modules/core/m_part.c
ViewVC logotype

Contents of /ircd-hybrid/modules/core/m_part.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1028 - (show annotations)
Sun Nov 8 13:03:38 2009 UTC (11 years, 5 months ago) by michael
File MIME type: text/x-chdr
File size: 4610 byte(s)
- move ircd-hybrid-7.2 to trunk

1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_part.c: Parts a user from a channel.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "list.h"
27 #include "handlers.h"
28 #include "channel.h"
29 #include "channel_mode.h"
30 #include "client.h"
31 #include "common.h"
32 #include "hash.h"
33 #include "irc_string.h"
34 #include "ircd.h"
35 #include "numeric.h"
36 #include "send.h"
37 #include "s_serv.h"
38 #include "msg.h"
39 #include "parse.h"
40 #include "modules.h"
41 #include "s_conf.h"
42 #include "packet.h"
43
44 static void m_part(struct Client *, struct Client *, int, char *[]);
45
46 struct Message part_msgtab = {
47 "PART", 0, 0, 2, 0, MFLG_SLOW, 0,
48 { m_unregistered, m_part, m_part, m_ignore, m_part, m_ignore }
49 };
50
51 #ifndef STATIC_MODULES
52 void
53 _modinit(void)
54 {
55 mod_add_cmd(&part_msgtab);
56 }
57
58 void
59 _moddeinit(void)
60 {
61 mod_del_cmd(&part_msgtab);
62 }
63
64 const char *_version = "$Revision$";
65 #endif
66
67
68 /* part_one_client()
69 *
70 * inputs - pointer to server
71 * - pointer to source client to remove
72 * - char pointer of name of channel to remove from
73 * output - none
74 * side effects - remove ONE client given the channel name
75 */
76 static void
77 part_one_client(struct Client *client_p, struct Client *source_p,
78 const char *name, const char *reason)
79 {
80 struct Channel *chptr = NULL;
81 struct Membership *ms = NULL;
82
83 if ((chptr = hash_find_channel(name)) == NULL)
84 {
85 sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
86 me.name, source_p->name, name);
87 return;
88 }
89
90 if ((ms = find_channel_link(source_p, chptr)) == NULL)
91 {
92 sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
93 me.name, source_p->name, name);
94 return;
95 }
96
97 if (MyConnect(source_p) && !IsOper(source_p))
98 check_spambot_warning(source_p, NULL);
99
100 /*
101 * Remove user from the old channel (if any)
102 * only allow /part reasons in -m chans
103 */
104 if (reason[0] && (!MyConnect(source_p) ||
105 ((can_send(chptr, source_p, ms) &&
106 (source_p->firsttime + ConfigFileEntry.anti_spam_exit_message_time)
107 < CurrentTime))))
108 {
109 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
110 ":%s PART %s :%s", ID(source_p), chptr->chname,
111 reason);
112 sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
113 ":%s PART %s :%s", source_p->name, chptr->chname,
114 reason);
115 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s PART %s :%s",
116 source_p->name, source_p->username,
117 source_p->host, chptr->chname, reason);
118 }
119 else
120 {
121 sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
122 ":%s PART %s", ID(source_p), chptr->chname);
123 sendto_server(client_p, chptr, NOCAPS, CAP_TS6,
124 ":%s PART %s", source_p->name, chptr->chname);
125 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s PART %s",
126 source_p->name, source_p->username,
127 source_p->host, chptr->chname);
128 }
129
130 remove_user_from_channel(ms);
131 }
132
133 /*
134 ** m_part
135 ** parv[0] = sender prefix
136 ** parv[1] = channel
137 ** parv[2] = reason
138 */
139 static void
140 m_part(struct Client *client_p, struct Client *source_p,
141 int parc, char *parv[])
142 {
143 char *p = NULL, *name = NULL;
144 char reason[KICKLEN + 1] = { '\0' };
145
146 if (IsServer(source_p))
147 return;
148
149 if (EmptyString(parv[1]))
150 {
151 sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
152 me.name, source_p->name, "PART");
153 return;
154 }
155
156 if (parc > 2)
157 strlcpy(reason, parv[2], sizeof(reason));
158
159 /* Finish the flood grace period... */
160 if (MyClient(source_p) && !IsFloodDone(source_p))
161 flood_endgrace(source_p);
162
163 for (name = strtoken(&p, parv[1], ","); name;
164 name = strtoken(&p, NULL, ","))
165 part_one_client(client_p, source_p, name, reason);
166 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28