]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/requestowner.c
1 /* Automatically generated by refactor.pl.
4 * CMDNAME: requestowner
5 * CMDLEVEL: QCMD_AUTHED
7 * CMDDESC: Requests ownership of a channel on which there are no owners.
8 * CMDFUNC: csc_dorequestowner
9 * CMDPROTO: int csc_dorequestowner(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: requestowner <channel>
11 * CMDHELP: Requests owner (+n) access to the named channel. In order to use this command,
12 * CMDHELP: there must be no owners left on the channel, and you must have the highest
13 * CMDHELP: access level of the remaining users. Where:
14 * CMDHELP: channel - the channel to request ownership of
17 #include "../chanserv.h"
18 #include "../../nick/nick.h"
19 #include "../../lib/flags.h"
20 #include "../../lib/irc_string.h"
21 #include "../../channel/channel.h"
22 #include "../../parser/parser.h"
23 #include "../../irc/irc.h"
24 #include "../../localuser/localuserchannel.h"
25 #include "../../lib/strlfunc.h"
29 int csc_dorequestowner(void *source
, int cargc
, char **cargv
) {
34 regchanuser
*rcup
, *requester
;
40 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "requestowner");
44 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_KNOWN
, NULL
, "requestowner", 0, 0)))
47 rup
=getreguserfromnick(sender
);
51 rcp
=cip
->exts
[chanservext
];
52 requester
=findreguseronchannel(rcp
, rup
);
53 if (!requester
|| !rcp
)
56 for(i
=0;i
<REGCHANUSERHASHSIZE
;i
++) {
57 for(rcup
=rcp
->regusers
[i
];rcup
;rcup
=rcup
->nextbychan
) {
58 if (CUIsOwner(rcup
) ||
59 (CUIsMaster(rcup
) && !CUHasMasterPriv(requester
)) ||
60 (CUIsOp(rcup
) && !CUHasOpPriv(requester
)) ||
61 (CUIsVoice(rcup
) && !CUHasVoicePriv(requester
)) ) {
62 chanservstdmessage(sender
, QM_NOREQUESTOWNER
, cip
->name
->content
, CUIsOwner(rcup
)?"owner":CUIsMaster(rcup
)?"master":"op");
68 oldflags
=requester
->flags
;
69 strlcpy(flagbuf
,printflags(oldflags
,rcuflags
),sizeof(flagbuf
));
71 CUSetOwner(requester
);
72 cs_log(sender
,"REQUESTOWNER %s #%s (%s -> %s)",cip
->name
->content
,requester
->user
->username
,flagbuf
,printflags(requester
->flags
,rcuflags
));
73 csdb_chanlevhistory_insert(rcp
, sender
, requester
->user
, oldflags
, requester
->flags
);
74 csdb_updatechanuser(requester
);
76 chanservstdmessage(sender
, QM_GRANTEDOWNER
, cip
->name
->content
);