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 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
26 bool TreeSocket::Whois(const std::string &prefix, parameterlist ¶ms)
28 if (params.size() < 1)
30 User* u = ServerInstance->FindNick(prefix);
33 // an incoming request
34 if (params.size() == 1)
36 User* x = ServerInstance->FindNick(params[0]);
37 if ((x) && (IS_LOCAL(x)))
41 snprintf(signon, MAXBUF, "%lu", (unsigned long)x->signon);
42 snprintf(idle, MAXBUF, "%lu", (unsigned long)abs((long)((x->idle_lastmsg) - ServerInstance->Time())));
44 par.push_back(prefix);
45 par.push_back(signon);
47 // ours, we're done, pass it BACK
48 Utils->DoOneToOne(params[0], "IDLE", par, u->server);
52 // not ours pass it on
54 Utils->DoOneToOne(prefix, "IDLE", params, x->server);
57 else if (params.size() == 3)
59 std::string who_did_the_whois = params[0];
60 User* who_to_send_to = ServerInstance->FindNick(who_did_the_whois);
61 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
63 // an incoming reply to a whois we sent out
64 std::string nick_whoised = prefix;
65 unsigned long signon = atoi(params[1].c_str());
66 unsigned long idle = atoi(params[2].c_str());
67 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
69 ServerInstance->DoWhois(who_to_send_to, u, signon, idle, nick_whoised.c_str());
74 // not ours, pass it on
76 Utils->DoOneToOne(prefix, "IDLE", params, who_to_send_to->server);