@@ -6,14 +6,12 @@ const _ = {
66 map : require ( 'lodash/map' ) ,
77} ;
88const Helpers = require ( '../../helpers' ) ;
9-
109const handlers = {
1110 RPL_LISTSTART : function ( command , handler ) {
1211 const cache = getChanListCache ( handler ) ;
1312 cache . channels = [ ] ;
1413 handler . emit ( 'channel list start' ) ;
1514 } ,
16-
1715 RPL_LISTEND : function ( command , handler ) {
1816 const cache = getChanListCache ( handler ) ;
1917 if ( cache . channels . length ) {
@@ -300,6 +298,12 @@ const handlers = {
300298 cache . destroy ( ) ;
301299 } ,
302300
301+ FAIL : standardReply ,
302+
303+ WARN : standardReply ,
304+
305+ NOTE : standardReply ,
306+
303307 BATCH : function ( command , handler ) {
304308 const batch_start = command . params [ 0 ] . substr ( 0 , 1 ) === '+' ;
305309 const batch_id = command . params [ 0 ] . substr ( 1 ) ;
@@ -351,7 +355,26 @@ const handlers = {
351355 handler . emit ( 'batch end ' + emit_obj . type , emit_obj ) ;
352356 }
353357} ;
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+ }
355378module . exports = function AddCommandHandlers ( command_controller ) {
356379 _ . each ( handlers , function ( handler , handler_command ) {
357380 command_controller . addHandler ( handler_command , handler ) ;
@@ -367,4 +390,4 @@ function getChanListCache(handler) {
367390 }
368391
369392 return cache ;
370- }
393+ }
0 commit comments