Skip to content

Commit

Permalink
Merge pull request #364 from SadieCat/whoisactually
Browse files Browse the repository at this point in the history
Allow handlers to get access to the username from RPL_WHOISACTUALLY.
  • Loading branch information
ItsOnlyBinary authored Jul 16, 2023
2 parents a609363 + 9cd24f2 commit f2989ca
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/commands/handlers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,18 @@ const handlers = {
const cache_key = command.params[1].toLowerCase();
const cache = handler.cache('whois.' + cache_key);

// <source> 338 <target> <nick> <user>@<host> <ip> :Actual user@host, Actual IP
// <source> 338 <target> <nick> [<user>@]<host> <ip> :Actual user@host, Actual IP
const user_host = command.params[command.params.length - 3] || '';
const host = user_host.substring(user_host.indexOf('@') + 1);
const mask_sep = user_host.indexOf('@');
const user = user_host.substring(0, mask_sep) || undefined;
const host = user_host.substring(mask_sep + 1);
const ip = command.params[command.params.length - 2];

// UnrealIRCd uses this numeric for something else resulting in ip+host
// to be empty, so ignore this is that's the case
if (ip && host) {
cache.actual_ip = ip;
cache.actual_username = user;
cache.actual_hostname = host;
}
},
Expand All @@ -338,7 +341,7 @@ const handlers = {
// This exposes some fields (that may or may not be set).
// Valid keys that should always be set: nick, ident, hostname, real_name
// Valid optional keys: actual_ip, actual_hostname, account, server,
// server_info
// server_info, actual_username
// More optional fields MAY exist, depending on the type of ircd.
const cache_key = command.params[1].toLowerCase();
const cache = handler.cache('whois.' + cache_key);
Expand Down

0 comments on commit f2989ca

Please sign in to comment.