19 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
|
* USA |
21 |
|
* |
22 |
< |
* $Id: m_clearchan.c,v 1.58 2005/09/11 15:59:35 michael Exp $ |
22 |
> |
* $Id$ |
23 |
|
*/ |
24 |
|
|
25 |
|
#include "stdinc.h" |
26 |
< |
#include "tools.h" |
27 |
< |
#include "handlers.h" |
26 |
> |
#include "list.h" |
27 |
|
#include "channel.h" |
28 |
|
#include "channel_mode.h" |
29 |
|
#include "client.h" |
35 |
|
#include "irc_string.h" |
36 |
|
#include "sprintf_irc.h" |
37 |
|
#include "hash.h" |
39 |
– |
#include "msg.h" |
38 |
|
#include "parse.h" |
39 |
|
#include "modules.h" |
42 |
– |
#include "list.h" |
40 |
|
#include "s_conf.h" |
41 |
< |
#include "common.h" |
41 |
> |
|
42 |
|
|
43 |
|
static void mo_clearchan(struct Client *, struct Client *, int, char *[]); |
44 |
|
static void kick_list(struct Client *, struct Channel *); |
46 |
|
static void remove_a_mode(struct Channel *, int, char); |
47 |
|
|
48 |
|
struct Message clearchan_msgtab = { |
49 |
< |
"CLEARCHAN", 0, 0, 2, 0, MFLG_SLOW, 0, |
49 |
> |
"CLEARCHAN", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
50 |
|
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_clearchan, m_ignore } |
51 |
|
}; |
52 |
|
|
56 |
– |
#ifndef STATIC_MODULES |
53 |
|
void |
54 |
|
_modinit(void) |
55 |
|
{ |
62 |
|
mod_del_cmd(&clearchan_msgtab); |
63 |
|
} |
64 |
|
|
65 |
< |
const char *_version = "$Revision: 1.58 $"; |
70 |
< |
#endif |
65 |
> |
const char *_version = "$Revision$"; |
66 |
|
|
67 |
|
/* |
68 |
|
** mo_clearchan |
76 |
|
struct Channel *chptr = NULL; |
77 |
|
|
78 |
|
/* admins only */ |
79 |
< |
if (!IsAdmin(source_p)) |
79 |
> |
if (!HasUMode(source_p, UMODE_ADMIN)) |
80 |
|
{ |
81 |
|
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
82 |
|
me.name, source_p->name); |
83 |
|
return; |
84 |
|
} |
85 |
|
|
91 |
– |
/* XXX - we might not have CBURSTed this channel if we are a lazylink |
92 |
– |
* yet. */ |
86 |
|
if ((chptr = hash_find_channel(parv[1])) == NULL) |
87 |
|
{ |
88 |
|
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
99 |
|
|
100 |
|
sendto_wallops_flags(UMODE_WALLOP, &me, "CLEARCHAN called for [%s] by %s!%s@%s", |
101 |
|
chptr->chname, source_p->name, source_p->username, source_p->host); |
102 |
< |
sendto_server(NULL, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT, |
102 |
> |
sendto_server(NULL, NULL, NOCAPS, NOCAPS, |
103 |
|
":%s WALLOPS :CLEARCHAN called for [%s] by %s!%s@%s", |
104 |
|
me.name, chptr->chname, source_p->name, source_p->username, |
105 |
|
source_p->host); |
106 |
|
ilog(L_NOTICE, "CLEARCHAN called for [%s] by %s!%s@%s", |
107 |
|
chptr->chname, source_p->name, source_p->username, source_p->host); |
108 |
|
|
109 |
< |
/* Kill all the modes we have about the channel.. |
109 |
> |
/* |
110 |
> |
* Kill all the modes we have about the channel.. |
111 |
|
* making everyone a peon |
112 |
|
*/ |
113 |
|
remove_our_modes(chptr); |
114 |
|
|
115 |
|
/* SJOIN the user to give them ops, and lock the channel */ |
116 |
< |
sendto_server(client_p, source_p, chptr, CAP_TS6, NOCAPS, LL_ICLIENT, |
116 |
> |
sendto_server(client_p, chptr, CAP_TS6, NOCAPS, |
117 |
|
":%s JOIN %lu %s +ntsi", |
118 |
|
source_p->id, (unsigned long)(chptr->channelts - 1), |
119 |
|
chptr->chname); |
120 |
< |
sendto_server(client_p, source_p, chptr, NOCAPS, CAP_TS6, |
121 |
< |
LL_ICLIENT, ":%s SJOIN %lu %s +ntsi :@%s", |
120 |
> |
sendto_server(client_p, chptr, NOCAPS, CAP_TS6, |
121 |
> |
":%s SJOIN %lu %s +ntsi :@%s", |
122 |
|
me.name, (unsigned long)(chptr->channelts - 1), |
123 |
|
chptr->chname, source_p->name); |
124 |
< |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s!%s@%s JOIN %s", |
124 |
> |
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s JOIN %s", |
125 |
|
source_p->name, source_p->username, |
126 |
|
source_p->host, chptr->chname); |
127 |
< |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s +o %s", |
127 |
> |
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s +o %s", |
128 |
|
me.name, chptr->chname, source_p->name); |
129 |
|
|
130 |
|
|
131 |
< |
/* Take the TS down by 1, so we don't see the channel taken over |
132 |
< |
* again. */ |
131 |
> |
/* |
132 |
> |
* Take the TS down by 1, so we don't see the channel taken over |
133 |
> |
* again. |
134 |
> |
*/ |
135 |
|
if (chptr->channelts) |
136 |
|
--chptr->channelts; |
137 |
|
|
147 |
|
static void |
148 |
|
kick_list(struct Client *source_p, struct Channel *chptr) |
149 |
|
{ |
150 |
< |
dlink_node *m = NULL, *next_m = NULL; |
151 |
< |
|
156 |
< |
add_user_to_channel(chptr, source_p, CHFL_CHANOP, NO); |
150 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
151 |
> |
struct Membership *ms = NULL; |
152 |
|
|
153 |
< |
DLINK_FOREACH_SAFE(m, next_m, chptr->members.head) |
153 |
> |
DLINK_FOREACH(ptr, chptr->members.head) |
154 |
|
{ |
155 |
< |
struct Membership *ms = m->data; |
155 |
> |
ms = ptr->data; |
156 |
|
|
157 |
< |
if (ms->client_p == source_p) |
158 |
< |
continue; |
159 |
< |
|
160 |
< |
/* can reuse m here */ |
161 |
< |
DLINK_FOREACH(m, chptr->locmembers.head) |
167 |
< |
{ |
168 |
< |
if (((struct Membership *)m->data)->client_p == source_p) |
169 |
< |
continue; |
170 |
< |
sendto_one(m->data, ":%s!%s@%s KICK %s %s :CLEARCHAN", |
171 |
< |
source_p->name, source_p->username, |
172 |
< |
source_p->host, |
173 |
< |
chptr->chname, ms->client_p->name); |
174 |
< |
} |
175 |
< |
|
176 |
< |
sendto_server(NULL, source_p, chptr, NOCAPS, NOCAPS, LL_ICLIENT, |
157 |
> |
sendto_channel_local(ALL_MEMBERS, 0, chptr, |
158 |
> |
":%s!%s@%s KICK %s %s CLEARCHAN", |
159 |
> |
source_p->name, source_p->username, |
160 |
> |
source_p->host, chptr->chname, ms->client_p->name); |
161 |
> |
sendto_server(NULL, chptr, NOCAPS, NOCAPS, |
162 |
|
":%s KICK %s %s :CLEARCHAN", source_p->name, |
163 |
|
chptr->chname, ms->client_p->name); |
164 |
< |
remove_user_from_channel(ms); |
164 |
> |
} |
165 |
> |
|
166 |
> |
add_user_to_channel(chptr, source_p, CHFL_CHANOP, 0); |
167 |
> |
|
168 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, chptr->members.head) |
169 |
> |
{ |
170 |
> |
ms = ptr->data; |
171 |
> |
|
172 |
> |
if (ms->client_p != source_p) |
173 |
> |
remove_user_from_channel(ms); |
174 |
|
} |
175 |
|
|
176 |
|
/* |
239 |
|
if (count == 4) |
240 |
|
{ |
241 |
|
*mbuf = '\0'; |
242 |
< |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s %s %s %s %s %s", |
242 |
> |
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s %s %s %s %s %s", |
243 |
|
me.name, chptr->chname, lmodebuf, lpara[0], |
244 |
|
lpara[1], lpara[2], lpara[3]); |
245 |
|
|
253 |
|
if (count != 0) |
254 |
|
{ |
255 |
|
*mbuf = '\0'; |
256 |
< |
sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s MODE %s %s %s %s %s %s", |
256 |
> |
sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s MODE %s %s %s %s %s %s", |
257 |
|
me.name, chptr->chname, lmodebuf, lpara[0], |
258 |
|
lpara[1], lpara[2], lpara[3]); |
259 |
|
} |