Added idletime to remote whois.
authorThiefMaster <thiefmaster@gamesurge.net>
Wed, 2 May 2007 15:52:28 +0000 (17:52 +0200)
committerMichael Poole <mdpoole@troilus.org>
Mon, 28 May 2007 18:46:25 +0000 (14:46 -0400)
src/hash.h
src/proto-p10.c
src/proto.h

index 4147aaed6c9b126c9c584aef781f1062d45637fb..a87956cee061d6d57def4b8102febd88a897445f 100644 (file)
@@ -116,6 +116,7 @@ struct userNode {
     long modes;                   /* user flags +isw etc... */
 
     time_t timestamp;             /* Time of last nick change */
+    time_t idle_since;
     struct server *uplink;        /* Server that user is connected to */
     struct modeList channels;     /* Vector of channels user is in */
 
index 49705cf17ca525f830545b8f6937f9e7a3318256..85bb122fa310e6d6721cef37149c2f908cd1f685 100644 (file)
@@ -965,6 +965,8 @@ static CMD_FUNC(cmd_whois)
         irc_numeric(from, RPL_WHOISACCOUNT, "%s %s :is logged in as", who->nick, who->handle_info->handle);
     if (IsHiddenHost(who) && who->handle_info && (IsOper(from) || from == who))
         irc_numeric(from, RPL_WHOISACTUALLY, "%s %s@%s %s :Actual user@host, Actual IP", who->nick, who->ident, who->hostname, irc_ntoa(&who->ip));
+    if (IsLocal(who) && !IsService(who) && (!IsNoIdle(who) || IsOper(from) || from == who))
+        irc_numeric(from, RPL_WHOISIDLE, "%s %ld %ld :seconds idle, signon time", who->nick, now - who->idle_since, who->timestamp);
 
     irc_numeric(from, RPL_ENDOFWHOIS, "%s :End of /WHOIS list", who->nick);
     return 1;
@@ -2107,6 +2109,7 @@ AddUser(struct server* uplink, const char *nick, const char *ident, const char *
     safestrncpy(uNode->numeric, numeric, sizeof(uNode->numeric));
     irc_p10_pton(&uNode->ip, realip);
     uNode->timestamp = timestamp;
+    uNode->idle_since = timestamp;
     modeList_init(&uNode->channels);
     uNode->uplink = uplink;
     if (++uNode->uplink->clients > uNode->uplink->max_clients) {
index e595522157cb474ceeeb341d18aeaae8b4b06e4e..451c181d3e727026a0c013d641371d627898fad6 100644 (file)
@@ -158,6 +158,7 @@ void irc_numeric(struct userNode *user, unsigned int num, const char *format, ..
 #define RPL_WHOISUSER           311
 #define RPL_WHOISSERVER         312
 #define RPL_WHOISOPERATOR       313
+#define RPL_WHOISIDLE           317
 #define RPL_ENDOFWHOIS          318
 #define RPL_WHOISCHANNELS       319
 #define RPL_WHOISACCOUNT        330