]>
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; | |
26 | int arg=0; | |
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 | |
59 | changemask=QUFLAG_NOTICE | QUFLAG_INFO; | |
60 | ||
61 | if (target==rup) { | |
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)); | |
64 | } | |
65 | ||
66 | /* Warning, policy ahead */ | |
67 | ||
68 | if (UHasOperPriv(rup)) | |
50ec21f3 | 69 | changemask |= QUFLAG_GLINE | QUFLAG_DELAYEDGLINE | QUFLAG_PROTECT | QUFLAG_TRUST | QCFLAG_NOINFO; |
1dd6d55d | 70 | |
71 | if (UHasAdminPriv(rup)) | |
e58b744c | 72 | changemask |= (QUFLAG_OPER | QUFLAG_HELPER | QUFLAG_CLEANUPEXEMPT); |
1dd6d55d | 73 | |
74 | if (UIsDev(rup)) | |
75 | changemask=QUFLAG_ALL; | |
76 | ||
77 | setflags(&target->flags, changemask, cargv[arg], ruflags, REJECT_NONE); | |
78 | ||
79 | /* More policy */ | |
80 | if (!UHasHelperPriv(target)) { | |
81 | target->flags &= ~QUFLAG_PROTECT; | |
82 | } | |
83 | ||
84 | cs_log(sender,"USERFLAGS #%s %s (%s -> %s)",target->username,cargv[arg],flagbuf,printflags(target->flags, ruflags)); | |
8dfd270a CP |
85 | |
86 | /* only warn about interesting changes */ | |
e9f49ea9 | 87 | if((target->flags ^ oldflags) & ~(QUFLAG_NOTICE | QUFLAG_INFO)) { |
8dfd270a CP |
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)); |
89 | ||
e9f49ea9 | 90 | #ifdef AUTHGATE_WARNINGS |
da6fc007 CP |
91 | if(UHasHelperPriv(target)) |
92 | chanservsendmessage(sender, "You MUST go to https://auth.quakenet.org and attempt to login as %s (with any password) to update the cache.",target->username); | |
e9f49ea9 CP |
93 | #endif |
94 | } | |
1dd6d55d | 95 | csdb_updateuser(target); |
96 | chanservstdmessage(sender, QM_DONE); | |
97 | } | |
98 | ||
99 | if (cs_privcheck(QPRIV_VIEWUSERFLAGS, sender)) | |
100 | flagmask=QUFLAG_ALL; | |
101 | else | |
102 | flagmask=QUFLAG_INFO | QUFLAG_NOTICE | QUFLAG_OPER | QUFLAG_HELPER | QUFLAG_DEV | QUFLAG_ADMIN; | |
103 | ||
43583524 | 104 | chanservstdmessage(sender, QM_CURUSERFLAGS, target->username, printflagsornone(target->flags & flagmask, ruflags)); |
1dd6d55d | 105 | |
106 | return CMD_OK; | |
107 | } |