@@ -760,6 +760,7 @@ function clientConnect(socket) {
760
760
connection . connected = true ;
761
761
connection . opmode = BOUNCER_DEFAULT_OPMODE ;
762
762
connection . userhostInNames = false ;
763
+ connection . messagetags = false ;
763
764
764
765
// Temp Buffer
765
766
connection . _buffer = '' ;
@@ -823,11 +824,12 @@ function clientConnect(socket) {
823
824
this . write ( "CAP REQ :userhost-in-names\n" ) ;
824
825
this . userhostInNames = true ;
825
826
}
826
- if ( lines [ n ] . trim ( ) . indexOf ( "server-time" ) >= 0 ) {
827
- this . write ( "CAP REQ :server-time\n" ) ;
828
- }
829
827
if ( lines [ n ] . trim ( ) . indexOf ( "message-tags" ) >= 0 ) {
830
828
this . write ( "CAP REQ :message-tags\n" ) ;
829
+ this . messagetags = true ;
830
+ }
831
+ if ( this . messagetags && lines [ n ] . trim ( ) . indexOf ( "server-time" ) >= 0 ) {
832
+ this . write ( "CAP REQ :server-time\n" ) ;
831
833
}
832
834
if ( SASL && lines [ n ] . trim ( ) . indexOf ( "sasl" ) >= 0 ) {
833
835
this . write ( "CAP REQ :sasl\n" ) ;
@@ -881,7 +883,12 @@ function clientConnect(socket) {
881
883
}
882
884
}
883
885
884
- let s = ( data [ 2 ] == "JOIN" || data [ 2 ] == "PART" || data [ 2 ] == "QUIT" || data [ 2 ] == "MODE" || data [ 2 ] == "PING" || data [ 2 ] == "NICK" || data [ 2 ] == "KICK" ? data [ 2 ] : data [ 1 ] ) ;
886
+ let s = data [ 1 ] ;
887
+
888
+ if ( this . messagetags && ( data [ 2 ] == "JOIN" || data [ 2 ] == "PART" || data [ 2 ] == "QUIT" || data [ 2 ] == "MODE" || data [ 2 ] == "PING" || data [ 2 ] == "NICK" || data [ 2 ] == "KICK" ) ) {
889
+ s = data [ 2 ] ;
890
+ }
891
+
885
892
switch ( s ) {
886
893
case '001' :
887
894
if ( ! this . authenticated ) {
@@ -902,20 +909,29 @@ function clientConnect(socket) {
902
909
break ;
903
910
case '324' :
904
911
case 'MODE' :
912
+ _mode_target = [ ] ;
905
913
if ( data [ 1 ] == '324' ) {
906
914
_target = data [ 3 ] . trim ( ) ;
907
- _sender = data [ 1 ] . substr ( 1 ) . split ( "!" ) [ 0 ] ;
915
+ _sender = data [ 0 ] . substr ( 1 ) . split ( "!" ) [ 0 ] ;
908
916
_mode = data [ 4 ] . trim ( ) ;
909
917
if ( data [ 5 ] )
910
918
_mode_target = data . slice ( 5 , data . length ) ;
911
919
}
912
- else if ( data [ 2 ] == 'MODE' ) {
920
+ else if ( this . messagetags && data [ 2 ] == 'MODE' ) {
913
921
_target = data [ 3 ] . trim ( ) ;
914
922
_sender = data [ 1 ] . substr ( 1 ) . split ( "!" ) [ 0 ] ;
915
923
_mode = data [ 4 ] . trim ( ) ;
916
924
if ( data [ 5 ] )
917
925
_mode_target = data . slice ( 5 , data . length ) ;
918
- } else {
926
+ }
927
+ else if ( ! this . messagetags ) {
928
+ _target = data [ 2 ] . trim ( ) ;
929
+ _sender = data [ 0 ] . substr ( 1 ) . split ( "!" ) [ 0 ] ;
930
+ _mode = data [ 3 ] . trim ( ) ;
931
+ if ( data [ 4 ] )
932
+ _mode_target = data . slice ( 4 , data . length ) ;
933
+ }
934
+ else {
919
935
_target = data [ 2 ] . trim ( ) ;
920
936
_sender = data [ 2 ] ;
921
937
_mode = data [ 3 ] . trim ( ) ;
@@ -1091,16 +1107,17 @@ function clientConnect(socket) {
1091
1107
this . motd += lines [ n ] + "\n" ;
1092
1108
break ;
1093
1109
case 'JOIN' :
1094
- _temp = data [ 1 ] . substr ( 1 ) . split ( "!" ) ;
1110
+ _temp = ( this . messagetags ? data [ 1 ] . substr ( 1 ) . split ( "!" ) : data [ 0 ] . substr ( 1 ) . split ( "!" ) ) ;
1111
+ _datatemp = ( this . messagetags ? 3 : 2 ) ;
1095
1112
_nick = _temp [ 0 ] ;
1096
1113
if ( _temp [ 1 ] )
1097
1114
_userhost = _temp [ 1 ] ;
1098
1115
if ( _temp [ 1 ] && this . nick == _nick ) {
1099
1116
this . ircuser = _temp [ 1 ] . split ( "@" ) [ 0 ] ;
1100
1117
}
1101
- _channels = data [ 3 ] . substr ( 0 ) . trim ( ) . split ( "," ) ;
1102
- if ( data [ 3 ] . indexOf ( ":" ) != - 1 )
1103
- _channels = data [ 3 ] . substr ( 1 ) . trim ( ) . split ( "," ) ;
1118
+ _channels = data [ _datatemp ] . substr ( 0 ) . trim ( ) . split ( "," ) ;
1119
+ if ( data [ _datatemp ] . indexOf ( ":" ) != - 1 )
1120
+ _channels = data [ _datatemp ] . substr ( 1 ) . trim ( ) . split ( "," ) ;
1104
1121
for ( x = 0 ; x < _channels . length ; x ++ ) {
1105
1122
_channel = _channels [ x ] ;
1106
1123
__channel = _channel . toUpperCase ( ) ;
@@ -1169,8 +1186,8 @@ function clientConnect(socket) {
1169
1186
this . channels [ _channel ] . topic_time = _time ;
1170
1187
break ;
1171
1188
case 'KICK' :
1172
- _target = data [ 4 ] . trim ( ) ;
1173
- _channel = data [ 3 ] . toUpperCase ( ) . trim ( ) ;
1189
+ _target = ( this . messagetags ? data [ 4 ] . trim ( ) : data [ 3 ] . trim ( ) ) ;
1190
+ _channel = ( this . messagetags ? data [ 3 ] . toUpperCase ( ) . trim ( ) : data [ 2 ] . toUpperCase ( ) . trim ( ) ) ;
1174
1191
if ( _target == this . nick ) {
1175
1192
delete this . channels [ _channel ] ;
1176
1193
}
@@ -1182,8 +1199,8 @@ function clientConnect(socket) {
1182
1199
}
1183
1200
break ;
1184
1201
case 'PART' :
1185
- _target = data [ 3 ] . toUpperCase ( ) . trim ( ) ;
1186
- _sender = data [ 1 ] . substr ( 1 ) . split ( "!" ) [ 0 ] ;
1202
+ _target = ( this . messagetags ? data [ 3 ] . toUpperCase ( ) . trim ( ) : data [ 2 ] . toUpperCase ( ) . trim ( ) ) ;
1203
+ _sender = ( this . messagetags ? data [ 1 ] . substr ( 1 ) . split ( "!" ) [ 0 ] : data [ 0 ] . substr ( 1 ) . split ( "!" ) [ 0 ] ) ;
1187
1204
if ( _sender == this . nick ) {
1188
1205
delete this . channels [ _target ] ;
1189
1206
}
@@ -1196,7 +1213,7 @@ function clientConnect(socket) {
1196
1213
}
1197
1214
break ;
1198
1215
case 'QUIT' :
1199
- _sender = data [ 1 ] . substr ( 1 ) . split ( "!" ) [ 0 ] ;
1216
+ _sender = ( this . messagetags ? data [ 1 ] . substr ( 1 ) . split ( "!" ) [ 0 ] : data [ 0 ] . substr ( 1 ) . split ( "!" ) [ 0 ] ) ;
1200
1217
for ( key in this . channels ) {
1201
1218
if ( this . channels . hasOwnProperty ( key ) ) {
1202
1219
for ( x = 0 ; x < this . channels [ key ] . names . length ; x ++ ) {
0 commit comments