]> jfr.im git - irc/quakenet/newserv.git/blame - chanserv/chancmds/devoiceall.c
Merge chanserv-live into default.
[irc/quakenet/newserv.git] / chanserv / chancmds / devoiceall.c
CommitLineData
1dd6d55d 1/* Automatically generated by refactor.pl.
2 *
3 *
4 * CMDNAME: devoiceall
5 * CMDLEVEL: QCMD_AUTHED
6 * CMDARGS: 1
7 * CMDDESC: Devoices all users on a channel.
8 * CMDFUNC: csc_dodevoiceall
9 * CMDPROTO: int csc_dodevoiceall(void *source, int cargc, char **cargv);
1e32d528 10 * CMDHELP: Usage: DEVOICEALL <channel>
11 * CMDHELP: Devoices all users in the channel. Registered voices (+v on CHANLEV) who are
12 * CMDHELP: protected (+p flag set in CHANLEV or CHANFLAGS) will not be devoiced.
13 * CMDHELP: DEVOICEALL requires master (+m) access on the named channel.
1dd6d55d 14 */
15
16#include "../chanserv.h"
17#include "../../nick/nick.h"
18#include "../../lib/flags.h"
19#include "../../lib/irc_string.h"
20#include "../../channel/channel.h"
21#include "../../parser/parser.h"
22#include "../../irc/irc.h"
23#include "../../localuser/localuserchannel.h"
24#include <string.h>
25#include <stdio.h>
26
27int csc_dodevoiceall(void *source, int cargc, char **cargv) {
28 nick *sender=source,*np;
29 reguser *rup;
30 regchanuser *rcup;
31 regchan *rcp;
32 chanindex *cip;
33 unsigned long *lp;
34 int i;
35 modechanges changes;
36
37 if (cargc<1) {
38 chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "devoiceall");
39 return CMD_ERROR;
40 }
41
42 if (!(cip=cs_checkaccess(sender, cargv[0], CA_MASTERPRIV, NULL, "devoiceall",0, 0)))
43 return CMD_ERROR;
44
45 rcp=cip->exts[chanservext];
46
47 if (cip->channel) {
48 localsetmodeinit(&changes, cip->channel, chanservnick);
49
50 for (i=0,lp=cip->channel->users->content;
51 i<cip->channel->users->hashsize;i++,lp++) {
52 if (*lp!=nouser && (*lp & CUMODE_VOICE)) {
53 if (!(np=getnickbynumeric(*lp)) ||
54 (!IsService(np) && (!(rup=getreguserfromnick(np)) ||
55 !(rcup=findreguseronchannel(rcp, rup)) || !(CUHasVoicePriv(rcup)) ||
56 !(CUIsProtect(rcup) || CIsProtect(rcp))))) {
57 localdosetmode_nick(&changes, np, MC_DEVOICE);
58 }
59 }
60 }
61
62 localsetmodeflush(&changes, 1);
63 }
64
65 cs_log(sender,"DEVOICEALL %s",cip->name->content);
66 chanservstdmessage(sender, QM_DONE);
67 return CMD_OK;
68}