]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/chanflags.c
1 /* Automatically generated by refactor.pl.
5 * CMDLEVEL: QCMD_AUTHED
7 * CMDDESC: Shows or changes the flags on a channel.
8 * CMDFUNC: csc_dochanflags
9 * CMDPROTO: int csc_dochanflags(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: CHANFLAGS <channel> [<changes>]
11 * CMDHELP: Shows or changes the status of channel flags, where:
12 * CMDHELP: channel - channel to use
13 * CMDHELP: changes - changes to apply to the channel flags in the usual +/- format, e.g. +c
14 * CMDHELP: to set +c and -c to remove it.
15 * CMDHELP: Viewing the current flags requires operator (+o) access on the named channel.
16 * CMDHELP: Changing the flags requires master (+m) access on the named channel.
17 * CMDHELP: Valid channel flags are:
18 * CMDHELP: +a AUTOOP Automatically ops any user who has op access when they join the
19 * CMDHELP: channel. Same effect as giving all ops the +a chanlev flag.
20 * CMDHELP: +b BITCH Prevents users who don't have operator access on the channel
21 * CMDHELP: from being opped (automatically deops them)
22 * CMDHELP: +c AUTOLIMIT Enables automatic limit feature - updates the channel limit at
23 * CMDHELP: regular intervals to keep a certain number of free spaces. This
24 * CMDHELP: can mitigate the effect of join floods. See AUTOLIMIT.
25 * CMDHELP: +e ENFORCE Enforces bans on the channel. Any user who is banned will be
26 * CMDHELP: kicked automatically.
27 * CMDHELP: +f FORCETOPIC Prevents channel ops from changing the topic. The SETTOPIC
28 * CMDHELP: command must be used instead.
29 * CMDHELP: +g AUTOVOICE Automatically voices any user who has voice access when they join
30 * CMDHELP: the channel. Same effect as giving all voices the +g chanlev flag.
31 * CMDHELP: +j JOINED Causes Q to remain on the channel. Cannot be removed.
32 * CMDHELP: +k KNOWNONLY Any user who joins the channel who is not known (+k) will be kicked.
33 * CMDHELP: Unless channel mode +i is set they will be banned as well.
34 * CMDHELP: +p PROTECT Any user with voice (+v) or operator (+o) access will have that
35 * CMDHELP: status enforced on the channel at all times. Same effect as giving
36 * CMDHELP: all ops and voices the +p chanlev flag.
37 * CMDHELP: +t TOPICSAVE Saves the topic when it changes. Such saved topics can be restored
38 * CMDHELP: via settopic, or when the bot rejoins when a channel has been left
40 * CMDHELP: +v VOICEALL Automatically grants voice (+v) on the channel to any user who enters,
41 * CMDHELP: unless they have quiet (+q) chanlev flag.
42 * CMDHELP: +w WELCOME Sends the welcome message to users joining the channel. See WELCOME.
43 * CMDHELP: Note: Previous versions of Q included the facility to enforce limits and keys using
44 * CMDHELP: +k and +l chanflags. This functionality is now available via the CHANMODE command.
47 #include "../chanserv.h"
48 #include "../../nick/nick.h"
49 #include "../../lib/flags.h"
50 #include "../../lib/irc_string.h"
51 #include "../../channel/channel.h"
52 #include "../../parser/parser.h"
53 #include "../../irc/irc.h"
54 #include "../../localuser/localuserchannel.h"
58 int csc_dochanflags(void *source
, int cargc
, char **cargv
) {
61 reguser
*rup
=getreguserfromnick(sender
);
63 flag_t oldflags
,changemask
;
67 chanservstdmessage(sender
,QM_NOTENOUGHPARAMS
,"chanflags");
71 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_OPPRIV
, NULL
,
72 "chanflags", QPRIV_VIEWCHANFLAGS
, 0)))
75 rcp
=cip
->exts
[chanservext
];
78 if (!cs_checkaccess(sender
, NULL
, CA_MASTERPRIV
, cip
, "chanflags",
79 QPRIV_CHANGECHANFLAGS
, 0))
83 changemask
=QCFLAG_USERCONTROL
;
85 changemask
=QCFLAG_ALL
;
87 setflags(&rcp
->flags
, changemask
, cargv
[1], rcflags
, REJECT_NONE
);
89 /* We might need to do things in response to the flag changes.. */
91 if ((oldflags
^ rcp
->flags
) & (QCFLAG_JOINED
| QCFLAG_SUSPENDED
)) {
92 chanservjoinchan(cip
->channel
);
93 rcp
->status
|= (QCSTAT_OPCHECK
| QCSTAT_MODECHECK
| QCSTAT_BANCHECK
);
97 if (CIsEnforce(rcp
)) {
99 cs_checkbans(cip
->channel
);
102 if (CIsProtect(rcp
) || CIsBitch(rcp
) || CIsAutoOp(rcp
) || CIsAutoVoice(rcp
) || CIsKnownOnly(rcp
)) {
103 rcp
->status
|= QCSTAT_OPCHECK
;
109 if (CIsAutoLimit(rcp
) && !(oldflags
& QCFLAG_AUTOLIMIT
)) {
110 rcp
->forcemodes
|= CHANMODE_LIMIT
;
111 rcp
->denymodes
&= ~CHANMODE_LIMIT
;
116 if (!CIsAutoLimit(rcp
) && (oldflags
& QCFLAG_AUTOLIMIT
)) {
117 rcp
->forcemodes
&= ~CHANMODE_LIMIT
;
119 cs_checkchanmodes(cip
->channel
);
122 /* If nothing has changed, say so and don't do anything else */
123 if (rcp
->flags
== oldflags
) {
124 chanservstdmessage(sender
, QM_CHANLEVNOCHANGE
);
128 strcpy(flagbuf
,printflags(oldflags
, rcflags
));
129 cs_log(sender
,"CHANFLAGS %s %s (%s -> %s)",cip
->name
->content
,cargv
[1],flagbuf
,printflags(rcp
->flags
,rcflags
));
130 chanservstdmessage(sender
, QM_DONE
);
131 csdb_updatechannel(rcp
);
134 chanservstdmessage(sender
,QM_CURCHANFLAGS
,cip
->name
->content
,printflags(rcp
->flags
, rcflags
));