]>
Commit | Line | Data |
---|---|---|
6b30ed58 CP |
1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: requestowner | |
5 | * CMDLEVEL: QCMD_AUTHED | |
6 | * CMDARGS: 1 | |
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); | |
50cd26d6 | 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 | |
6b30ed58 CP |
15 | */ |
16 | ||
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" | |
26 | #include <string.h> | |
27 | #include <stdio.h> | |
28 | ||
29 | int csc_dorequestowner(void *source, int cargc, char **cargv) { | |
30 | nick *sender=source; | |
31 | chanindex *cip; | |
32 | reguser *rup; | |
33 | regchan *rcp; | |
34 | regchanuser *rcup, *requester; | |
35 | int i; | |
36 | char flagbuf[20]; | |
37 | flag_t oldflags; | |
38 | ||
39 | if (cargc<1) { | |
40 | chanservstdmessage(sender, QM_NOTENOUGHPARAMS, "requestowner"); | |
41 | return CMD_ERROR; | |
42 | } | |
43 | ||
e8e09b86 | 44 | if (!(cip=cs_checkaccess(sender, cargv[0], CA_KNOWN, NULL, "requestowner", 0, 0))) |
6b30ed58 CP |
45 | return CMD_ERROR; |
46 | ||
47 | rup=getreguserfromnick(sender); | |
48 | if(!rup) | |
49 | return CMD_ERROR; | |
50 | ||
51 | rcp=cip->exts[chanservext]; | |
52 | requester=findreguseronchannel(rcp, rup); | |
53 | if (!requester || !rcp) | |
54 | return CMD_ERROR; | |
55 | ||
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)) || | |
e8e09b86 | 60 | (CUIsOp(rcup) && !CUHasOpPriv(requester)) || |
61 | (CUIsVoice(rcup) && !CUHasVoicePriv(requester)) ) { | |
6b30ed58 CP |
62 | chanservstdmessage(sender, QM_NOREQUESTOWNER, cip->name->content, CUIsOwner(rcup)?"owner":CUIsMaster(rcup)?"master":"op"); |
63 | return CMD_ERROR; | |
64 | } | |
65 | } | |
66 | } | |
67 | ||
68 | oldflags=requester->flags; | |
69 | strlcpy(flagbuf,printflags(oldflags,rcuflags),sizeof(flagbuf)); | |
70 | ||
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); | |
75 | ||
76 | chanservstdmessage(sender, QM_GRANTEDOWNER, cip->name->content); | |
77 | return CMD_OK; | |
78 | } |