1 var _
= require('lodash'),
10 '005': 'RPL_ISUPPORT',
13 '250': 'RPL_STATSCONN',
14 '251': 'RPL_LUSERCLIENT',
16 '253': 'RPL_LUSERUNKNOWN',
17 '254': 'RPL_LUSERCHANNELS',
19 '265': 'RPL_LOCALUSERS',
20 '266': 'RPL_GLOBALUSERS',
22 '307': 'RPL_WHOISREGNICK',
23 '311': 'RPL_WHOISUSER',
24 '312': 'RPL_WHOISSERVER',
25 '313': 'RPL_WHOISOPERATOR',
26 '317': 'RPL_WHOISIDLE',
27 '318': 'RPL_ENDOFWHOIS',
28 '319': 'RPL_WHOISCHANNELS',
29 '321': 'RPL_LISTSTART',
34 '333': 'RPL_TOPICWHOTIME',
35 '353': 'RPL_NAMEREPLY',
37 '365': 'RPL_ENDOFLINKS',
38 '366': 'RPL_ENDOFNAMES',
40 '368': 'RPL_ENDOFBANLIST',
42 '375': 'RPL_MOTDSTART',
43 '376': 'RPL_ENDOFMOTD',
44 '379': 'RPL_WHOISMODES',
45 '401': 'ERR_NOSUCHNICK',
46 '404': 'ERR_CANNOTSENDTOCHAN',
47 '405': 'ERR_TOOMANYCHANNELS',
48 '421': 'ERR_UNKNOWNCOMMAND',
50 '432': 'ERR_ERRONEUSNICKNAME',
51 '433': 'ERR_NICKNAMEINUSE',
52 '441': 'ERR_USERNOTINCHANNEL',
53 '442': 'ERR_NOTONCHANNEL',
54 '451': 'ERR_NOTREGISTERED',
55 '464': 'ERR_PASSWDMISMATCH',
56 '470': 'ERR_LINKCHANNEL',
57 '471': 'ERR_CHANNELISFULL',
58 '473': 'ERR_INVITEONLYCHAN',
59 '474': 'ERR_BANNEDFROMCHAN',
60 '475': 'ERR_BADCHANNELKEY',
61 '481': 'ERR_NOPRIVILEGES',
62 '482': 'ERR_CHANOPRIVSNEEDED',
63 '670': 'RPL_STARTTLS',
64 '900': 'RPL_SASLAUTHENTICATED',
65 '903': 'RPL_SASLLOGGEDIN',
66 '904': 'ERR_SASLNOTAUTHORISED',
67 '906': 'ERR_SASLABORTED',
68 '907': 'ERR_SASLALREADYAUTHED'
72 IrcCommands = function (irc_connection
, con_num
, client
) {
73 this.irc_connection
= irc_connection
;
74 this.con_num
= con_num
;
77 module
.exports
= IrcCommands
;
79 IrcCommands
.prototype.dispatch = function (command
, data
) {
81 if (irc_numerics
[command
]) {
82 command
= irc_numerics
[command
];
84 if (handlers
[command
]) {
85 handlers
[command
].call(this, data
);
87 unknownCommand(command
, data
);
91 IrcCommands
.addHandler = function (command
, handler
) {
92 if (typeof handler
!== 'function') {
95 handlers
[command
] = handler
;
98 IrcCommands
.addNumeric = function (numeric
, handler_name
) {
99 irc_numerics
[numeric
+ ''] = handler_name
+'';
102 unknownCommand = function (command
, data
) {
103 // TODO: Do something here, log?
108 'RPL_WELCOME': function (command
) {
109 var nick
= command
.params
[0];
110 this.irc_connection
.registered
= true;
111 this.cap_negotation
= false;
112 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' connect', {
117 'RPL_ISUPPORT': function (command
) {
118 var options
, i
, option
, matches
, j
;
119 options
= command
.params
;
120 for (i
= 1; i
< options
.length
; i
++) {
121 option
= options
[i
].split("=", 2);
122 option
[0] = option
[0].toUpperCase();
123 this.irc_connection
.options
[option
[0]] = (typeof option
[1] !== 'undefined') ? option
[1] : true;
124 if (_
.include(['NETWORK', 'PREFIX', 'CHANTYPES', 'CHANMODES', 'NAMESX'], option
[0])) {
125 if (option
[0] === 'PREFIX') {
126 matches
= /\(([^)]*)\)(.*)/.exec(option
[1]);
127 if ((matches
) && (matches
.length
=== 3)) {
128 this.irc_connection
.options
.PREFIX
= [];
129 for (j
= 0; j
< matches
[2].length
; j
++) {
130 this.irc_connection
.options
.PREFIX
.push({symbol
: matches
[2].charAt(j
), mode
: matches
[1].charAt(j
)});
133 } else if (option
[0] === 'CHANTYPES') {
134 this.irc_connection
.options
.CHANTYPES
= this.irc_connection
.options
.CHANTYPES
.split('');
135 } else if (option
[0] === 'CHANMODES') {
136 this.irc_connection
.options
.CHANMODES
= option
[1].split(',');
137 } else if ((option
[0] === 'NAMESX') && (!_
.contains(this.irc_connection
.cap
.enabled
, 'multi-prefix'))) {
138 this.irc_connection
.write('PROTOCTL NAMESX');
142 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' options', {
143 options
: this.irc_connection
.options
,
144 cap
: this.irc_connection
.cap
.enabled
148 'RPL_ENDOFWHOIS': function (command
) {
149 this.irc_connection
.emit('user ' + command
.params
[1] + ' endofwhois', {
150 nick
: command
.params
[1],
151 msg
: command
.trailing
155 'RPL_AWAY': function (command
) {
156 this.irc_connection
.emit('user ' + command
.params
[1] + ' whoisaway', {
157 nick
: command
.params
[1],
158 reason
: command
.trailing
162 'RPL_WHOISUSER': function (command
) {
163 this.irc_connection
.emit('user ' + command
.params
[1] + ' whoisuser', {
164 nick
: command
.params
[1],
165 ident
: command
.params
[2],
166 host
: command
.params
[3],
167 msg
: command
.trailing
171 'RPL_WHOISSERVER': function (command
) {
172 this.irc_connection
.emit('user ' + command
.params
[1] + ' whoisserver', {
173 nick
: command
.params
[1],
174 irc_server
: command
.params
[2]
178 'RPL_WHOISOPERATOR': function (command
) {
179 this.irc_connection
.emit('user ' + command
.params
[1] + ' whoisoperator', {
180 nick
: command
.params
[1],
181 msg
: command
.trailing
185 'RPL_WHOISCHANNELS': function (command
) {
186 this.irc_connection
.emit('user ' + command
.params
[1] + ' whoischannels', {
187 nick
: command
.params
[1],
188 chans
: command
.trailing
192 'RPL_WHOISMODES': function (command
) {
193 this.irc_connection
.emit('user ' + command
.params
[1] + ' whoismodes', {
194 nick
: command
.params
[1],
195 msg
: command
.trailing
199 'RPL_WHOISIDLE': function (command
) {
200 this.irc_connection
.emit('user ' + command
.params
[1] + ' whoisidle', {
201 nick
: command
.params
[1],
202 idle
: command
.params
[2],
203 logon
: command
.params
[3] || undefined
207 'RPL_WHOISREGNICK': function (command
) {
208 this.irc_connection
.emit('user ' + command
.params
[1] + ' whoisregnick', {
209 nick
: command
.params
[1],
210 msg
: command
.trailing
214 'RPL_LISTSTART': function (command
) {
215 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' list_start', {});
218 'RPL_LISTEND': function (command
) {
219 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' list_end', {});
222 'RPL_LIST': function (command
) {
223 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' list_channel', {
224 channel
: command
.params
[1],
225 num_users
: parseInt(command
.params
[2], 10),
226 topic
: command
.trailing
230 'RPL_MOTD': function (command
) {
231 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' motd', {
232 motd
: command
.trailing
+ '\n'
236 'RPL_MOTDSTART': function (command
) {
237 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' motd_start', {});
240 'RPL_ENDOFMOTD': function (command
) {
241 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' motd_end', {});
244 'RPL_NAMEREPLY': function (command
) {
245 var members
= command
.trailing
.split(' ');
246 var member_list
= [];
249 _
.each(members
, function (member
) {
250 var j
, k
, modes
= [];
252 // Make sure we have some prefixes already
253 if (that
.irc_connection
.options
.PREFIX
) {
254 for (j
= 0; j
< member
.length
; j
++) {
255 for (k
= 0; k
< that
.irc_connection
.options
.PREFIX
.length
; k
++) {
256 if (member
.charAt(j
) === that
.irc_connection
.options
.PREFIX
[k
].symbol
) {
257 modes
.push(that
.irc_connection
.options
.PREFIX
[k
].mode
);
264 member_list
.push({nick
: member
, modes
: modes
});
267 this.irc_connection
.emit('channel ' + command
.params
[2] + ' userlist', {
269 channel
: command
.params
[2]
273 'RPL_ENDOFNAMES': function (command
) {
274 this.irc_connection
.emit('channel ' + command
.params
[1] + ' userlist_end', {
275 channel
: command
.params
[1]
279 'RPL_BANLIST': function (command
) {
280 this.irc_connection
.emit('channel ' + command
.params
[1] + ' banlist', {
281 channel
: command
.params
[1],
282 banned
: command
.params
[2],
283 banned_by
: command
.params
[3],
284 banned_at
: command
.params
[4]
288 'RPL_ENDOFBANLIST': function (command
) {
289 this.irc_connection
.emit('channel ' + command
.params
[1] + ' banlist_end', {
290 channel
: command
.params
[1]
294 'RPL_TOPIC': function (command
) {
295 this.irc_connection
.emit('channel ' + command
.params
[1] + ' topic', {
296 channel
: command
.params
[1],
297 topic
: command
.trailing
301 'RPL_NOTOPIC': function (command
) {
302 this.irc_connection
.emit('channel ' + command
.params
[1] + ' topic', {
303 channel
: command
.params
[1],
308 'RPL_TOPICWHOTIME': function (command
) {
309 this.irc_connection
.emit('channel ' + command
.params
[1] + ' topicsetby', {
310 nick
: command
.params
[2],
311 channel
: command
.params
[1],
312 when
: command
.params
[3]
316 'PING': function (command
) {
317 this.irc_connection
.write('PONG ' + command
.trailing
);
320 'JOIN': function (command
) {
322 if (typeof command
.trailing
=== 'string' && command
.trailing
!== '') {
323 channel
= command
.trailing
;
324 } else if (typeof command
.params
[0] === 'string' && command
.params
[0] !== '') {
325 channel
= command
.params
[0];
328 this.irc_connection
.emit('channel ' + channel
+ ' join', {
330 ident
: command
.ident
,
331 hostname
: command
.hostname
,
336 'PART': function (command
) {
337 this.irc_connection
.emit('channel ' + command
.params
[0] + ' part', {
339 ident
: command
.ident
,
340 hostname
: command
.hostname
,
341 channel
: command
.params
[0],
342 message
: command
.trailing
346 'KICK': function (command
) {
347 this.irc_connection
.emit('channel ' + command
.params
[0] + ' kick', {
348 kicked
: command
.params
[1],
350 ident
: command
.ident
,
351 hostname
: command
.hostname
,
352 channel
: command
.params
[0],
353 message
: command
.trailing
357 'QUIT': function (command
) {
358 this.irc_connection
.emit('user ' + command
.nick
+ ' quit', {
360 ident
: command
.ident
,
361 hostname
: command
.hostname
,
362 message
: command
.trailing
366 'NOTICE': function (command
) {
369 if ((command
.trailing
.charAt(0) === String
.fromCharCode(1)) && (command
.trailing
.charAt(command
.trailing
.length
- 1) === String
.fromCharCode(1))) {
370 // It's a CTCP response
371 namespace = (command
.params
[0] == this.irc_connection
.nick
) ? 'user' : 'channel';
372 this.irc_connection
.emit(namespace + ' ' + command
.params
[0] + ' ctcp_response', {
374 ident
: command
.ident
,
375 hostname
: command
.hostname
,
376 channel
: command
.params
[0],
377 msg
: command
.trailing
.substr(1, command
.trailing
.length
- 2)
380 namespace = (command
.params
[0] == this.irc_connection
.nick
|| command
.params
[0] == '*') ?
384 this.irc_connection
.emit(namespace + ' ' + command
.params
[0] + ' notice', {
385 from_server
: command
.prefix
? true : false,
386 nick
: command
.nick
|| command
.prefix
|| undefined,
387 ident
: command
.ident
,
388 hostname
: command
.hostname
,
389 target
: command
.params
[0],
390 msg
: command
.trailing
395 'NICK': function (command
) {
396 this.irc_connection
.emit('user ' + command
.nick
+ ' nick', {
398 ident
: command
.ident
,
399 hostname
: command
.hostname
,
400 newnick
: command
.trailing
|| command
.params
[0]
404 'TOPIC': function (command
) {
405 // If we don't have an associated channel, no need to continue
406 if (!command
.params
[0]) return;
408 var channel
= command
.params
[0],
409 topic
= command
.trailing
|| '';
411 this.irc_connection
.emit('channel ' + channel
+ ' topic', {
418 'MODE': function (command
) {
419 var chanmodes
= this.irc_connection
.options
.CHANMODES
|| [],
420 prefixes
= this.irc_connection
.options
.PREFIX
|| [],
421 always_param
= (chanmodes
[0] || '').concat((chanmodes
[1] || '')),
423 has_param
, i
, j
, add
, event
;
425 prefixes
= _
.reduce(prefixes
, function (list
, prefix
) {
426 list
.push(prefix
.mode
);
429 always_param
= always_param
.split('').concat(prefixes
);
431 has_param = function (mode
, add
) {
432 if (_
.find(always_param
, function (m
) {
436 } else if (add
&& _
.find((chanmodes
[2] || '').split(''), function (m
) {
445 if (!command
.params
[1]) {
446 command
.params
[1] = command
.trailing
;
450 for (i
= 0; i
< command
.params
[1].length
; i
++) {
451 switch (command
.params
[1][i
]) {
459 if (has_param(command
.params
[1][i
], add
)) {
460 modes
.push({mode
: (add
? '+' : '-') + command
.params
[1][i
], param
: command
.params
[2 + j
]});
463 modes
.push({mode
: (add
? '+' : '-') + command
.params
[1][i
], param
: null});
468 event
= (_
.contains(this.irc_connection
.options
.CHANTYPES
, command
.params
[0][0]) ? 'channel ' : 'user ') + command
.params
[0] + ' mode';
470 this.irc_connection
.emit(event
, {
471 target
: command
.params
[0],
472 nick
: command
.nick
|| command
.prefix
|| '',
477 'PRIVMSG': function (command
) {
479 if ((command
.trailing
.charAt(0) === String
.fromCharCode(1)) && (command
.trailing
.charAt(command
.trailing
.length
- 1) === String
.fromCharCode(1))) {
481 if (command
.trailing
.substr(1, 6) === 'ACTION') {
482 this.client
.sendIrcCommand('action', {server
: this.con_num
, nick
: command
.nick
, ident
: command
.ident
, hostname
: command
.hostname
, channel
: command
.params
[0], msg
: command
.trailing
.substr(7, command
.trailing
.length
- 2)});
483 } else if (command
.trailing
.substr(1, 4) === 'KIWI') {
484 tmp
= command
.trailing
.substr(6, command
.trailing
.length
- 2);
485 namespace = tmp
.split(' ', 1)[0];
486 this.client
.sendIrcCommand('kiwi', {server
: this.con_num
, namespace: namespace, data
: tmp
.substr(namespace.length
+ 1)});
487 } else if (command
.trailing
.substr(1, 7) === 'VERSION') {
488 this.irc_connection
.write('NOTICE ' + command
.nick
+ ' :' + String
.fromCharCode(1) + 'VERSION KiwiIRC' + String
.fromCharCode(1));
489 } else if (command
.trailing
.substr(1, 6) === 'SOURCE') {
490 this.irc_connection
.write('NOTICE ' + command
.nick
+ ' :' + String
.fromCharCode(1) + 'SOURCE http://www.kiwiirc.com/' + String
.fromCharCode(1));
491 } else if (command
.trailing
.substr(1, 10) === 'CLIENTINFO') {
492 this.irc_connection
.write('NOTICE ' + command
.nick
+ ' :' + String
.fromCharCode(1) + 'CLIENTINFO SOURCE VERSION TIME' + String
.fromCharCode(1));
494 namespace = (command
.params
[0].toLowerCase() == this.irc_connection
.nick
.toLowerCase()) ? 'user' : 'channel';
495 this.irc_connection
.emit(namespace + ' ' + command
.nick
+ ' ctcp_request', {
497 ident
: command
.ident
,
498 hostname
: command
.hostname
,
499 target
: command
.params
[0],
500 type
: (command
.trailing
.substr(1, command
.trailing
.length
- 2).split(' ') || [null])[0],
501 msg
: command
.trailing
.substr(1, command
.trailing
.length
- 2)
505 // A message to a user (private message) or to a channel?
506 namespace = (command
.params
[0] === this.irc_connection
.nick
) ? 'user ' + command
.nick
: 'channel ' + command
.params
[0];
507 this.irc_connection
.emit(namespace + ' privmsg', {
509 ident
: command
.ident
,
510 hostname
: command
.hostname
,
511 channel
: command
.params
[0],
512 msg
: command
.trailing
517 'CAP': function (command
) {
518 // TODO: capability modifiers
519 // i.e. - for disable, ~ for requires ACK, = for sticky
520 var capabilities
= command
.trailing
.replace(/[\-~=]/, '').split(' ');
523 // Which capabilities we want to enable
524 var want
= ['multi-prefix', 'away-notify'];
526 if (this.irc_connection
.password
) {
530 switch (command
.params
[1]) {
532 // Compute which of the available capabilities we want and request them
533 request
= _
.intersection(capabilities
, want
);
534 if (request
.length
> 0) {
535 this.irc_connection
.cap
.requested
= request
;
536 this.irc_connection
.write('CAP REQ :' + request
.join(' '));
538 this.irc_connection
.write('CAP END');
539 this.irc_connection
.cap_negotation
= false;
543 if (capabilities
.length
> 0) {
544 // Update list of enabled capabilities
545 this.irc_connection
.cap
.enabled
= capabilities
;
546 // Update list of capabilities we would like to have but that aren't enabled
547 this.irc_connection
.cap
.requested
= _
.difference(this.irc_connection
.cap
.requested
, capabilities
);
549 if (this.irc_connection
.cap
.enabled
.length
> 0) {
550 if (_
.contains(this.irc_connection
.cap
.enabled
, 'sasl')) {
551 this.irc_connection
.sasl
= true;
552 this.irc_connection
.write('AUTHENTICATE PLAIN');
554 this.irc_connection
.write('CAP END');
555 this.irc_connection
.cap_negotation
= false;
560 if (capabilities
.length
> 0) {
561 this.irc_connection
.cap
.requested
= _
.difference(this.irc_connection
.cap
.requested
, capabilities
);
563 if (this.irc_connection
.cap
.requested
.length
> 0) {
564 this.irc_connection
.write('CAP END');
565 this.irc_connection
.cap_negotation
= false;
569 // should we do anything here?
574 'AUTHENTICATE': function (command
) {
575 var b
= new Buffer(this.irc_connection
.nick
+ "\0" + this.irc_connection
.nick
+ "\0" + this.irc_connection
.password
, 'utf8');
576 var b64
= b
.toString('base64');
577 if (command
.params
[0] === '+') {
578 while (b64
.length
>= 400) {
579 this.irc_connection
.write('AUTHENTICATE ' + b64
.slice(0, 399));
580 b64
= b64
.slice(399);
582 if (b64
.length
> 0) {
583 this.irc_connection
.write('AUTHENTICATE ' + b64
);
585 this.irc_connection
.write('AUTHENTICATE +');
588 this.irc_connection
.write('CAP END');
589 this.irc_connection
.cap_negotation
= false;
593 'AWAY': function (command
) {
594 this.irc_connection
.emit('user ' + command
.nick
+ ' away', {
596 msg
: command
.trailing
600 'RPL_SASLAUTHENTICATED': function (command
) {
601 this.irc_connection
.write('CAP END');
602 this.irc_connection
.cap_negotation
= false;
603 this.irc_connection
.sasl
= true;
606 'RPL_SASLLOGGEDIN': function (command
) {
607 if (this.irc_connection
.cap_negotation
=== false) {
608 this.irc_connection
.write('CAP END');
612 'ERR_SASLNOTAUTHORISED': function (command
) {
613 this.irc_connection
.write('CAP END');
614 this.irc_connection
.cap_negotation
= false;
617 'ERR_SASLABORTED': function (command
) {
618 this.irc_connection
.write('CAP END');
619 this.irc_connection
.cap_negotation
= false;
622 'ERR_SASLALREADYAUTHED': function (command
) {
626 'ERROR': function (command
) {
627 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' error', {
628 reason
: command
.trailing
631 ERR_PASSWDMISMATCH: function (command
) {
632 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' password_mismatch', {});
635 ERR_LINKCHANNEL: function (command
) {
636 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' channel_redirect', {
637 from: command
.params
[1],
638 to
: command
.params
[2]
642 ERR_NOSUCHNICK: function (command
) {
643 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' no_such_nick', {
644 nick
: command
.params
[1],
645 reason
: command
.trailing
649 ERR_CANNOTSENDTOCHAN: function (command
) {
650 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' cannot_send_to_chan', {
651 channel
: command
.params
[1],
652 reason
: command
.trailing
656 ERR_TOOMANYCHANNELS: function (command
) {
657 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' too_many_channels', {
658 channel
: command
.params
[1],
659 reason
: command
.trailing
663 ERR_USERNOTINCHANNEL: function (command
) {
664 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' user_not_in_channel', {
665 nick
: command
.params
[0],
666 channel
: command
.params
[1],
667 reason
: command
.trailing
671 ERR_NOTONCHANNEL: function (command
) {
672 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' not_on_channel', {
673 channel
: command
.params
[1],
674 reason
: command
.trailing
678 ERR_CHANNELISFULL: function (command
) {
679 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' channel_is_full', {
680 channel
: command
.params
[1],
681 reason
: command
.trailing
685 ERR_INVITEONLYCHAN: function (command
) {
686 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' invite_only_channel', {
687 channel
: command
.params
[1],
688 reason
: command
.trailing
692 ERR_BANNEDFROMCHAN: function (command
) {
693 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' banned_from_channel', {
694 channel
: command
.params
[1],
695 reason
: command
.trailing
699 ERR_BADCHANNELKEY: function (command
) {
700 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' bad_channel_key', {
701 channel
: command
.params
[1],
702 reason
: command
.trailing
706 ERR_CHANOPRIVSNEEDED: function (command
) {
707 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' chanop_privs_needed', {
708 channel
: command
.params
[1],
709 reason
: command
.trailing
713 ERR_NICKNAMEINUSE: function (command
) {
714 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' nickname_in_use', {
715 nick
: command
.params
[1],
716 reason
: command
.trailing
720 ERR_ERRONEUSNICKNAME: function(command
) {
721 this.irc_connection
.emit('server ' + this.irc_connection
.irc_host
.hostname
+ ' erroneus_nickname', {
722 nick
: command
.params
[1],
723 reason
: command
.trailing
727 ERR_NOTREGISTERED: function (command
) {
730 RPL_MAPMORE: function (command
) {
731 var params
= _
.clone(command
.params
);
733 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
736 RPL_MAPEND: function (command
) {
737 var params
= _
.clone(command
.params
);
739 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
742 RPL_LINKS: function (command
) {
743 var params
= _
.clone(command
.params
);
745 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
748 RPL_ENDOFLINKS: function (command
) {
749 var params
= _
.clone(command
.params
);
751 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
754 ERR_UNKNOWNCOMMAND: function (command
) {
755 var params
= _
.clone(command
.params
);
757 genericNotice
.call(this, command
, '`' + params
.join(', ') + '` ' + command
.trailing
);
760 ERR_NOMOTD: function (command
) {
761 var params
= _
.clone(command
.params
);
763 genericNotice
.call(this, command
, command
.trailing
);
766 ERR_NOPRIVILEGES: function (command
) {
767 var params
= _
.clone(command
.params
);
769 genericNotice
.call(this, command
, command
.trailing
);
772 RPL_STATSCONN: function (command
) {
773 var params
= _
.clone(command
.params
);
775 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
778 RPL_LUSERCLIENT: function (command
) {
779 var params
= _
.clone(command
.params
);
781 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
784 RPL_LUSEROP: function (command
) {
785 var params
= _
.clone(command
.params
);
787 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
790 RPL_LUSERUNKNOWN: function (command
) {
791 var params
= _
.clone(command
.params
);
793 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
796 RPL_LUSERCHANNELS: function (command
) {
797 var params
= _
.clone(command
.params
);
799 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
802 RPL_LUSERME: function (command
) {
803 var params
= _
.clone(command
.params
);
805 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
808 RPL_LOCALUSERS: function (command
) {
809 var params
= _
.clone(command
.params
);
811 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
814 RPL_GLOBALUSERS: function (command
) {
815 var params
= _
.clone(command
.params
);
817 genericNotice
.call(this, command
, params
.join(', ') + ' ' + command
.trailing
);
824 function genericNotice (command
, msg
, is_error
) {
825 // Default to being an error
826 if (typeof is_error
!== 'boolean')
829 this.client
.sendIrcCommand('notice', {
830 server
: this.con_num
,
832 nick
: command
.prefix
,
835 target
: command
.params
[0],
837 numeric
: parseInt(command
.command
, 10)