2 * IRC - Internet Relay Chat, contrib/m_clearchan.c
3 * Copyright (C) 2002 Hybrid Development Team
4 * Copyright (C) 2004 ircd-ratbox Development Team
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)
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.
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.
20 * $Id: m_clearchan.c 3161 2007-01-25 07:23:01Z nenolod $
31 #include "s_newconf.h"
38 static int mo_clearchan(struct Client
*client_p
, struct Client
*source_p
,
39 int parc
, const char *parv
[]);
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}}
46 mapi_clist_av1 clearchan_clist
[] = { &clearchan_msgtab
, NULL
};
48 DECLARE_MODULE_AV1(clearchan
, NULL
, NULL
, clearchan_clist
, NULL
, NULL
, "$Revision: 3161 $");
52 ** parv[0] = sender prefix
56 mo_clearchan(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
58 struct Channel
*chptr
;
59 struct membership
*msptr
;
60 struct Client
*target_p
;
62 rb_dlink_node
*next_ptr
;
65 if(!IsOperAdmin(source_p
))
67 sendto_one_notice(source_p
, ":You have no A flag");
72 if((chptr
= find_channel(parv
[1])) == NULL
)
74 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
75 form_str(ERR_NOSUCHCHANNEL
), parv
[1]);
79 if(IsMember(source_p
, chptr
))
81 sendto_one_notice(source_p
, ":*** Please part %s before using CLEARCHAN", parv
[1]);
85 /* quickly make everyone a peon.. */
86 RB_DLINK_FOREACH(ptr
, chptr
->members
.head
)
89 msptr
->flags
&= ~CHFL_CHANOP
| CHFL_VOICE
;
92 sendto_wallops_flags(UMODE_WALLOP
, &me
,
93 "CLEARCHAN called for [%s] by %s!%s@%s",
94 parv
[1], source_p
->name
, source_p
->username
, source_p
->host
);
95 ilog(L_MAIN
, "CLEARCHAN called for [%s] by %s!%s@%s",
96 parv
[1], source_p
->name
, source_p
->username
, source_p
->host
);
98 if(*chptr
->chname
!= '&')
100 sendto_server(NULL
, NULL
, NOCAPS
, NOCAPS
,
101 ":%s WALLOPS :CLEARCHAN called for [%s] by %s!%s@%s",
102 me
.name
, parv
[1], source_p
->name
, source_p
->username
, source_p
->host
);
104 /* SJOIN the user to give them ops, and lock the channel */
105 sendto_server(client_p
, chptr
, NOCAPS
, NOCAPS
,
106 ":%s SJOIN %ld %s +ntsi :@%s",
107 me
.name
, (long) (chptr
->channelts
- 1),
108 chptr
->chname
, source_p
->name
);
111 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s!%s@%s JOIN %s",
112 source_p
->name
, source_p
->username
, source_p
->host
, chptr
->chname
);
113 sendto_channel_local(ALL_MEMBERS
, chptr
, ":%s MODE %s +o %s",
114 me
.name
, chptr
->chname
, source_p
->name
);
116 add_user_to_channel(chptr
, source_p
, CHFL_CHANOP
);
118 /* Take the TS down by 1, so we don't see the channel taken over
123 chptr
->mode
.mode
= MODE_SECRET
| MODE_TOPICLIMIT
| MODE_INVITEONLY
| MODE_NOPRIVMSGS
;
124 chptr
->mode
.key
[0] = '\0';
126 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, chptr
->members
.head
)
129 target_p
= msptr
->client_p
;
131 /* skip the person we just added.. */
135 sendto_channel_local(ALL_MEMBERS
, chptr
,
136 ":%s KICK %s %s :CLEARCHAN",
137 source_p
->name
, chptr
->chname
, target_p
->name
);
139 if(*chptr
->chname
!= '&')
140 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
141 ":%s KICK %s %s :CLEARCHAN",
142 source_p
->name
, chptr
->chname
, target_p
->name
);
144 remove_user_from_channel(msptr
);
147 /* Join the user themselves to the channel down here, so they dont see a nicklist
148 * or people being kicked */
149 sendto_one(source_p
, ":%s!%s@%s JOIN %s",
150 source_p
->name
, source_p
->username
, source_p
->host
, chptr
->chname
);
152 channel_member_names(chptr
, source_p
, 1);