]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: chanflags | |
5 | * CMDLEVEL: QCMD_AUTHED | |
6 | * CMDARGS: 2 | |
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); | |
1e32d528 | 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 | |
39 | * CMDHELP: empty. | |
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. | |
1dd6d55d | 45 | */ |
46 | ||
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" | |
55 | #include <string.h> | |
56 | #include <stdio.h> | |
57 | ||
58 | int csc_dochanflags(void *source, int cargc, char **cargv) { | |
59 | regchan *rcp; | |
60 | nick *sender=source; | |
61 | reguser *rup=getreguserfromnick(sender); | |
62 | chanindex *cip; | |
63 | flag_t oldflags,changemask; | |
64 | char flagbuf[20]; | |
65 | ||
66 | if (cargc<1) { | |
67 | chanservstdmessage(sender,QM_NOTENOUGHPARAMS,"chanflags"); | |
68 | return CMD_ERROR; | |
69 | } | |
70 | ||
71 | if (!(cip=cs_checkaccess(sender, cargv[0], CA_OPPRIV, NULL, | |
72 | "chanflags", QPRIV_VIEWCHANFLAGS, 0))) | |
73 | return CMD_ERROR; | |
74 | ||
75 | rcp=cip->exts[chanservext]; | |
76 | ||
77 | if (cargc>1) { | |
78 | if (!cs_checkaccess(sender, NULL, CA_MASTERPRIV, cip, "chanflags", | |
79 | QPRIV_CHANGECHANFLAGS, 0)) | |
80 | return CMD_ERROR; | |
81 | ||
82 | oldflags=rcp->flags; | |
83 | changemask=QCFLAG_USERCONTROL; | |
84 | if (UIsDev(rup)) { | |
85 | changemask=QCFLAG_ALL; | |
86 | } | |
87 | setflags(&rcp->flags, changemask, cargv[1], rcflags, REJECT_NONE); | |
88 | ||
89 | /* We might need to do things in response to the flag changes.. */ | |
90 | if (cip->channel) { | |
91 | if ((oldflags ^ rcp->flags) & (QCFLAG_JOINED | QCFLAG_SUSPENDED)) { | |
92 | chanservjoinchan(cip->channel); | |
93 | rcp->status |= (QCSTAT_OPCHECK | QCSTAT_MODECHECK | QCSTAT_BANCHECK); | |
94 | rcp->lastbancheck=0; | |
95 | cs_timerfunc(cip); | |
96 | } else { | |
97 | if (CIsEnforce(rcp)) { | |
98 | rcp->lastbancheck=0; | |
99 | cs_checkbans(cip->channel); | |
100 | } | |
101 | ||
102 | if (CIsProtect(rcp) || CIsBitch(rcp) || CIsAutoOp(rcp) || CIsAutoVoice(rcp) || CIsKnownOnly(rcp)) { | |
103 | rcp->status |= QCSTAT_OPCHECK; | |
104 | cs_timerfunc(cip); | |
105 | } | |
106 | } | |
107 | } | |
108 | ||
109 | if (CIsAutoLimit(rcp) && !(oldflags & QCFLAG_AUTOLIMIT)) { | |
110 | rcp->forcemodes |= CHANMODE_LIMIT; | |
111 | rcp->denymodes &= ~CHANMODE_LIMIT; | |
112 | rcp->limit=0; | |
113 | cs_timerfunc(cip); | |
114 | } | |
115 | ||
116 | if (!CIsAutoLimit(rcp) && (oldflags & QCFLAG_AUTOLIMIT)) { | |
117 | rcp->forcemodes &= ~CHANMODE_LIMIT; | |
118 | if (cip->channel) | |
119 | cs_checkchanmodes(cip->channel); | |
120 | } | |
121 | ||
dba27c3b | 122 | /* If nothing has changed, say so and don't do anything else */ |
123 | if (rcp->flags == oldflags) { | |
124 | chanservstdmessage(sender, QM_CHANLEVNOCHANGE); | |
125 | return CMD_OK; | |
126 | } | |
127 | ||
1dd6d55d | 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); | |
132 | } | |
133 | ||
134 | chanservstdmessage(sender,QM_CURCHANFLAGS,cip->name->content,printflags(rcp->flags, rcflags)); | |
135 | return CMD_OK; | |
136 | } |