1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 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 "../transport.h"
18 #include "socketengine.h"
22 #include "treeserver.h"
23 #include "treesocket.h"
25 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
27 bool TreeSocket::Whois(const std::string &prefix, parameterlist ¶ms)
29 if (params.size() < 1)
31 User* u = ServerInstance->FindNick(prefix);
34 // an incoming request
35 if (params.size() == 1)
37 User* x = ServerInstance->FindNick(params[0]);
38 if ((x) && (IS_LOCAL(x)))
42 snprintf(signon, MAXBUF, "%lu", (unsigned long)x->signon);
43 snprintf(idle, MAXBUF, "%lu", (unsigned long)abs((long)((x->idle_lastmsg) - ServerInstance->Time())));
45 par.push_back(prefix);
46 par.push_back(signon);
48 // ours, we're done, pass it BACK
49 Utils->DoOneToOne(params[0], "IDLE", par, u->server);
53 // not ours pass it on
55 Utils->DoOneToOne(prefix, "IDLE", params, x->server);
58 else if (params.size() == 3)
60 std::string who_did_the_whois = params[0];
61 User* who_to_send_to = ServerInstance->FindNick(who_did_the_whois);
62 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
64 // an incoming reply to a whois we sent out
65 std::string nick_whoised = prefix;
66 unsigned long signon = atoi(params[1].c_str());
67 unsigned long idle = atoi(params[2].c_str());
68 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
70 ServerInstance->DoWhois(who_to_send_to, u, signon, idle, nick_whoised.c_str());
75 // not ours, pass it on
77 Utils->DoOneToOne(prefix, "IDLE", params, who_to_send_to->server);