@@ -18,6 +18,8 @@ class CommandHandler {
1818 var sendClientCommand = this . sendClientCommand . bind ( this ) ; //Send a browser based command to the user.
1919 var getActiveClients = this . getActiveClients . bind ( this ) ; //Gets everyone's conection socket in the room.
2020 var commandIsAllowed = this . commandIsAllowed . bind ( this ) ; //Checks if the command for that client is allowed.
21+ var addUserMessageFilter = this . addUserMessageFilter . bind ( this ) ; //Add a message filter to a client, editing their messages sent.
22+ var removeUserMessageFilter = this . removeUserMessageFilter . bind ( this ) ; //Remove a message filter from a client.
2123 var _this = this ;
2224
2325 ////////////////////////////////////////////////////
@@ -402,6 +404,7 @@ class CommandHandler {
402404 var foundClients = searchUsersByKey ( args [ 0 ] , senderClient ) ;
403405 foundClients . forEach ( ( otherClient ) => {
404406 sendClientCommand ( otherClient , "slowrotateEnd" ) ;
407+ removeUserMessageFilter ( otherClient , "" ) ;
405408 } ) ;
406409 } ,
407410 "<Username>[br]Aligns the specified users screen back to its default position from the mildly infuriating command, this command won’t show in the ;help list" ,
@@ -698,6 +701,44 @@ class CommandHandler {
698701 false
699702 ) ;
700703
704+ addCommand (
705+ "Australian" ,
706+ function ( args , userInfo , senderClient ) {
707+ var nameToSearch = args [ 0 ] ;
708+ var foundClients = searchUsersByKey ( nameToSearch , senderClient ) ;
709+
710+ foundClients . forEach ( ( client ) => {
711+ addUserMessageFilter ( client , "australian_filter" , function ( originalMessage ) {
712+ var message = "" + originalMessage ; //Make sure its string.
713+
714+ function safeFindAndReplace ( str , find , replace ) { //For compatibility
715+ var splitStr = str . split ( find ) ;
716+ return splitStr . join ( replace ) ;
717+ }
718+
719+ var bro_replace = "mate" ;
720+ var bro_words = [ "bro" , "friend" , "dude" , "bruh" , "bru" , "brother" , "man" ] ;
721+ var hello_replace = "Oi" ;
722+ var hello_words = [ "hi" , "hello" , "hey" ] ;
723+
724+ for ( var targetWord of bro_words ) {
725+ message = safeFindAndReplace ( message , targetWord , bro_replace ) ;
726+ }
727+
728+ for ( var targetWord of hello_words ) {
729+ message = safeFindAndReplace ( message , targetWord , hello_replace ) ;
730+ }
731+
732+ return message ;
733+ } ) ;
734+ } ) ;
735+
736+ return CommandHandler . HIDE_MESSAGE ;
737+ } ,
738+ "" ,
739+ true
740+ )
741+
701742 ////////////////////////////////////////////////////
702743 }
703744
@@ -929,6 +970,14 @@ class CommandHandler {
929970 }
930971 }
931972 }
973+
974+ addUserMessageFilter ( client , id , func ) {
975+ client . _rrUserFilters [ "commands_" + id ] = func ;
976+ }
977+
978+ removeUserMessageFilter ( client , id , func ) {
979+ delete client . _rrUserFilters [ "commands_" + id ] ;
980+ }
932981}
933982
934983module . exports = CommandHandler ;
0 commit comments