]>
jfr.im git - irc/quakenet/newserv.git/blob - chanserv/usercmds/whois.c
5e733872728d246affde50bdd5bf867dfb38051d
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"
21 int csu_dowhois(void *source
, int cargc
, char **cargv
) {
23 reguser
*rup
=getreguserfromnick(sender
), *target
;
27 regchanuser
*rcup
, *rcup2
;
28 flag_t flagmask
, flags
;
33 if (!(rup
=getreguserfromnick(sender
)))
37 chanservstdmessage(sender
, QM_NOTENOUGHPARAMS
, "whois");
41 if (!(target
=findreguser(sender
, cargv
[0]))) {
44 if (cs_privcheck(QPRIV_VIEWFULLWHOIS
, sender
) && (np
=getnickbynick(cargv
[0]))) {
45 activeuser
*aup
=getactiveuserfromnick(np
);
46 chanservsendmessage(sender
, "%s has attempted to auth %d time%s.", np
->nick
, aup
->authattempts
,
47 aup
->authattempts
==1?"":"s");
52 if (cargv
[0][0]=='#') {
53 chanservstdmessage(sender
, QM_WHOISHEADER_AUTH
, target
->username
);
55 chanservstdmessage(sender
, QM_WHOISHEADER_NICK
, cargv
[0], target
->username
);
58 if (rup
==target
|| cs_privcheck(QPRIV_VIEWFULLWHOIS
, sender
)) {
59 chanservstdmessage(sender
, QM_WHOIS_USERID
, target
->ID
);
62 if (cs_privcheck(QPRIV_VIEWUSERFLAGS
, sender
)) {
66 chanservstdmessage(sender
, QM_USERISADMIN
, target
->username
);
67 else if (UIsOper(target
))
68 chanservstdmessage(sender
, QM_USERISOPER
, target
->username
);
69 else if (UIsHelper(target
))
70 chanservstdmessage(sender
, QM_USERISHELPER
, target
->username
);
73 chanservstdmessage(sender
, QM_USERISDEV
, target
->username
);
79 flagmask
|=(QUFLAG_OPER
| QUFLAG_DEV
| QUFLAG_HELPER
|
80 QUFLAG_ADMIN
| QUFLAG_INFO
| QUFLAG_NOTICE
);
82 if (flagmask
& target
->flags
)
83 chanservstdmessage(sender
, QM_WHOIS_FLAGS
, printflags(flagmask
& target
->flags
, ruflags
));
85 if (!(anp
=findauthname(target
->ID
)) || !anp
->nicks
) {
86 chanservstdmessage(sender
, QM_WHOIS_USERS
, "(none)");
88 for (tnp
=anp
->nicks
; ;tnp
=tnp
->nextbyauthname
) {
89 if (nbpos
>0 && (!tnp
|| nbpos
+strlen(tnp
->nick
) > 60)) {
90 chanservstdmessage(sender
, QM_WHOIS_USERS
, buf
);
97 nbpos
+=sprintf(buf
+nbpos
,"%s ",tnp
->nick
);
101 if (target
->created
) {
102 tmp
=gmtime(&(target
->created
));
103 strftime(buf
,15,"%d/%m/%y %H:%M",tmp
);
105 chanservstdmessage(sender
, QM_WHOIS_CREATED
, buf
);
108 if (target
->lastauth
== 0) {
109 snprintf(buf
,sizeof(buf
),"(never)");
111 tmp
=gmtime(&(target
->lastauth
));
112 strftime(buf
,15,"%d/%m/%y %H:%M",tmp
);
114 chanservstdmessage(sender
, QM_WHOIS_LASTAUTH
, buf
);
116 if (target
->lastuserhost
&& (rup
==target
|| cs_privcheck(QPRIV_VIEWFULLWHOIS
, sender
))) {
117 /* Commenting out language until we implement some - splidge
118 chanservstdmessage(sender, QM_WHOIS_USERLANG, cslanguages[target->languageid] ?
119 cslanguages[target->languageid]->name->content : "(unknown)"); */
120 chanservstdmessage(sender
, QM_WHOIS_LASTUSERHOST
, target
->lastuserhost
->content
);
123 if (target
->email
&& (rup
==target
|| cs_privcheck(QPRIV_VIEWEMAIL
, sender
))) {
124 chanservstdmessage(sender
, QM_WHOIS_EMAIL
, target
->email
->content
);
126 tmp
=gmtime(&(target
->lastemailchange
));
127 strftime(buf
,15,"%d/%m/%y %H:%M",tmp
);
129 chanservstdmessage(sender
, QM_WHOIS_EMAILSET
, buf
);
133 chanservstdmessage(sender
, QM_WHOIS_INFO
, target
->info
->content
);
136 if (target
->comment
&& (cs_privcheck(QPRIV_VIEWCOMMENTS
, sender
))) {
137 chanservstdmessage(sender
, QM_WHOIS_COMMENT
, target
->comment
->content
);
140 for (rcup
=target
->knownon
;rcup
;rcup
=rcup
->nextbyuser
) {
141 if (!UHasHelperPriv(rup
) || (UHasOperPriv(target
) && UHasHelperPriv(rup
) && !UHasOperPriv(rup
))) {
142 if (!(rcup2
=findreguseronchannel(rcup
->chan
,rup
)))
145 if (!CUHasVoicePriv(rcup2
))
148 flagmask
= (QCUFLAG_OWNER
| QCUFLAG_MASTER
| QCUFLAG_OP
| QCUFLAG_VOICE
| QCUFLAG_AUTOVOICE
|
149 QCUFLAG_AUTOOP
| QCUFLAG_TOPIC
);
151 if (CUHasMasterPriv(rcup2
))
152 flagmask
|= (QCUFLAG_DENY
| QCUFLAG_QUIET
| QCUFLAG_BANNED
);
154 flagmask
=QCUFLAG_ALL
;
157 if (!(flags
=rcup
->flags
& flagmask
))
162 chanservstdmessage(sender
, QM_WHOIS_CHANHEADER
, target
->username
);
165 chanservsendmessage(sender
, " %-30s %s",rcup
->chan
->index
->name
->content
,printflags(flags
, rcuflags
));
168 chanservstdmessage(sender
, QM_ENDOFLIST
);