@@ -70,8 +70,8 @@ var handlers = {
7070
7171 if ( ( message . charAt ( 0 ) === '\01' ) && ( message . charAt ( message . length - 1 ) === '\01' ) ) {
7272 // CTCP request
73- if ( message . substr ( 1 , 6 ) === 'ACTION' ) {
74-
73+ var ctcp_command = message . slice ( 1 , - 1 ) . split ( ' ' ) [ 0 ] . toUpperCase ( ) ;
74+ if ( ctcp_command === 'ACTION' ) {
7575 this . emit ( 'action' , {
7676 nick : command . nick ,
7777 ident : command . ident ,
@@ -84,14 +84,14 @@ var handlers = {
8484 account : command . getTag ( 'account' )
8585 } ) ;
8686
87- } else if ( message . substr ( 1 , 7 ) === 'VERSION' ) {
87+ } else if ( ctcp_command === 'VERSION' ) {
8888 this . connection . write ( util . format (
8989 'NOTICE %s :\01VERSION %s\01' ,
9090 command . nick ,
9191 this . connection . options . version
9292 ) ) ;
9393
94- } else if ( message . substr ( 1 , 10 ) === 'CLIENTINFO' ) {
94+ } else if ( ctcp_command === 'CLIENTINFO' ) {
9595 this . connection . write ( util . format (
9696 'NOTICE %s :\01CLIENTINFO VERSION\01' ,
9797 command . nick
@@ -104,7 +104,7 @@ var handlers = {
104104 hostname : command . hostname ,
105105 target : target ,
106106 group : target_group ,
107- type : ( message . substring ( 1 , message . length - 1 ) . split ( ' ' ) || [ null ] ) [ 0 ] ,
107+ type : ( ctcp_command || [ null ] ) [ 0 ] ,
108108 message : message . substring ( 1 , message . length - 1 ) ,
109109 time : time ,
110110 account : command . getTag ( 'account' )
0 commit comments