@@ -519,8 +519,8 @@ describe('Bot', function () {
519
519
const testUser = this . addUser ( { username : 'testuser' , id : '123' , nickname : 'somenickname' } ) ;
520
520
521
521
const username = 'ircuser' ;
522
- const text = 'Hello, @somenickname! ' ;
523
- const expected = `**<${ username } >** Hello, ${ testUser } ! ` ;
522
+ const text = 'Hello, @somenickname' ;
523
+ const expected = `**<${ username } >** Hello, ${ testUser } ` ;
524
524
525
525
this . bot . sendToDiscord ( username , '#irc' , text ) ;
526
526
this . sendStub . should . have . been . calledWith ( expected ) ;
@@ -531,7 +531,19 @@ describe('Bot', function () {
531
531
532
532
const username = 'ircuser' ;
533
533
const text = 'Hello, @testuser!' ;
534
- const expected = `**<${ username } >** Hello, <@${ testUser . id } >!` ;
534
+ const expected = `**<${ username } >** Hello, ${ testUser } !` ;
535
+
536
+ this . bot . sendToDiscord ( username , '#irc' , text ) ;
537
+ this . sendStub . should . have . been . calledWith ( expected ) ;
538
+ } ) ;
539
+
540
+ it ( 'should convert username-discriminator mentions from IRC properly' , function ( ) {
541
+ const user1 = this . addUser ( { username : 'user' , id : '123' , discriminator : '9876' } ) ;
542
+ const user2 = this . addUser ( { username : 'user' , id : '124' , discriminator : '5555' , nickname : 'secondUser' } ) ;
543
+
544
+ const username = 'ircuser' ;
545
+ const text = 'hello @user#9876 and @user#5555 and @fakeuser#1234' ;
546
+ const expected = `**<${ username } >** hello ${ user1 } and ${ user2 } and @fakeuser#1234` ;
535
547
536
548
this . bot . sendToDiscord ( username , '#irc' , text ) ;
537
549
this . sendStub . should . have . been . calledWith ( expected ) ;
@@ -599,6 +611,35 @@ describe('Bot', function () {
599
611
this . sendStub . should . have . been . calledWith ( expected ) ;
600
612
} ) ;
601
613
614
+ it ( 'should convert overlapping mentions from IRC properly and case-insensitively' , function ( ) {
615
+ const user = this . addUser ( { username : 'user' , id : '111' } ) ;
616
+ const nickUser = this . addUser ( { username : 'user2' , id : '112' , nickname : 'userTest' } ) ;
617
+ const nickUserCase = this . addUser ( { username : 'user3' , id : '113' , nickname : 'userTEST' } ) ;
618
+ const role = this . addRole ( { name : 'userTestRole' , id : '12345' , mentionable : true } ) ;
619
+
620
+ const username = 'ircuser' ;
621
+ const text = 'hello @User, @user, @userTest, @userTEST, @userTestRole and @usertestrole' ;
622
+ const expected = `**<${ username } >** hello ${ user } , ${ user } , ${ nickUser } , ${ nickUserCase } , ${ role } and ${ role } ` ;
623
+
624
+ this . bot . sendToDiscord ( username , '#irc' , text ) ;
625
+ this . sendStub . should . have . been . calledWith ( expected ) ;
626
+ } ) ;
627
+
628
+ it ( 'should convert partial matches from IRC properly' , function ( ) {
629
+ const user = this . addUser ( { username : 'user' , id : '111' } ) ;
630
+ const longUser = this . addUser ( { username : 'user-punc' , id : '112' } ) ;
631
+ const nickUser = this . addUser ( { username : 'user2' , id : '113' , nickname : 'nick' } ) ;
632
+ const nickUserCase = this . addUser ( { username : 'user3' , id : '114' , nickname : 'NiCK' } ) ;
633
+ const role = this . addRole ( { name : 'role' , id : '12345' , mentionable : true } ) ;
634
+
635
+ const username = 'ircuser' ;
636
+ const text = '@user-ific @usermore, @user\'s friend @user-punc, @nicks and @NiCKs @roles' ;
637
+ const expected = `**<${ username } >** ${ user } -ific ${ user } more, ${ user } 's friend ${ longUser } , ${ nickUser } s and ${ nickUserCase } s ${ role } s` ;
638
+
639
+ this . bot . sendToDiscord ( username , '#irc' , text ) ;
640
+ this . sendStub . should . have . been . calledWith ( expected ) ;
641
+ } ) ;
642
+
602
643
it ( 'should successfully send messages with default config' , function ( ) {
603
644
const bot = new Bot ( configMsgFormatDefault ) ;
604
645
bot . connect ( ) ;
0 commit comments