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