]>
Commit | Line | Data |
---|---|---|
1dd6d55d | 1 | /* Automatically generated by refactor.pl. |
2 | * | |
3 | * | |
4 | * CMDNAME: userflags | |
5 | * CMDLEVEL: QCMD_AUTHED | |
6 | * CMDARGS: 2 | |
7 | * CMDDESC: Shows or changes user flags. | |
8 | * CMDFUNC: csu_douserflags | |
9 | * CMDPROTO: int csu_douserflags(void *source, int cargc, char **cargv); | |
50cd26d6 | 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. | |
1dd6d55d | 16 | */ |
17 | ||
18 | #include "../chanserv.h" | |
19 | #include "../../lib/irc_string.h" | |
20 | #include <stdio.h> | |
21 | #include <string.h> | |
22 | ||
23 | int csu_douserflags(void *source, int cargc, char **cargv) { | |
24 | nick *sender=source; | |
25 | reguser *rup=getreguserfromnick(sender), *target; | |
fbc4d9ed | 26 | int arg=0, wasorisoper; |
8dfd270a | 27 | flag_t flagmask, changemask, oldflags; |
1dd6d55d | 28 | char flagbuf[30]; |
29 | ||
30 | if (!rup) | |
31 | return CMD_ERROR; | |
32 | ||
1482fb78 | 33 | if (cargc>0 && (*cargv[0]!='+' && *cargv[0]!='-')) { |
1dd6d55d | 34 | arg++; |
35 | /* If the first char isn't a "change" character, it must specify a target */ | |
36 | ||
37 | if (!(target=findreguser(sender,cargv[0]))) | |
38 | return CMD_ERROR; | |
39 | ||
40 | if (target!=rup && !cs_privcheck(QPRIV_VIEWUSERFLAGS, sender)) { | |
1482fb78 | 41 | chanservstdmessage(sender, QM_NOACCESSONUSER, "userflags", cargv[0]); |
1dd6d55d | 42 | return CMD_ERROR; |
43 | } | |
44 | } else { | |
45 | target=rup; | |
46 | } | |
47 | ||
48 | if (cargc>arg) { | |
49 | /* OK, now we have a changestring.. */ | |
50 | if (target!=rup && !cs_privcheck(QPRIV_CHANGEUSERFLAGS, sender)) { | |
1482fb78 | 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]); | |
1dd6d55d | 53 | return CMD_ERROR; |
54 | } | |
55 | ||
56 | strcpy(flagbuf,printflags(target->flags, ruflags)); | |
8dfd270a | 57 | oldflags=target->flags; |
1dd6d55d | 58 | |
3a744b8f | 59 | changemask=QUFLAG_NOTICE; |
1dd6d55d | 60 | |
61 | if (target==rup) { | |
62 | /* If you're changing yourself, you can give up the "status" flags and add/remove notice */ | |
347686bd | 63 | changemask|=(target->flags & (QUFLAG_OPER | QUFLAG_DEV | QUFLAG_PROTECT | QUFLAG_HELPER | QUFLAG_ADMIN | QUFLAG_STAFF)); |
1dd6d55d | 64 | } |
65 | ||
66 | /* Warning, policy ahead */ | |
67 | ||
68 | if (UHasOperPriv(rup)) | |
f39514a3 | 69 | changemask |= QUFLAG_PROTECT | QUFLAG_TRUST | QCFLAG_NOINFO; |
1dd6d55d | 70 | |
71 | if (UHasAdminPriv(rup)) | |
347686bd | 72 | changemask |= (QUFLAG_OPER | QUFLAG_HELPER | QUFLAG_CLEANUPEXEMPT | QUFLAG_STAFF); |
1dd6d55d | 73 | |
74 | if (UIsDev(rup)) | |
75 | changemask=QUFLAG_ALL; | |
76 | ||
fbc4d9ed | 77 | wasorisoper = UHasOperPriv(target); |
1dd6d55d | 78 | setflags(&target->flags, changemask, cargv[arg], ruflags, REJECT_NONE); |
fbc4d9ed CP |
79 | wasorisoper |= UHasOperPriv(target); |
80 | ||
1dd6d55d | 81 | /* More policy */ |
82 | if (!UHasHelperPriv(target)) { | |
83 | target->flags &= ~QUFLAG_PROTECT; | |
84 | } | |
85 | ||
86 | cs_log(sender,"USERFLAGS #%s %s (%s -> %s)",target->username,cargv[arg],flagbuf,printflags(target->flags, ruflags)); | |
8dfd270a CP |
87 | |
88 | /* only warn about interesting changes */ | |
8907f377 | 89 | if((target->flags ^ oldflags) & ~(QUFLAG_NOTICE | QUFLAG_INFO | QUFLAG_TRUST)) { |
8dfd270a CP |
90 | chanservwallmessage("%s (%s) just used USERFLAGS on %s %s (%s -> %s)",sender->nick,rup->username,target->username,cargv[arg],flagbuf,printflags(target->flags,ruflags)); |
91 | ||
e9f49ea9 | 92 | #ifdef AUTHGATE_WARNINGS |
fbc4d9ed CP |
93 | if(wasorisoper) |
94 | 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); | |
e9f49ea9 CP |
95 | #endif |
96 | } | |
1dd6d55d | 97 | csdb_updateuser(target); |
98 | chanservstdmessage(sender, QM_DONE); | |
99 | } | |
100 | ||
101 | if (cs_privcheck(QPRIV_VIEWUSERFLAGS, sender)) | |
102 | flagmask=QUFLAG_ALL; | |
103 | else | |
347686bd | 104 | flagmask=QUFLAG_INFO | QUFLAG_NOTICE | QUFLAG_OPER | QUFLAG_HELPER | QUFLAG_DEV | QUFLAG_ADMIN | QUFLAG_STAFF; |
1dd6d55d | 105 | |
43583524 | 106 | chanservstdmessage(sender, QM_CURUSERFLAGS, target->username, printflagsornone(target->flags & flagmask, ruflags)); |
1dd6d55d | 107 | |
108 | return CMD_OK; | |
109 | } |