]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_whowas.cpp
Spotted problem: must clear out all prefixes attached to a user when they quit or...
[user/henk/code/inspircd.git] / src / cmd_whowas.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include "inspircd_config.h"
18 #include "configreader.h"
19 #include "users.h"
20 #include "commands.h"
21
22 #include "commands/cmd_whowas.h"
23
24 void cmd_whowas::Handle (const char** parameters, int pcnt, userrec* user)
25 {
26         irc::whowas::whowas_users::iterator i = ServerInstance->whowas.find(parameters[0]);
27
28         if (i == ServerInstance->whowas.end())
29         {
30                 user->WriteServ("406 %s %s :There was no such nickname",user->nick,parameters[0]);
31         }
32         else
33         {
34                 irc::whowas::whowas_set* grp = i->second;
35                 if (grp->size())
36                 {
37                         for (irc::whowas::whowas_set::iterator ux = grp->begin(); ux != grp->end(); ux++)
38                         {
39                                 irc::whowas::WhoWasGroup* u = *ux;
40                                 time_t rawtime = u->signon;
41                                 tm *timeinfo;
42                                 char b[MAXBUF];
43         
44                                 timeinfo = localtime(&rawtime);
45                                 
46                                 /* XXX - 'b' could be only 25 chars long and then strlcpy() would terminate it for us too? */
47                                 strlcpy(b,asctime(timeinfo),MAXBUF);
48                                 b[24] = 0;
49
50                                 user->WriteServ("314 %s %s %s %s * :%s",user->nick,parameters[0],u->ident,u->dhost,u->gecos);
51                                 
52                                 if(*user->oper)
53                                         user->WriteServ("379 %s %s :was connecting from *@%s", user->nick, parameters[0], u->host);
54                                 
55                                 if(*ServerInstance->Config->HideWhoisServer && !(*user->oper))
56                                         user->WriteServ("312 %s %s %s :%s",user->nick,parameters[0], ServerInstance->Config->HideWhoisServer, b);
57                                 else
58                                         user->WriteServ("312 %s %s %s :%s",user->nick,parameters[0], u->server, b);
59                         }
60                 }
61                 else
62                 {
63                         user->WriteServ("406 %s %s :There was no such nickname",user->nick,parameters[0]);
64                 }
65         }
66         
67         user->WriteServ("369 %s %s :End of WHOWAS",user->nick,parameters[0]);
68 }