]>
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 int arg
= 0 , wasorisoper
;
28 flag_t flagmask
, changemask
, oldflags
;
34 if ( cargc
> 0 && (* cargv
[ 0 ]!= '+' && * cargv
[ 0 ]!= '-' )) {
36 /* If the first char isn't a "change" character, it must specify a target */
38 if (!( target
= findreguser ( sender
, cargv
[ 0 ])))
41 if ( target
!= rup
&& ! cs_privcheck ( QPRIV_VIEWUSERFLAGS
, sender
)) {
42 chanservstdmessage ( sender
, QM_NOACCESSONUSER
, "userflags" , cargv
[ 0 ]);
50 /* OK, now we have a changestring.. */
51 if ( target
!= rup
&& ! cs_privcheck ( QPRIV_CHANGEUSERFLAGS
, sender
)) {
52 /* Safe to use cargv[0] because if target != rup then first arg must have been the target name */
53 chanservstdmessage ( sender
, QM_NOACCESSONUSER
, "userflags" , cargv
[ 0 ]);
57 strcpy ( flagbuf
, printflags ( target
-> flags
, ruflags
));
58 oldflags
= target
-> flags
;
60 changemask
= QUFLAG_NOTICE
;
63 /* If you're changing yourself, you can give up the "status" flags and add/remove notice */
64 changemask
|=( target
-> flags
& ( QUFLAG_OPER
| QUFLAG_DEV
| QUFLAG_PROTECT
| QUFLAG_HELPER
| QUFLAG_ADMIN
| QUFLAG_STAFF
));
67 /* Warning, policy ahead */
69 if ( UHasStaffPriv ( rup
))
70 changemask
|= QUFLAG_PROTECT
;
72 if ( UHasOperPriv ( rup
))
73 changemask
|= QUFLAG_PROTECT
| QUFLAG_TRUST
| QCFLAG_NOINFO
;
75 if ( UHasAdminPriv ( rup
))
76 changemask
|= ( QUFLAG_OPER
| QUFLAG_HELPER
| QUFLAG_CLEANUPEXEMPT
| QUFLAG_STAFF
);
79 changemask
= QUFLAG_ALL
;
81 wasorisoper
= UHasOperPriv ( target
);
82 setflags (& target
-> flags
, changemask
, cargv
[ arg
], ruflags
, REJECT_NONE
);
83 wasorisoper
|= UHasOperPriv ( target
);
86 if (! UHasStaffPriv ( target
)) {
87 target
-> flags
&= ~ QUFLAG_PROTECT
;
90 cs_log ( sender
, "USERFLAGS # %s %s ( %s -> %s )" , target
-> username
, cargv
[ arg
], flagbuf
, printflags ( target
-> flags
, ruflags
));
92 /* only warn about interesting changes */
93 if (( target
-> flags
^ oldflags
) & ~( QUFLAG_NOTICE
| QUFLAG_INFO
| QUFLAG_TRUST
)) {
94 chanservwallmessage ( " %s ( %s ) just used USERFLAGS on %s %s ( %s -> %s )" , sender
-> nick
, rup
-> username
, target
-> username
, cargv
[ arg
], flagbuf
, printflags ( target
-> flags
, ruflags
));
96 #ifdef AUTHGATE_WARNINGS
98 chanservsendmessage ( sender
, "WARNING FOR PRIVILEGED USERS: you MUST go to https://auth.quakenet.org and attempt to login as %s (with any password) to update the cache, otherwise their old credentials will be preserved in certain circumstances." , target
-> username
);
101 csdb_updateuser ( target
);
103 if (( anp
= findauthname ( rup
-> ID
)))
104 localusersetaccountflags ( anp
, cs_accountflagmap ( target
));
106 chanservstdmessage ( sender
, QM_DONE
);
109 if ( cs_privcheck ( QPRIV_VIEWUSERFLAGS
, sender
))
112 flagmask
= QUFLAG_INFO
| QUFLAG_NOTICE
| QUFLAG_OPER
| QUFLAG_HELPER
| QUFLAG_DEV
| QUFLAG_ADMIN
| QUFLAG_STAFF
;
114 chanservstdmessage ( sender
, QM_CURUSERFLAGS
, target
-> username
, printflagsornone ( target
-> flags
& flagmask
, ruflags
));