]>
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: | |
9b7c9974 | 14 | * CMDHELP: +c ACH'MENTS - enables achievements system - allows use of achievement commands |
15 | * CMDHELP: and sends achievement messages. | |
16 | * CMDHELP: +n NOTICE - causes the bot to sent you NOTICEs. If this flag is not set the | |
17 | * CMDHELP: bot will communicate using PRIVMSG. | |
1dd6d55d | 18 | */ |
19 | ||
20 | #include "../chanserv.h" | |
21 | #include "../../lib/irc_string.h" | |
22 | #include <stdio.h> | |
23 | #include <string.h> | |
24 | ||
25 | int csu_douserflags(void *source, int cargc, char **cargv) { | |
26 | nick *sender=source; | |
27 | reguser *rup=getreguserfromnick(sender), *target; | |
3294b10b | 28 | authname *anp; |
fbc4d9ed | 29 | int arg=0, wasorisoper; |
8dfd270a | 30 | flag_t flagmask, changemask, oldflags; |
1dd6d55d | 31 | char flagbuf[30]; |
32 | ||
33 | if (!rup) | |
34 | return CMD_ERROR; | |
35 | ||
1482fb78 | 36 | if (cargc>0 && (*cargv[0]!='+' && *cargv[0]!='-')) { |
1dd6d55d | 37 | arg++; |
38 | /* If the first char isn't a "change" character, it must specify a target */ | |
39 | ||
40 | if (!(target=findreguser(sender,cargv[0]))) | |
41 | return CMD_ERROR; | |
42 | ||
43 | if (target!=rup && !cs_privcheck(QPRIV_VIEWUSERFLAGS, sender)) { | |
1482fb78 | 44 | chanservstdmessage(sender, QM_NOACCESSONUSER, "userflags", cargv[0]); |
1dd6d55d | 45 | return CMD_ERROR; |
46 | } | |
47 | } else { | |
48 | target=rup; | |
49 | } | |
50 | ||
51 | if (cargc>arg) { | |
52 | /* OK, now we have a changestring.. */ | |
53 | if (target!=rup && !cs_privcheck(QPRIV_CHANGEUSERFLAGS, sender)) { | |
1482fb78 | 54 | /* Safe to use cargv[0] because if target != rup then first arg must have been the target name */ |
55 | chanservstdmessage(sender, QM_NOACCESSONUSER, "userflags", cargv[0]); | |
1dd6d55d | 56 | return CMD_ERROR; |
57 | } | |
58 | ||
59 | strcpy(flagbuf,printflags(target->flags, ruflags)); | |
8dfd270a | 60 | oldflags=target->flags; |
1dd6d55d | 61 | |
3a744b8f | 62 | changemask=QUFLAG_NOTICE; |
1dd6d55d | 63 | |
64 | if (target==rup) { | |
65 | /* If you're changing yourself, you can give up the "status" flags and add/remove notice */ | |
347686bd | 66 | changemask|=(target->flags & (QUFLAG_OPER | QUFLAG_DEV | QUFLAG_PROTECT | QUFLAG_HELPER | QUFLAG_ADMIN | QUFLAG_STAFF)); |
1dd6d55d | 67 | } |
68 | ||
69 | /* Warning, policy ahead */ | |
70 | ||
c005651e CP |
71 | if (UHasStaffPriv(rup)) |
72 | changemask |= QUFLAG_PROTECT; | |
73 | ||
1dd6d55d | 74 | if (UHasOperPriv(rup)) |
f39514a3 | 75 | changemask |= QUFLAG_PROTECT | QUFLAG_TRUST | QCFLAG_NOINFO; |
1dd6d55d | 76 | |
77 | if (UHasAdminPriv(rup)) | |
347686bd | 78 | changemask |= (QUFLAG_OPER | QUFLAG_HELPER | QUFLAG_CLEANUPEXEMPT | QUFLAG_STAFF); |
1dd6d55d | 79 | |
80 | if (UIsDev(rup)) | |
81 | changemask=QUFLAG_ALL; | |
82 | ||
fbc4d9ed | 83 | wasorisoper = UHasOperPriv(target); |
1dd6d55d | 84 | setflags(&target->flags, changemask, cargv[arg], ruflags, REJECT_NONE); |
fbc4d9ed CP |
85 | wasorisoper |= UHasOperPriv(target); |
86 | ||
1dd6d55d | 87 | /* More policy */ |
c005651e | 88 | if (!UHasStaffPriv(target)) { |
1dd6d55d | 89 | target->flags &= ~QUFLAG_PROTECT; |
90 | } | |
91 | ||
92 | cs_log(sender,"USERFLAGS #%s %s (%s -> %s)",target->username,cargv[arg],flagbuf,printflags(target->flags, ruflags)); | |
8dfd270a CP |
93 | |
94 | /* only warn about interesting changes */ | |
8907f377 | 95 | if((target->flags ^ oldflags) & ~(QUFLAG_NOTICE | QUFLAG_INFO | QUFLAG_TRUST)) { |
8dfd270a CP |
96 | chanservwallmessage("%s (%s) just used USERFLAGS on %s %s (%s -> %s)",sender->nick,rup->username,target->username,cargv[arg],flagbuf,printflags(target->flags,ruflags)); |
97 | ||
e9f49ea9 | 98 | #ifdef AUTHGATE_WARNINGS |
fbc4d9ed CP |
99 | if(wasorisoper) |
100 | 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 |
101 | #endif |
102 | } | |
1dd6d55d | 103 | csdb_updateuser(target); |
3294b10b | 104 | |
de00c123 | 105 | /* Disabled this for now as live ircu doesn't support it - splidge |
3294b10b CP |
106 | if ((anp=findauthname(rup->ID))) |
107 | localusersetaccountflags(anp, cs_accountflagmap(target)); | |
de00c123 | 108 | */ |
109 | ||
1dd6d55d | 110 | chanservstdmessage(sender, QM_DONE); |
111 | } | |
112 | ||
113 | if (cs_privcheck(QPRIV_VIEWUSERFLAGS, sender)) | |
114 | flagmask=QUFLAG_ALL; | |
115 | else | |
347686bd | 116 | flagmask=QUFLAG_INFO | QUFLAG_NOTICE | QUFLAG_OPER | QUFLAG_HELPER | QUFLAG_DEV | QUFLAG_ADMIN | QUFLAG_STAFF; |
1dd6d55d | 117 | |
43583524 | 118 | chanservstdmessage(sender, QM_CURUSERFLAGS, target->username, printflagsornone(target->flags & flagmask, ruflags)); |
1dd6d55d | 119 | |
120 | return CMD_OK; | |
121 | } |