1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 #include "socketengine.h"
21 #include "treeserver.h"
22 #include "treesocket.h"
24 bool TreeSocket::Whois(const std::string &prefix, parameterlist ¶ms)
26 if (params.size() < 1)
28 User* u = ServerInstance->FindNick(prefix);
31 // an incoming request
32 if (params.size() == 1)
34 User* x = ServerInstance->FindNick(params[0]);
35 if ((x) && (IS_LOCAL(x)))
37 long idle = abs((long)((x->idle_lastmsg) - ServerInstance->Time()));
39 par.push_back(prefix);
40 par.push_back(ConvToStr(x->signon));
41 par.push_back(ConvToStr(idle));
42 // ours, we're done, pass it BACK
43 Utils->DoOneToOne(params[0], "IDLE", par, u->server);
47 // not ours pass it on
49 Utils->DoOneToOne(prefix, "IDLE", params, x->server);
52 else if (params.size() == 3)
54 std::string who_did_the_whois = params[0];
55 User* who_to_send_to = ServerInstance->FindNick(who_did_the_whois);
56 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
58 // an incoming reply to a whois we sent out
59 std::string nick_whoised = prefix;
60 unsigned long signon = atoi(params[1].c_str());
61 unsigned long idle = atoi(params[2].c_str());
62 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
64 ServerInstance->DoWhois(who_to_send_to, u, signon, idle, nick_whoised.c_str());
69 // not ours, pass it on
71 Utils->DoOneToOne(prefix, "IDLE", params, who_to_send_to->server);