]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/usercmds/userflags.c
1 /* Automatically generated by refactor.pl.
5 * CMDLEVEL: QCMD_AUTHED
7 * CMDDESC: Shows or changes user flags.
8 * CMDFUNC: csu_douserflags
9 * CMDPROTO: int csu_douserflags(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: USERFLAGS <flags>
11 * CMDHELP: Changes your current user flags, where:
12 * CMDHELP: flags - changes to apply, in the usual flag letters preceded by +/- format.
13 * CMDHELP: Valid user flags are:
14 * CMDHELP: +n NOTICE - causes the bot to sent you NOTICEs. If this flag is not set the
15 * CMDHELP: bot will communicate using PRIVMSG.
18 #include "../chanserv.h"
19 #include "../../lib/irc_string.h"
23 int csu_douserflags ( void * source
, int cargc
, char ** cargv
) {
25 reguser
* rup
= getreguserfromnick ( sender
), * target
;
27 flag_t flagmask
, changemask
, oldflags
;
33 if ( cargc
> 0 && (* cargv
[ 0 ]!= '+' && * cargv
[ 0 ]!= '-' )) {
35 /* If the first char isn't a "change" character, it must specify a target */
37 if (!( target
= findreguser ( sender
, cargv
[ 0 ])))
40 if ( target
!= rup
&& ! cs_privcheck ( QPRIV_VIEWUSERFLAGS
, sender
)) {
41 chanservstdmessage ( sender
, QM_NOACCESSONUSER
, "userflags" , cargv
[ 0 ]);
49 /* OK, now we have a changestring.. */
50 if ( target
!= rup
&& ! cs_privcheck ( QPRIV_CHANGEUSERFLAGS
, sender
)) {
51 /* Safe to use cargv[0] because if target != rup then first arg must have been the target name */
52 chanservstdmessage ( sender
, QM_NOACCESSONUSER
, "userflags" , cargv
[ 0 ]);
56 strcpy ( flagbuf
, printflags ( target
-> flags
, ruflags
));
57 oldflags
= target
-> flags
;
59 changemask
= QUFLAG_NOTICE
| QUFLAG_INFO
;
62 /* If you're changing yourself, you can give up the "status" flags and add/remove notice */
63 changemask
|=( target
-> flags
& ( QUFLAG_OPER
| QUFLAG_DEV
| QUFLAG_PROTECT
| QUFLAG_HELPER
| QUFLAG_ADMIN
));
66 /* Warning, policy ahead */
68 if ( UHasOperPriv ( rup
))
69 changemask
|= QUFLAG_GLINE
| QUFLAG_DELAYEDGLINE
| QUFLAG_PROTECT
| QUFLAG_TRUST
;
71 if ( UHasAdminPriv ( rup
))
72 changemask
|= ( QUFLAG_OPER
| QUFLAG_HELPER
| QUFLAG_CLEANUPEXEMPT
);
75 changemask
= QUFLAG_ALL
;
77 setflags (& target
-> flags
, changemask
, cargv
[ arg
], ruflags
, REJECT_NONE
);
80 if (! UHasHelperPriv ( target
)) {
81 target
-> flags
&= ~ QUFLAG_PROTECT
;
84 cs_log ( sender
, "USERFLAGS # %s %s ( %s -> %s )" , target
-> username
, cargv
[ arg
], flagbuf
, printflags ( target
-> flags
, ruflags
));
86 /* only warn about interesting changes */
87 if (( target
-> flags
^ oldflags
) & ~( QUFLAG_NOTICE
| QUFLAG_INFO
)) {
88 chanservwallmessage ( " %s ( %s ) just used USERFLAGS on %s %s ( %s -> %s )" , sender
-> nick
, rup
-> username
, target
-> username
, cargv
[ arg
], flagbuf
, printflags ( target
-> flags
, ruflags
));
90 #ifdef AUTHGATE_WARNINGS
91 if ( UHasHelperPriv ( rup
))
92 chanservsendmessage ( sender
, "You MUST go to https://auth.quakenet.org and attempt to login as %s (with any password) to update the cache." , rup
-> username
);
95 csdb_updateuser ( target
);
96 chanservstdmessage ( sender
, QM_DONE
);
99 if ( cs_privcheck ( QPRIV_VIEWUSERFLAGS
, sender
))
102 flagmask
= QUFLAG_INFO
| QUFLAG_NOTICE
| QUFLAG_OPER
| QUFLAG_HELPER
| QUFLAG_DEV
| QUFLAG_ADMIN
;
104 chanservstdmessage ( sender
, QM_CURUSERFLAGS
, target
-> username
, printflagsornone ( target
-> flags
& flagmask
, ruflags
));