diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-09 14:48:14 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-09 14:48:14 +0000 |
commit | 2fddaaa4dbb63cbdb7b17a52ed50e67204cba272 (patch) | |
tree | 7d01ed28a65b801913fd593d61a017d89c139016 /src/commands.cpp | |
parent | 4d5738912ae8dfa7286393c3e86a2e7e2f16d17a (diff) |
Added preliminary remote WHOIS
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2287 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands.cpp')
-rw-r--r-- | src/commands.cpp | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/src/commands.cpp b/src/commands.cpp index a01f3a844..bc144dd51 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -824,61 +824,71 @@ void handle_time(char **parameters, int pcnt, userrec *user) void handle_whois(char **parameters, int pcnt, userrec *user) { userrec *dest; - - if (loop_call(handle_whois,parameters,pcnt,user,0,pcnt-1,0)) - return; + if (loop_call(handle_whois,parameters,pcnt,user,0,pcnt-1,0)) + return; dest = Find(parameters[0]); if (dest) { - // bug found by phidjit - were able to whois an incomplete connection if it had sent a NICK or USER - if (dest->registered == 7) + do_whois(user,dest,0,0,parameters[0]); + } + else + { + /* no such nick/channel */ + WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]); + WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, parameters[0]); + } +} + +void do_whois(userrec* user, userrec* dest,unsigned long signon, unsigned long idle, char* nick) +{ + // bug found by phidjit - were able to whois an incomplete connection if it had sent a NICK or USER + if (dest->registered == 7) + { + WriteServ(user->fd,"311 %s %s %s %s * :%s",user->nick, dest->nick, dest->ident, dest->dhost, dest->fullname); + if ((user == dest) || (strchr(user->modes,'o'))) { - WriteServ(user->fd,"311 %s %s %s %s * :%s",user->nick, dest->nick, dest->ident, dest->dhost, dest->fullname); - if ((user == dest) || (strchr(user->modes,'o'))) - { - WriteServ(user->fd,"378 %s %s :is connecting from *@%s %s",user->nick, dest->nick, dest->host, dest->ip); - } - char* cl = chlist(dest,user); - if (*cl) - { - WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, cl); - } - WriteServ(user->fd,"312 %s %s %s :%s",user->nick, dest->nick, dest->server, GetServerDescription(dest->server).c_str()); - if (*dest->awaymsg) + WriteServ(user->fd,"378 %s %s :is connecting from *@%s %s",user->nick, dest->nick, dest->host, dest->ip); + } + char* cl = chlist(dest,user); + if (*cl) + { + WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, cl); + } + WriteServ(user->fd,"312 %s %s %s :%s",user->nick, dest->nick, dest->server, GetServerDescription(dest->server).c_str()); + if (*dest->awaymsg) + { + WriteServ(user->fd,"301 %s %s :%s",user->nick, dest->nick, dest->awaymsg); + } + if (strchr(dest->modes,'o')) + { + if (*dest->oper) { - WriteServ(user->fd,"301 %s %s :%s",user->nick, dest->nick, dest->awaymsg); + WriteServ(user->fd,"313 %s %s :is %s %s on %s",user->nick, dest->nick, (strchr("aeiou",dest->oper[0]) ? "an" : "a"),dest->oper, Network); } - if (strchr(dest->modes,'o')) + else { - if (*dest->oper) - { - WriteServ(user->fd,"313 %s %s :is %s %s on %s",user->nick, dest->nick, (strchr("aeiou",dest->oper[0]) ? "an" : "a"),dest->oper, Network); - } - else - { - WriteServ(user->fd,"313 %s %s :is opered but has an unknown type",user->nick, dest->nick); - } + WriteServ(user->fd,"313 %s %s :is opered but has an unknown type",user->nick, dest->nick); } + } + if ((!signon) && (!idle)) + { FOREACH_MOD OnWhois(user,dest); - if (!strcasecmp(user->server,dest->server)) - { - // idle time and signon line can only be sent if youre on the same server (according to RFC) - WriteServ(user->fd,"317 %s %s %d %d :seconds idle, signon time",user->nick, dest->nick, abs((dest->idle_lastmsg)-TIME), dest->signon); - } - - WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, dest->nick); + } + if (!strcasecmp(user->server,dest->server)) + { + // idle time and signon line can only be sent if youre on the same server (according to RFC) + WriteServ(user->fd,"317 %s %s %d %d :seconds idle, signon time",user->nick, dest->nick, abs((dest->idle_lastmsg)-TIME), dest->signon); } else { - WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]); - WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, parameters[0]); + WriteServ(user->fd,"317 %s %s %d %d :seconds idle, signon time",user->nick, dest->nick, idle, signon); } + WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, dest->nick); } else { - /* no such nick/channel */ - WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]); - WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, parameters[0]); + WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, nick); + WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, nick); } } |