]>
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: +h ACH'MENTS Display achievement announcements in channel.
32 * CMDHELP: +j JOINED Causes Q to remain on the channel. Cannot be removed.
33 * CMDHELP: +k KNOWNONLY Any user who joins the channel who is not known (+k) will be kicked.
34 * CMDHELP: Unless channel mode +i is set they will be banned as well.
35 * CMDHELP: +p PROTECT Any user with voice (+v) or operator (+o) access will have that
36 * CMDHELP: status enforced on the channel at all times. Same effect as giving
37 * CMDHELP: all ops and voices the +p chanlev flag.
38 * CMDHELP: +t TOPICSAVE Saves the topic when it changes. Such saved topics can be restored
39 * CMDHELP: via settopic, or when the bot rejoins when a channel has been left
41 * CMDHELP: +v VOICEALL Automatically grants voice (+v) on the channel to any user who enters,
42 * CMDHELP: unless they have quiet (+q) chanlev flag.
43 * CMDHELP: +w WELCOME Sends the welcome message to users joining the channel. See WELCOME.
44 * CMDHELP: Note: Previous versions of Q included the facility to enforce limits and keys using
45 * CMDHELP: +k and +l chanflags. This functionality is now available via the CHANMODE command.
48 #include "../chanserv.h"
49 #include "../../nick/nick.h"
50 #include "../../lib/flags.h"
51 #include "../../lib/irc_string.h"
52 #include "../../channel/channel.h"
53 #include "../../parser/parser.h"
54 #include "../../irc/irc.h"
55 #include "../../localuser/localuserchannel.h"
59 int csc_dochanflags(void *source
, int cargc
, char **cargv
) {
62 reguser
*rup
=getreguserfromnick(sender
);
64 flag_t oldflags
,changemask
;
68 chanservstdmessage(sender
,QM_NOTENOUGHPARAMS
,"chanflags");
72 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_OPPRIV
, NULL
,
73 "chanflags", QPRIV_VIEWCHANFLAGS
, 0)))
76 rcp
=cip
->exts
[chanservext
];
79 if (!cs_checkaccess(sender
, NULL
, CA_MASTERPRIV
, cip
, "chanflags",
80 QPRIV_CHANGECHANFLAGS
, 0))
84 changemask
=QCFLAG_USERCONTROL
;
86 /* Disable achievements flag before April 1 */
87 if (time(NULL
) < ACHIEVEMENTS_START
)
88 changemask
&= ~QCFLAG_ACHIEVEMENTS
;
90 /* Developer override! */
92 changemask
=QCFLAG_ALL
;
94 setflags(&rcp
->flags
, changemask
, cargv
[1], rcflags
, REJECT_NONE
);
96 /* We might need to do things in response to the flag changes.. */
98 if ((oldflags
^ rcp
->flags
) & (QCFLAG_JOINED
| QCFLAG_SUSPENDED
)) {
99 chanservjoinchan(cip
->channel
);
100 rcp
->status
|= (QCSTAT_OPCHECK
| QCSTAT_MODECHECK
| QCSTAT_BANCHECK
);
104 if (CIsEnforce(rcp
)) {
106 cs_checkbans(cip
->channel
);
109 if (CIsProtect(rcp
) || CIsBitch(rcp
) || CIsAutoOp(rcp
) || CIsAutoVoice(rcp
) || CIsKnownOnly(rcp
)) {
110 rcp
->status
|= QCSTAT_OPCHECK
;
116 if (CIsAutoLimit(rcp
) && !(oldflags
& QCFLAG_AUTOLIMIT
)) {
117 rcp
->forcemodes
|= CHANMODE_LIMIT
;
118 rcp
->denymodes
&= ~CHANMODE_LIMIT
;
123 if (!CIsAutoLimit(rcp
) && (oldflags
& QCFLAG_AUTOLIMIT
)) {
124 rcp
->forcemodes
&= ~CHANMODE_LIMIT
;
126 cs_checkchanmodes(cip
->channel
);
129 /* If nothing has changed, say so and don't do anything else */
130 if (rcp
->flags
== oldflags
) {
131 chanservstdmessage(sender
, QM_CHANLEVNOCHANGE
);
135 strcpy(flagbuf
,printflags(oldflags
, rcflags
));
136 cs_log(sender
,"CHANFLAGS %s %s (%s -> %s)",cip
->name
->content
,cargv
[1],flagbuf
,printflags(rcp
->flags
,rcflags
));
137 chanservstdmessage(sender
, QM_DONE
);
138 csdb_updatechannel(rcp
);
141 chanservstdmessage(sender
,QM_CURCHANFLAGS
,cip
->name
->content
,printflags(rcp
->flags
, rcflags
));