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 * ---------------------------------------------------
16 /** Handle /WHOIS. These command handlers can be reloaded by the core,
17 * and handle basic RFC1459 commands. Commands within modules work
18 * the same way, however, they can be fully unloaded, where these
21 class CommandWhois : public Command
24 /** Constructor for whois.
26 CommandWhois ( Module* parent) : Command(parent,"WHOIS",1) { Penalty = 2; syntax = "<nick>{,<nick>}"; }
28 * @param parameters The parameters to the comamnd
29 * @param pcnt The number of parameters passed to teh command
30 * @param user The user issuing the command
31 * @return A value from CmdResult to indicate command success or failure.
33 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
37 CmdResult CommandWhois::Handle (const std::vector<std::string>& parameters, User *user)
41 unsigned long idle = 0, signon = 0;
43 if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
48 * If 2 paramters are specified (/whois nick nick), ignore the first one like spanningtree
49 * does, and use the second one, otherwise, use the only paramter. -- djGrrr
51 if (parameters.size() > 1)
55 dest = ServerInstance->FindNickOnly(parameters[userindex]);
57 dest = ServerInstance->FindNick(parameters[userindex]);
62 * Okay. Umpteenth attempt at doing this, so let's re-comment...
63 * For local users (/w localuser), we show idletime if hidewhois is disabled
64 * For local users (/w localuser localuser), we always show idletime, hence parameters.size() > 1 check.
65 * For remote users (/w remoteuser), we do NOT show idletime
66 * For remote users (/w remoteuser remoteuser), spanningtree will handle calling do_whois, so we can ignore this case.
67 * Thanks to djGrrr for not being impatient while I have a crap day coding. :p -- w00t
69 if (IS_LOCAL(dest) && (ServerInstance->Config->HideWhoisServer.empty() || parameters.size() > 1))
71 idle = abs((long)((dest->idle_lastmsg)-ServerInstance->Time()));
72 signon = dest->signon;
75 ServerInstance->DoWhois(user,dest,signon,idle,parameters[userindex].c_str());
79 /* no such nick/channel */
80 user->WriteNumeric(401, "%s %s :No such nick/channel",user->nick.c_str(), !parameters[userindex].empty() ? parameters[userindex].c_str() : "*");
81 user->WriteNumeric(318, "%s %s :End of /WHOIS list.",user->nick.c_str(), parameters[userindex].empty() ? parameters[userindex].c_str() : "*");
90 COMMAND_INIT(CommandWhois)