2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2011 Adam <Adam@anope.org>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "socketengine.h"
27 #include "treeserver.h"
28 #include "treesocket.h"
30 bool TreeSocket::Whois(const std::string &prefix, parameterlist ¶ms)
32 if (params.size() < 1)
34 User* u = ServerInstance->FindNick(prefix);
37 // an incoming request
38 if (params.size() == 1)
40 User* x = ServerInstance->FindNick(params[0]);
41 if ((x) && (IS_LOCAL(x)))
43 long idle = labs((long)((x->idle_lastmsg) - ServerInstance->Time()));
45 par.push_back(prefix);
46 par.push_back(ConvToStr(x->signon));
47 par.push_back(ConvToStr(idle));
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)) && (who_to_send_to->registered == REG_ALL))
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);