@@ -6,14 +6,12 @@ const _ = {
6
6
map : require ( 'lodash/map' ) ,
7
7
} ;
8
8
const Helpers = require ( '../../helpers' ) ;
9
-
10
9
const handlers = {
11
10
RPL_LISTSTART : function ( command , handler ) {
12
11
const cache = getChanListCache ( handler ) ;
13
12
cache . channels = [ ] ;
14
13
handler . emit ( 'channel list start' ) ;
15
14
} ,
16
-
17
15
RPL_LISTEND : function ( command , handler ) {
18
16
const cache = getChanListCache ( handler ) ;
19
17
if ( cache . channels . length ) {
@@ -300,6 +298,12 @@ const handlers = {
300
298
cache . destroy ( ) ;
301
299
} ,
302
300
301
+ FAIL : standardReply ,
302
+
303
+ WARN : standardReply ,
304
+
305
+ NOTE : standardReply ,
306
+
303
307
BATCH : function ( command , handler ) {
304
308
const batch_start = command . params [ 0 ] . substr ( 0 , 1 ) === '+' ;
305
309
const batch_id = command . params [ 0 ] . substr ( 1 ) ;
@@ -351,7 +355,26 @@ const handlers = {
351
355
handler . emit ( 'batch end ' + emit_obj . type , emit_obj ) ;
352
356
}
353
357
} ;
354
-
358
+ /**
359
+ *
360
+ * @param {import('../command') } irccommand
361
+ * @param {import('../handler') } handler
362
+ */
363
+ function standardReply ( irccommand , handler ) {
364
+ const [ command , code , ...context ] = irccommand . params ;
365
+ const description = context [ context . length - 1 ]
366
+ . indexOf ( ' ' ) !== - 1 ?
367
+ context . pop ( ) :
368
+ null ;
369
+ handler . emit ( 'standard reply' , {
370
+ reply_type : irccommand . command ,
371
+ command,
372
+ code,
373
+ context,
374
+ description,
375
+ tags : irccommand . tags
376
+ } ) ;
377
+ }
355
378
module . exports = function AddCommandHandlers ( command_controller ) {
356
379
_ . each ( handlers , function ( handler , handler_command ) {
357
380
command_controller . addHandler ( handler_command , handler ) ;
@@ -367,4 +390,4 @@ function getChanListCache(handler) {
367
390
}
368
391
369
392
return cache ;
370
- }
393
+ }
0 commit comments