]> jfr.im git - irc/rqf/shadowircd.git/blob - unsupported/m_clearchan.c
Add description for LOCOPS message.
[irc/rqf/shadowircd.git] / unsupported / m_clearchan.c
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 3161 2007-01-25 07:23:01Z nenolod $
21 */
22 #include "stdinc.h"
23 #include "channel.h"
24 #include "client.h"
25 #include "hash.h"
26 #include "match.h"
27 #include "ircd.h"
28 #include "numeric.h"
29 #include "s_user.h"
30 #include "s_conf.h"
31 #include "s_newconf.h"
32 #include "send.h"
33 #include "msg.h"
34 #include "parse.h"
35 #include "modules.h"
36 #include "packet.h"
37
38 static int mo_clearchan(struct Client *client_p, struct Client *source_p,
39 int parc, const char *parv[]);
40
41 struct Message clearchan_msgtab = {
42 "CLEARCHAN", 0, 0, 0, MFLG_SLOW,
43 {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_clearchan, 2}}
44 };
45
46 mapi_clist_av1 clearchan_clist[] = { &clearchan_msgtab, NULL };
47
48 DECLARE_MODULE_AV1(clearchan, NULL, NULL, clearchan_clist, NULL, NULL, "$Revision: 3161 $");
49
50 /*
51 ** mo_clearchan
52 ** parv[1] = channel
53 */
54 static int
55 mo_clearchan(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
56 {
57 struct Channel *chptr;
58 struct membership *msptr;
59 struct Client *target_p;
60 rb_dlink_node *ptr;
61 rb_dlink_node *next_ptr;
62
63 /* admins only */
64 if(!IsOperAdmin(source_p))
65 {
66 sendto_one_notice(source_p, ":You have no A flag");
67 return 0;
68 }
69
70
71 if((chptr = find_channel(parv[1])) == NULL)
72 {
73 sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
74 form_str(ERR_NOSUCHCHANNEL), parv[1]);
75 return 0;
76 }
77
78 if(IsMember(source_p, chptr))
79 {
80 sendto_one_notice(source_p, ":*** Please part %s before using CLEARCHAN", parv[1]);
81 return 0;
82 }
83
84 /* quickly make everyone a peon.. */
85 RB_DLINK_FOREACH(ptr, chptr->members.head)
86 {
87 msptr = ptr->data;
88 msptr->flags &= ~CHFL_CHANOP | CHFL_VOICE;
89 }
90
91 sendto_wallops_flags(UMODE_WALLOP, &me,
92 "CLEARCHAN called for [%s] by %s!%s@%s",
93 parv[1], source_p->name, source_p->username, source_p->host);
94 ilog(L_MAIN, "CLEARCHAN called for [%s] by %s!%s@%s",
95 parv[1], source_p->name, source_p->username, source_p->host);
96
97 if(*chptr->chname != '&')
98 {
99 sendto_server(NULL, NULL, NOCAPS, NOCAPS,
100 ":%s WALLOPS :CLEARCHAN called for [%s] by %s!%s@%s",
101 me.name, parv[1], source_p->name, source_p->username, source_p->host);
102
103 /* SJOIN the user to give them ops, and lock the channel */
104 sendto_server(client_p, chptr, NOCAPS, NOCAPS,
105 ":%s SJOIN %ld %s +ntsi :@%s",
106 me.name, (long) (chptr->channelts - 1),
107 chptr->chname, source_p->name);
108 }
109
110 sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
111 source_p->name, source_p->username, source_p->host, chptr->chname);
112 sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
113 me.name, chptr->chname, source_p->name);
114
115 add_user_to_channel(chptr, source_p, CHFL_CHANOP);
116
117 /* Take the TS down by 1, so we don't see the channel taken over
118 * again. */
119 if(chptr->channelts)
120 chptr->channelts--;
121
122 chptr->mode.mode = MODE_SECRET | MODE_TOPICLIMIT | MODE_INVITEONLY | MODE_NOPRIVMSGS;
123 chptr->mode.key[0] = '\0';
124
125 RB_DLINK_FOREACH_SAFE(ptr, next_ptr, chptr->members.head)
126 {
127 msptr = ptr->data;
128 target_p = msptr->client_p;
129
130 /* skip the person we just added.. */
131 if(is_chanop(msptr))
132 continue;
133
134 sendto_channel_local(ALL_MEMBERS, chptr,
135 ":%s KICK %s %s :CLEARCHAN",
136 source_p->name, chptr->chname, target_p->name);
137
138 if(*chptr->chname != '&')
139 sendto_server(NULL, chptr, NOCAPS, NOCAPS,
140 ":%s KICK %s %s :CLEARCHAN",
141 source_p->name, chptr->chname, target_p->name);
142
143 remove_user_from_channel(msptr);
144 }
145
146 /* Join the user themselves to the channel down here, so they dont see a nicklist
147 * or people being kicked */
148 sendto_one(source_p, ":%s!%s@%s JOIN %s",
149 source_p->name, source_p->username, source_p->host, chptr->chname);
150
151 channel_member_names(chptr, source_p, 1);
152
153 return 0;
154 }