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