]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/voice.c
1 /* Automatically generated by refactor.pl.
5 * CMDLEVEL: QCMD_AUTHED
7 * CMDDESC: Voices you or other users on channel(s).
9 * CMDPROTO: int csc_dovoice(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: VOICE [<channel> [<user1> [<user2> [...]]]]
11 * CMDHELP: Grants voice to you on one or more channels, or grants voice to one or more
12 * CMDHELP: other users on a particular channel. This command cannot be used to grant
13 * CMDHELP: voice to users who would otherwise be prevented from obtaining voice, e.g.
14 * CMDHELP: the quiet (+q) chanlev flag. Where:
15 * CMDHELP: channel - channel to use. If no channel is specified, you will be granted voice
16 * CMDHELP: on every channel where you have appropriate access and are not already
18 * CMDHELP: user<n> - other users to grant voice to. Must be specified as the nickname
19 * CMDHELP: of users who are on the named channel.
20 * CMDHELP: Voicing yourself requires voice (+v) access on the relevant channels.
21 * CMDHELP: Voicing other users requires operator (+o) access on the named channel. If this
22 * CMDHELP: command is used to voice other users, a notice will be sent to channel operators
23 * CMDHELP: on the channel identifying you, unless you have master (+m) access.
26 #include "../chanserv.h"
27 #include "../../nick/nick.h"
28 #include "../../lib/flags.h"
29 #include "../../lib/irc_string.h"
30 #include "../../channel/channel.h"
31 #include "../../parser/parser.h"
32 #include "../../irc/irc.h"
33 #include "../../localuser/localuserchannel.h"
37 int csc_dovoice(void *source
, int cargc
, char **cargv
) {
38 nick
*sender
=source
, *np
;
39 reguser
*rup
=getreguserfromnick(sender
);
48 unsigned int bufpos
=0,donotice
=0;
54 /* No args: "voice me on every channel you can */
55 ca
=sender
->channels
->content
;
56 for (i
=0;i
<sender
->channels
->cursi
;i
++) {
57 if ((rcp
=ca
[i
]->index
->exts
[chanservext
]) && !CIsSuspended(rcp
)) {
58 /* It's a Q channel */
59 if (!(*(getnumerichandlefromchanhash(ca
[i
]->users
, sender
->numeric
)) &
60 (CUMODE_OP
|CUMODE_VOICE
))) {
61 /* They're not opped or voiced */
62 rcup
=findreguseronchannel(rcp
, rup
);
63 if ((!rcup
|| !CUIsQuiet(rcup
)) &&
64 ((rcup
&& CUHasVoicePriv(rcup
)) ||
65 (CIsVoiceAll(rcp
)))) {
66 /* And they have voice priv on the chan (or it's autovoice):
68 localsetmodeinit(&changes
, ca
[i
], chanservnick
);
69 localdosetmode_nick(&changes
, sender
, MC_VOICE
);
70 localsetmodeflush(&changes
,1);
76 chanservstdmessage(sender
, QM_DONE
);
80 /* If there is at least one arg, the first is a channel */
82 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_VOICEPRIV
, NULL
, "voice", 0, 0)))
86 /* Only one arg: "voice me" */
87 if (!cs_checkaccess(sender
, NULL
, CA_VOICEPRIV
| CA_DEVOICED
, cip
,
91 localsetmodeinit(&changes
, cip
->channel
, chanservnick
);
92 localdosetmode_nick(&changes
, sender
, MC_VOICE
);
93 localsetmodeflush(&changes
,1);
95 chanservstdmessage(sender
, QM_DONE
);
99 /* You've got to be an operator to voice other people */
100 if (!cs_checkaccess(sender
, NULL
, CA_OPPRIV
, cip
, "voice", 0, 0))
103 /* You've got to be a master to 'silently' voice other people */
104 if (!cs_checkaccess(sender
, NULL
, CA_MASTERPRIV
, cip
, "voice", 0, 1))
107 rcp
=cip
->exts
[chanservext
];
109 /* Set up the modes */
110 localsetmodeinit(&changes
, cip
->channel
, chanservnick
);
112 for(i
=1;i
<cargc
;i
++) {
113 if (!(np
=getnickbynick(cargv
[i
]))) {
114 chanservstdmessage(sender
, QM_UNKNOWNUSER
, cargv
[i
]);
118 if (!(lp
=getnumerichandlefromchanhash(cip
->channel
->users
, np
->numeric
))) {
119 chanservstdmessage(sender
, QM_USERNOTONCHAN
, np
->nick
, cip
->name
->content
);
123 if (*lp
& CUMODE_VOICE
) {
124 chanservstdmessage(sender
, QM_USERVOICEDONCHAN
, np
->nick
, cip
->name
->content
);
128 if ((rup
=getreguserfromnick(np
)) && (rcup
=findreguseronchannel(rcp
, rup
)) && CUIsQuiet(rcup
)) {
129 chanservstdmessage(sender
, QM_CANTVOICE
, np
->nick
, cip
->name
->content
);
133 bufpos
+=sprintf(buf
+bufpos
,"%s%s",bufpos
?", ":"",np
->nick
);
134 localdosetmode_nick(&changes
, np
, MC_VOICE
);
137 if (donotice
&& bufpos
) {
138 sendopnoticetochannel(chanservnick
, cip
->channel
, "%s voiced %s", sender
, buf
);
141 localsetmodeflush(&changes
, 1);
142 chanservstdmessage(sender
, QM_DONE
);