1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
15 #include "commands/cmd_whois.h"
16 #include "commands/cmd_stats.h"
20 #include "transport.h"
21 #include "socketengine.h"
23 #include "m_spanningtree/main.h"
24 #include "m_spanningtree/utils.h"
25 #include "m_spanningtree/treeserver.h"
26 #include "m_spanningtree/treesocket.h"
28 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
30 bool TreeSocket::Whois(const std::string &prefix, std::deque<std::string> ¶ms)
32 if (params.size() < 1)
34 User* u = this->Instance->FindNick(prefix);
37 // an incoming request
38 if (params.size() == 1)
40 User* x = this->Instance->FindNick(params[0]);
41 if ((x) && (IS_LOCAL(x)))
45 snprintf(signon, MAXBUF, "%lu", (unsigned long)x->signon);
46 snprintf(idle, MAXBUF, "%lu", (unsigned long)abs((long)((x->idle_lastmsg) - Instance->Time())));
47 std::deque<std::string> par;
48 par.push_back(prefix);
49 par.push_back(signon);
51 // ours, we're done, pass it BACK
52 Utils->DoOneToOne(params[0], "IDLE", par, u->server);
56 // not ours pass it on
58 Utils->DoOneToOne(prefix, "IDLE", params, x->server);
61 else if (params.size() == 3)
63 std::string who_did_the_whois = params[0];
64 User* who_to_send_to = this->Instance->FindNick(who_did_the_whois);
65 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
67 // an incoming reply to a whois we sent out
68 std::string nick_whoised = prefix;
69 unsigned long signon = atoi(params[1].c_str());
70 unsigned long idle = atoi(params[2].c_str());
71 if ((who_to_send_to) && (IS_LOCAL(who_to_send_to)))
73 do_whois(this->Instance, who_to_send_to, u, signon, idle, nick_whoised.c_str());
78 // not ours, pass it on
80 Utils->DoOneToOne(prefix, "IDLE", params, who_to_send_to->server);