]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/op.c
1 /* Automatically generated by refactor.pl.
5 * CMDLEVEL: QCMD_AUTHED
7 * CMDDESC: Ops you or other users on channel(s).
9 * CMDPROTO: int csc_doop(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: OP [<channel> [<user1> [<user2> [...]]]]
11 * CMDHELP: Ops you on one or more channels, or ops other named users on a given channel.
12 * CMDHELP: This command cannot be used to op users who are otherwise prevented from getting
13 * CMDHELP: ops, e.g. via the +d chanlev flag (see CHANLEV) or bitch mode (see CHANFLAGS).
15 * CMDHELP: channel - channel to use. If no channel is specified, you will be given ops on
16 * CMDHELP: every channel where you have appropriate access and are not already
18 * CMDHELP: user<n> - user(s) to op instead of yourself. Each user must be specified as the
19 * CMDHELP: current nickname of a user on the named channel.
20 * CMDHELP: OP requires operator access (+o) on the named channel. If this command is used
21 * CMDHELP: to op other users, a notice will be sent to other channel operators on the
22 * CMDHELP: channel identifying you, unless you have master (+m) access.
25 #include "../chanserv.h"
26 #include "../../nick/nick.h"
27 #include "../../lib/flags.h"
28 #include "../../lib/irc_string.h"
29 #include "../../channel/channel.h"
30 #include "../../parser/parser.h"
31 #include "../../irc/irc.h"
32 #include "../../localuser/localuserchannel.h"
36 int csc_doop(void *source
, int cargc
, char **cargv
) {
37 nick
*sender
=source
, *np
;
38 reguser
*rup
=getreguserfromnick(sender
);
47 int donotice
=0, bufpos
=0;
54 /* No args: "op 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
)) &
61 /* They're not opped */
62 if ((rcup
=findreguseronchannel(rcp
, rup
)) && CUHasOpPriv(rcup
) &&
64 /* And they have op priv on the chan: op them */
65 localsetmodeinit(&changes
, ca
[i
], chanservnick
);
66 localdosetmode_nick(&changes
, sender
, MC_OP
);
67 localsetmodeflush(&changes
,1);
68 cs_logchanop(rcp
, sender
->nick
, rup
);
74 chanservstdmessage(sender
, QM_DONE
);
78 /* If there is at least one arg, the first is a channel */
80 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_OPPRIV
, NULL
, "op", 0, 0)))
83 rcp
=cip
->exts
[chanservext
];
85 /* If the channel doesn't currently exist, forget it. */
87 chanservstdmessage(sender
, QM_EMPTYCHAN
, cip
->name
->content
);
92 /* Only one arg: "op me" */
93 if (!cs_checkaccess(sender
, NULL
, CA_OPPRIV
| CA_DEOPPED
, cip
, "op", 0, 0))
96 localsetmodeinit(&changes
, cip
->channel
, chanservnick
);
97 localdosetmode_nick(&changes
, sender
, MC_OP
);
98 localsetmodeflush(&changes
,1);
99 cs_logchanop(rcp
, sender
->nick
, srup
);
101 chanservstdmessage(sender
, QM_DONE
);
105 /* You've got to be a master to 'silently' op other people */
106 if (!cs_checkaccess(sender
, NULL
, CA_MASTERPRIV
, cip
, "op", 0, 1))
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_OP
) {
124 chanservstdmessage(sender
, QM_USEROPPEDONCHAN
, np
->nick
, cip
->name
->content
);
128 rup
=getreguserfromnick(np
);
130 rcup
=findreguseronchannel(rcp
,rup
);
134 /* Bitch mode: check that this user is allowed to be opped.. */
135 if ((CIsBitch(rcp
) && (!rcup
|| !CUHasOpPriv(rcup
))) || (rcup
&& CUIsDeny(rcup
))) {
136 chanservstdmessage(sender
, QM_CANTOP
, np
->nick
, cip
->name
->content
);
140 bufpos
+= sprintf(buf
+bufpos
,"%s%s",bufpos
?", ":"",np
->nick
);
141 localdosetmode_nick(&changes
, np
, MC_OP
);
142 cs_logchanop(rcp
, np
->nick
, srup
);
145 if (donotice
&& bufpos
) {
146 sendopnoticetochannel(chanservnick
, cip
->channel
, "%s opped %s", sender
, buf
);
149 localsetmodeflush(&changes
, 1);
150 chanservstdmessage(sender
, QM_DONE
);