]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * IRC - Internet Relay Chat, contrib/m_clearchan.c | |
3 | * Copyright (C) 2002 Hybrid Development Team | |
4 | * Copyright (C) 2004 ircd-ratbox Development Team | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 1, or (at your option) | |
9 | * any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 | * | |
20 | * $Id: m_clearchan.c 1425 2006-05-23 16:41:33Z jilles $ | |
21 | */ | |
22 | #include "stdinc.h" | |
23 | #include "tools.h" | |
24 | #include "channel.h" | |
25 | #include "client.h" | |
26 | #include "hash.h" | |
27 | #include "irc_string.h" | |
28 | #include "ircd.h" | |
29 | #include "numeric.h" | |
30 | #include "s_user.h" | |
31 | #include "s_conf.h" | |
32 | #include "s_newconf.h" | |
33 | #include "send.h" | |
34 | #include "msg.h" | |
35 | #include "parse.h" | |
36 | #include "modules.h" | |
37 | #include "packet.h" | |
38 | ||
39 | static int mo_clearchan(struct Client *client_p, struct Client *source_p, | |
40 | int parc, const char *parv[]); | |
41 | ||
42 | struct Message clearchan_msgtab = { | |
43 | "CLEARCHAN", 0, 0, 0, MFLG_SLOW, | |
44 | {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_clearchan, 2}} | |
45 | }; | |
46 | ||
47 | mapi_clist_av1 clearchan_clist[] = { &clearchan_msgtab, NULL }; | |
48 | ||
49 | DECLARE_MODULE_AV1(clearchan, NULL, NULL, clearchan_clist, NULL, NULL, "$Revision: 1425 $"); | |
50 | ||
51 | /* | |
52 | ** mo_clearchan | |
53 | ** parv[0] = sender prefix | |
54 | ** parv[1] = channel | |
55 | */ | |
56 | static int | |
57 | mo_clearchan(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) | |
58 | { | |
59 | struct Channel *chptr; | |
60 | struct membership *msptr; | |
61 | struct Client *target_p; | |
62 | dlink_node *ptr; | |
63 | dlink_node *next_ptr; | |
64 | ||
65 | /* admins only */ | |
66 | if(!IsOperAdmin(source_p)) | |
67 | { | |
68 | sendto_one(source_p, ":%s NOTICE %s :You have no A flag", me.name, parv[0]); | |
69 | return 0; | |
70 | } | |
71 | ||
72 | ||
73 | if((chptr = find_channel(parv[1])) == NULL) | |
74 | { | |
75 | sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, | |
76 | form_str(ERR_NOSUCHCHANNEL), parv[1]); | |
77 | return 0; | |
78 | } | |
79 | ||
80 | if(IsMember(source_p, chptr)) | |
81 | { | |
82 | sendto_one(source_p, ":%s NOTICE %s :*** Please part %s before using CLEARCHAN", | |
83 | me.name, source_p->name, parv[1]); | |
84 | return 0; | |
85 | } | |
86 | ||
87 | /* quickly make everyone a peon.. */ | |
88 | DLINK_FOREACH(ptr, chptr->members.head) | |
89 | { | |
90 | msptr = ptr->data; | |
91 | msptr->flags &= ~CHFL_CHANOP | CHFL_VOICE; | |
92 | } | |
93 | ||
94 | sendto_wallops_flags(UMODE_WALLOP, &me, | |
95 | "CLEARCHAN called for [%s] by %s!%s@%s", | |
96 | parv[1], source_p->name, source_p->username, source_p->host); | |
97 | ilog(L_MAIN, "CLEARCHAN called for [%s] by %s!%s@%s", | |
98 | parv[1], source_p->name, source_p->username, source_p->host); | |
99 | ||
100 | if(*chptr->chname != '&') | |
101 | { | |
102 | sendto_server(NULL, NULL, NOCAPS, NOCAPS, | |
103 | ":%s WALLOPS :CLEARCHAN called for [%s] by %s!%s@%s", | |
104 | me.name, parv[1], source_p->name, source_p->username, source_p->host); | |
105 | ||
106 | /* SJOIN the user to give them ops, and lock the channel */ | |
107 | sendto_server(client_p, chptr, NOCAPS, NOCAPS, | |
108 | ":%s SJOIN %ld %s +ntsi :@%s", | |
109 | me.name, (long) (chptr->channelts - 1), | |
110 | chptr->chname, source_p->name); | |
111 | } | |
112 | ||
113 | sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s", | |
114 | source_p->name, source_p->username, source_p->host, chptr->chname); | |
115 | sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s", | |
116 | me.name, chptr->chname, source_p->name); | |
117 | ||
118 | add_user_to_channel(chptr, source_p, CHFL_CHANOP); | |
119 | ||
120 | /* Take the TS down by 1, so we don't see the channel taken over | |
121 | * again. */ | |
122 | if(chptr->channelts) | |
123 | chptr->channelts--; | |
124 | ||
125 | chptr->mode.mode = MODE_SECRET | MODE_TOPICLIMIT | MODE_INVITEONLY | MODE_NOPRIVMSGS; | |
126 | chptr->mode.key[0] = '\0'; | |
127 | ||
128 | DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head) | |
129 | { | |
130 | msptr = ptr->data; | |
131 | target_p = msptr->client_p; | |
132 | ||
133 | /* skip the person we just added.. */ | |
134 | if(is_chanop(msptr)) | |
135 | continue; | |
136 | ||
137 | sendto_channel_local(ALL_MEMBERS, chptr, | |
138 | ":%s KICK %s %s :CLEARCHAN", | |
139 | source_p->name, chptr->chname, target_p->name); | |
140 | ||
141 | if(*chptr->chname != '&') | |
142 | sendto_server(NULL, chptr, NOCAPS, NOCAPS, | |
143 | ":%s KICK %s %s :CLEARCHAN", | |
144 | source_p->name, chptr->chname, target_p->name); | |
145 | ||
146 | remove_user_from_channel(msptr); | |
147 | } | |
148 | ||
149 | /* Join the user themselves to the channel down here, so they dont see a nicklist | |
150 | * or people being kicked */ | |
151 | sendto_one(source_p, ":%s!%s@%s JOIN %s", | |
152 | source_p->name, source_p->username, source_p->host, chptr->chname); | |
153 | ||
154 | channel_member_names(chptr, source_p, 1); | |
155 | ||
156 | return 0; | |
157 | } |