Skip to content

Commit 423dee2

Browse files
ItsOnlyBinaryprawnsalad
authored andcommitted
Add whox support (#180)
* Add whox support * requested changed * handle account param better * no user account is string 0 * unrealircd op_level can be "n/a" * unify the different ways ircd's handle no op_level
1 parent d60894e commit 423dee2

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

src/client.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,11 @@ module.exports = class IrcClient extends EventEmitter {
656656
}
657657
});
658658

659-
client.raw('WHO', target);
659+
if (client.network.supports('whox')) {
660+
client.raw('WHO', target, '%cuhsnfdaor');
661+
} else {
662+
client.raw('WHO', target);
663+
}
660664
}
661665

662666

@@ -704,7 +708,7 @@ module.exports = class IrcClient extends EventEmitter {
704708
matchAction(match_regex, cb) {
705709
return this.match(match_regex, cb, 'action');
706710
}
707-
711+
708712
/**
709713
* Truncate a string into blocks of a set size
710714
*/
@@ -727,7 +731,7 @@ module.exports = class IrcClient extends EventEmitter {
727731
do {
728732
current_char_length = chars[end_index].length;
729733
current_block_length += current_char_length;
730-
734+
731735
// If character does not fit in a single block, include it in current block anyway
732736
// and split it later on by falling back to simple substring
733737
if (current_char_length > block_size) {

src/commands/handlers/misc.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,34 @@ var handlers = {
9999
});
100100
},
101101

102+
RPL_WHOSPCRPL: function(command) {
103+
var cache = this.cache('who');
104+
if (!cache.members) {
105+
cache.members = [];
106+
}
107+
var params = command.params;
108+
109+
// G = Gone, H = Here
110+
var is_away = params[6][0].toUpperCase() === 'G' ?
111+
true :
112+
false;
113+
114+
// Some ircd's use n/a for no level, unify them all to 0 for no level
115+
var op_level = !/^[0-9]+$/.test(params[9]) ? 0 : parseInt(params[9], 10);
116+
117+
cache.members.push({
118+
nick: params[5],
119+
ident: params[2],
120+
hostname: params[3],
121+
server: params[4],
122+
op_level: op_level,
123+
real_name: params[10],
124+
account: params[8] === '0' ? '' : params[8],
125+
away: is_away,
126+
num_hops_away: parseInt(params[7], 10),
127+
});
128+
},
129+
102130

103131
RPL_ENDOFWHO: function(command) {
104132
var cache = this.cache('who');

src/commands/numerics.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ module.exports = {
100100
'347': 'RPL_ENDOFINVITELIST',
101101
'352': 'RPL_WHOREPLY',
102102
'353': 'RPL_NAMEREPLY',
103+
'354': 'RPL_WHOSPCRPL',
103104
'364': 'RPL_LINKS',
104105
'365': 'RPL_ENDOFLINKS',
105106
'366': 'RPL_ENDOFNAMES',

0 commit comments

Comments
 (0)