+
+ bool Whois(std::string prefix, std::deque<std::string> ¶ms)
+ {
+ if (params.size() < 1)
+ return true;
+ log(DEBUG,"In IDLE command");
+ userrec* u = Srv->FindNick(prefix);
+ if (u)
+ {
+ log(DEBUG,"USER EXISTS: %s",u->nick);
+ // an incoming request
+ if (params.size() == 1)
+ {
+ userrec* x = Srv->FindNick(params[0]);
+ if ((x) && (x->fd > -1))
+ {
+ userrec* x = Srv->FindNick(params[0]);
+ log(DEBUG,"Got IDLE");
+ char signon[MAXBUF];
+ char idle[MAXBUF];
+ log(DEBUG,"Sending back IDLE 3");
+ snprintf(signon,MAXBUF,"%lu",(unsigned long)x->signon);
+ snprintf(idle,MAXBUF,"%lu",(unsigned long)abs((x->idle_lastmsg)-time(NULL)));
+ std::deque<std::string> par;
+ par.push_back(prefix);
+ par.push_back(signon);
+ par.push_back(idle);
+ // ours, we're done, pass it BACK
+ DoOneToOne(params[0],"IDLE",par,u->server);
+ }
+ else
+ {
+ // not ours pass it on
+ DoOneToOne(prefix,"IDLE",params,x->server);
+ }
+ }
+ else if (params.size() == 3)
+ {
+ std::string who_did_the_whois = params[0];
+ userrec* who_to_send_to = Srv->FindNick(who_did_the_whois);
+ if ((who_to_send_to) && (who_to_send_to->fd > -1))
+ {
+ log(DEBUG,"Got final IDLE");
+ // an incoming reply to a whois we sent out
+ std::string nick_whoised = prefix;
+ unsigned long signon = atoi(params[1].c_str());
+ unsigned long idle = atoi(params[2].c_str());
+ if ((who_to_send_to) && (who_to_send_to->fd > -1))
+ do_whois(who_to_send_to,u,signon,idle,(char*)nick_whoised.c_str());
+ }
+ else
+ {
+ // not ours, pass it on
+ DoOneToOne(prefix,"IDLE",params,who_to_send_to->server);
+ }
+ }
+ }
+ return true;
+ }