]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/chancmds/giveowner.c
3 * CMDLEVEL: QCMD_AUTHED
5 * CMDDESC: Gives total control over a channel to another user.
6 * CMDFUNC: csc_dogiveowner
7 * CMDPROTO: int csc_dogiveowner(void *source, int cargc, char **cargv);
10 #include "../chanserv.h"
11 #include "../../nick/nick.h"
12 #include "../../lib/flags.h"
13 #include "../../lib/irc_string.h"
14 #include "../../channel/channel.h"
15 #include "../../parser/parser.h"
16 #include "../../irc/irc.h"
17 #include "../../localuser/localuserchannel.h"
21 int csc_dogiveowner(void *source
, int cargc
, char **cargv
) {
26 reguser
*rup
=getreguserfromnick(sender
), *target
;
33 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "giveowner");
37 /* You need to either be +n or have the relevant override... */
38 if (!(cip
=cs_checkaccess(sender
, cargv
[0], CA_OWNERPRIV
,
39 NULL
, "chanlev", QPRIV_CHANGECHANLEV
, 0)))
42 rcp
=cip
->exts
[chanservext
];
44 if (!(target
=findreguser(sender
, cargv
[1])))
45 return CMD_ERROR
; /* If there was an error, findreguser will have sent a message saying why.. */
47 rcup
=findreguseronchannel(rcp
, target
);
49 /* You can only promote a master */
50 if (!rcup
|| !(rcup
->flags
& QCUFLAG_MASTER
)) {
51 chanservstdmessage(sender
,QM_GIVEOWNERNOTMASTER
,target
->username
,cip
->name
->content
);
55 /* Can't promote if already owner */
56 if (rcup
->flags
& QCUFLAG_OWNER
) {
57 chanservstdmessage(sender
,QM_GIVEOWNERALREADYOWNER
,target
->username
,cip
->name
->content
);
62 sprintf(hashstr
,"%u.%u.%u",rcp
->ID
,target
->ID
,rup
->ID
);
63 thehash
=crc32(hashstr
);
65 sprintf(hashstr
,"%x",thehash
);
68 chanservstdmessage(sender
,QM_GIVEOWNERNEEDHASH
,cip
->name
->content
,target
->username
,
69 cip
->name
->content
,target
->username
,hashstr
);
73 if (ircd_strcmp(cargv
[2], hashstr
)) {
74 chanservstdmessage(sender
,QM_GIVEOWNERWRONGHASH
,target
->username
,
79 /* OK, hash matches, do it. */
80 oldflags
= rcup
->flags
;
81 rcup
->flags
|= QCUFLAG_OWNER
;
83 chanservstdmessage(sender
,QM_DONE
);
85 strcpy(flagbuf
,printflags(oldflags
,rcuflags
));
86 cs_log(sender
,"GIVEOWNER %s #%s (%s -> %s)",cip
->name
->content
,rcup
->user
->username
,
87 flagbuf
,printflags(rcup
->flags
,rcuflags
));
89 csdb_chanlevhistory_insert(rcp
, sender
, rcup
->user
, oldflags
, rcup
->flags
);
90 csdb_updatechanuser(rcup
);