]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/usercmds/whois.c
1 /* Automatically generated by refactor.pl.
5 * CMDLEVEL: QCMD_AUTHED
7 * CMDDESC: Displays information about a user.
9 * CMDPROTO: int csu_dowhois(void *source, int cargc, char **cargv);
10 * CMDHELP: Usage: WHOIS <user>
11 * CMDHELP: Displays information about a user, where:
12 * CMDHELP: user - user to request information for, either the nickname of an active user on
13 * CMDHELP: the network or #accountname.
16 #include "../chanserv.h"
17 #include "../../lib/irc_string.h"
18 #include "../../lib/strlfunc.h"
22 int csu_dowhois(void *source
, int cargc
, char **cargv
) {
24 reguser
*rup
=getreguserfromnick(sender
), *target
;
28 regchanuser
*rcup
, *rcup2
;
29 flag_t flagmask
, flags
;
34 if (!(rup
=getreguserfromnick(sender
)))
38 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "whois");
42 if (!(target
=findreguser(sender
, cargv
[0]))) {
45 if (cs_privcheck(QPRIV_VIEWFULLWHOIS
, sender
) && (np
=getnickbynick(cargv
[0]))) {
46 activeuser
*aup
=getactiveuserfromnick(np
);
47 chanservsendmessage(sender
, "%s has attempted to auth %d time%s.", np
->nick
, aup
->authattempts
,
48 aup
->authattempts
==1?"":"s");
53 if (cargv
[0][0]=='#') {
54 chanservstdmessage(sender
, QM_WHOISHEADER_AUTH
, target
->username
);
56 chanservstdmessage(sender
, QM_WHOISHEADER_NICK
, cargv
[0], target
->username
);
59 if (rup
==target
|| cs_privcheck(QPRIV_VIEWFULLWHOIS
, sender
)) {
60 chanservstdmessage(sender
, QM_WHOIS_USERID
, target
->ID
);
63 if (cs_privcheck(QPRIV_VIEWUSERFLAGS
, sender
)) {
64 flagmask
=QUFLAG_ALL
& ~(QUFLAG_SUSPENDED
| QUFLAG_GLINE
| QUFLAG_DELAYEDGLINE
);
68 if (UHasSuspension(target
)) {
69 char expiresbuf
[100], timebuf
[100];
70 char *reason
, *suspendtype
, *whom
;
72 if(UIsDelayedGline(target
)) {
73 suspendtype
= "delayed gline";
74 } else if(UIsGline(target
)) {
75 suspendtype
= "gline";
76 } else if(UIsSuspended(target
)) {
77 suspendtype
= "suspended";
82 if(target
->suspendexp
) {
83 if(time(NULL
) >= target
->suspendexp
) {
84 strlcpy(expiresbuf
, "(next auth)", sizeof(expiresbuf
));
86 strftime(expiresbuf
, 15, "%d/%m/%y %H:%M", gmtime(&(target
->suspendexp
)));
89 strlcpy(expiresbuf
, "(never)", sizeof(expiresbuf
));
91 strftime(timebuf
, 15, "%d/%m/%y %H:%M", gmtime(&(target
->suspendtime
)));
93 if(UHasOperPriv(rup
)) {
94 reguser
*trup
= findreguserbyID(target
->suspendby
);
96 whom
= trup
->username
;
104 if(target
->suspendreason
&& target
->suspendreason
->content
) {
105 reason
= target
->suspendreason
->content
;
110 chanservstdmessage(sender
, QM_USERSUSPENDEDTYPE
, suspendtype
);
111 chanservstdmessage(sender
, QM_USERSUSPENDEDBY
, whom
);
112 chanservstdmessage(sender
, QM_USERSUSPENDEDREASON
, reason
);
113 chanservstdmessage(sender
, QM_USERSUSPENDEDAT
, timebuf
);
114 chanservstdmessage(sender
, QM_USERSUSPENDEDEXPIRY
, expiresbuf
);
117 /* Incidentally none of the QM_USERIS* mesages take parameters. Just thought I'd mention it.. */
118 if (UIsAdmin(target
))
119 chanservstdmessage(sender
, QM_USERISADMIN
, target
->username
);
120 else if (UIsOper(target
))
121 chanservstdmessage(sender
, QM_USERISOPER
, target
->username
);
122 else if (UIsHelper(target
))
123 chanservstdmessage(sender
, QM_USERISHELPER
, target
->username
);
124 else if (UIsStaff(target
))
125 chanservstdmessage(sender
, QM_USERISSTAFF
, target
->username
);
128 chanservstdmessage(sender
, QM_USERISDEV
, target
->username
);
134 flagmask
|=(QUFLAG_OPER
| QUFLAG_DEV
| QUFLAG_HELPER
|
135 QUFLAG_ADMIN
| QUFLAG_INFO
| QUFLAG_NOTICE
| QUFLAG_STAFF
);
137 if (flagmask
& target
->flags
)
138 chanservstdmessage(sender
, QM_WHOIS_FLAGS
, printflagsornone(flagmask
& target
->flags
, ruflags
));
140 if (!(anp
=findauthname(target
->ID
)) || !anp
->nicks
) {
141 chanservstdmessage(sender
, QM_WHOIS_USERS
, "(none)");
143 for (tnp
=anp
->nicks
; ;tnp
=tnp
->nextbyauthname
) {
144 if (nbpos
>0 && (!tnp
|| nbpos
+strlen(tnp
->nick
) > 60)) {
145 chanservstdmessage(sender
, QM_WHOIS_USERS
, buf
);
152 nbpos
+=sprintf(buf
+nbpos
,"%s ",tnp
->nick
);
156 if (target
->created
) {
157 tmp
=gmtime(&(target
->created
));
158 strftime(buf
,15,"%d/%m/%y %H:%M",tmp
);
160 chanservstdmessage(sender
, QM_WHOIS_CREATED
, buf
);
163 if (target
->lastauth
== 0) {
164 snprintf(buf
,sizeof(buf
),"(never)");
166 tmp
=gmtime(&(target
->lastauth
));
167 strftime(buf
,15,"%d/%m/%y %H:%M",tmp
);
169 chanservstdmessage(sender
, QM_WHOIS_LASTAUTH
, buf
);
171 if (target
->lastuserhost
&& (rup
==target
|| cs_privcheck(QPRIV_VIEWFULLWHOIS
, sender
))) {
172 /* Commenting out language until we implement some - splidge
173 chanservstdmessage(sender, QM_WHOIS_USERLANG, cslanguages[target->languageid] ?
174 cslanguages[target->languageid]->name->content : "(unknown)"); */
175 chanservstdmessage(sender
, QM_WHOIS_LASTUSERHOST
, target
->lastuserhost
->content
);
178 if (target
->email
&& (rup
==target
|| cs_privcheck(QPRIV_VIEWEMAIL
, sender
))) {
179 chanservstdmessage(sender
, QM_WHOIS_EMAIL
, target
->email
->content
);
181 tmp
=gmtime(&(target
->lastemailchange
));
182 strftime(buf
,15,"%d/%m/%y %H:%M",tmp
);
184 chanservstdmessage(sender
, QM_WHOIS_EMAILSET
, buf
);
187 if (target
->info
&& *target
->info
->content
) {
188 chanservstdmessage(sender
, QM_WHOIS_INFO
, target
->info
->content
);
191 if (target
->comment
&& (cs_privcheck(QPRIV_VIEWCOMMENTS
, sender
))) {
192 chanservstdmessage(sender
, QM_WHOIS_COMMENT
, target
->comment
->content
);
195 for (rcup
=target
->knownon
;rcup
;rcup
=rcup
->nextbyuser
) {
196 if (!UHasHelperPriv(rup
) || (UHasOperPriv(target
) && UHasHelperPriv(rup
) && !UHasOperPriv(rup
))) {
197 if (!(rcup2
=findreguseronchannel(rcup
->chan
,rup
)))
203 flagmask
= (QCUFLAG_OWNER
| QCUFLAG_MASTER
| QCUFLAG_OP
| QCUFLAG_VOICE
| QCUFLAG_AUTOVOICE
|
204 QCUFLAG_AUTOOP
| QCUFLAG_TOPIC
| QCUFLAG_KNOWN
| QCUFLAG_PROTECT
);
206 if (CUHasMasterPriv(rcup2
))
207 flagmask
|= QCUFLAGS_PUNISH
;
210 flagmask
|= QCUFLAGS_PERSONAL
;
212 flagmask
=QCUFLAG_ALL
;
215 if (!(flags
=rcup
->flags
& flagmask
))
220 chanservstdmessage(sender
, QM_WHOIS_CHANHEADER
, target
->username
);
223 chanservsendmessage(sender
, " %-30s %s",rcup
->chan
->index
->name
->content
,printflags(flags
, rcuflags
));
227 chanservstdmessage(sender
, QM_ENDOFLIST
);