Welcome, Guest
  • Author Topic: Banning certain TEXT from the chat room component  (Read 3060 times)

    jay

    • Jr. Programmer
    • **
    • Posts: 99
      • View Profile
    hello everyone

    Does anyone know how to ban certain words and remove links from the the text chat component. So that people cant send out bad language and so they cannot use our hard worked site and chat rooms for spamming other sites?

    any help would be greatly appreciated....

    Thanks
    Jay

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Banning certain TEXT from the chat room component
    « Reply #1 on: 10/22/05, 13:26 »
    Open chat.asc in <Flash Communication Server MX>scriptlib\components

    Look at the sendMessage method:


    FCChat
    .prototype.sendMessage = function( clientmesg ) {

    	
    	
    var 
    cglobal this.getClientGlobalStorage(client);

    	
    	
    mesg this.hiliteURLs(mesg);

    	
    	
    var 
    hexColor "#"+cglobal.usercolor.substring(2cglobal.usercolor.length)

    	
    	
    mesg "<font color=\"" hexColor "\"><b>" cglobal.username ": </b>" mesg "</font><br>\n";
    	
    	
    this.history.pushmesg );
    	
    	
    while ( 
    this.history.length this.histlen )
    	
    	
    	
    this.history.shift();

    	
    	
    this.message_so.send"message"mesg );
    	
    }


    The hiliteURLs method hilite URL's, remove it
    You can use any String method over mesg to filter words or whatever
    Remember that this is the base code for all components, chat, so if you want to add this feature just to one version, probably you can build your own (based on this code on server side, and based on chat component on client side)

    Jorge

    jay

    • Jr. Programmer
    • **
    • Posts: 99
      • View Profile
    Re: Banning certain TEXT from the chat room component
    « Reply #2 on: 10/22/05, 17:33 »
    So basically , could I simply duplicate the entire chat.asc and name something like customChat.asc and then use that .ASC file for this particular App only? Either way I dont see me wanting anyone being able to send spam into the chat room. Hey just wondering something else...Do you think FCS is really the best solution for for a video chat room site or is it better to use a JAVA App? Bandwidth wise what is going to handle the overall intent of the APP better?

    Also, is their a way for me to make it so the Flash App runs from a users desktop and not in a browser. I thought that I had one time read somewhere that you could make Flash Apps do that. I am just trying to figure something out to make my App run better. I am running TWO professional versions and I still have problems with bandwidth. ANy suggestions?

    Thanks
    Jay

    jay

    • Jr. Programmer
    • **
    • Posts: 99
      • View Profile
    Re: Banning certain TEXT from the chat room component
    « Reply #3 on: 10/22/05, 19:44 »
    jorge

    At the bottom of the chat.asc file i found the follow bolck of code. I think I could use this to actually change what appears in the chat text when someone tries to spam. Or am I wrong?

    Here is the code

    //highlight urls
          //-
          var url_begin = msg.indexOf("http:");
          if ( url_begin == -1 )
             url_begin = msg.indexOf("www.");

          if ( url_begin == -1 )
             return msg;

          var hilited = msg.substring(0, url_begin);
          var url_end = msg.indexOf( " ", url_begin );

          var urlstr = "";
          if ( url_end == -1 )
             urlstr = msg.substring(url_begin);
          else
             urlstr = msg.substring(url_begin, url_end);

          var urlref = urlstr;
          if ( urlstr.indexOf("www.") == 0 )
             urlref = "http://" + urlstr;

          var trailer = "";
          if ( url_end != -1 )
             trailer = this.hiliteURLs( msg.substring(url_end) );

          hilited += "<font color=\"#0000FF\"><u><a href=\"" + urlref + "\" target=\"_blank\">" + urlstr + "</a></u></font>" + trailer;
          //hilited += "<font color=\"#0000FF\"><u><a href=\"" + urlstr + "\">" + urlstr + "</a></u></font>" + trailer;

          return hilited;
       } 

    jay

    • Jr. Programmer
    • **
    • Posts: 99
      • View Profile
    Re: Banning certain TEXT from the chat room component
    « Reply #4 on: 10/22/05, 19:49 »
    jorge , after looking at this further I think I understand it a little more. there is actually an entire area of code dedicated to making links show up in the chat room itself. as i said before it is close to the bottom

    thanks again
    jay



                   // Hilight the urls in a message
       FCChat.prototype.hiliteURLs = function(msg)
       {

    jay

    • Jr. Programmer
    • **
    • Posts: 99
      • View Profile
    Re: Banning certain TEXT from the chat room component
    « Reply #5 on: 10/23/05, 09:01 »
    Jorge

    Here is a real easy solution for the spam problem. I hope this can help other FCS developers. This solution can help in three ways. First it stops the unwanted advertising of another website by replacing the spamed website name with TEXT that the developer chooses (defines).  Secondly, it will replaces the actually URL link with a URL link that the FCS developer chooses (defines). This is good because if any chatters do click on the link it will take them to a website or page that can be serve a purpose. For example.... my URL link will open a new window and take the chatter to a page that clearly outlines our policy on spam and bad language. Thirdly, it shows your chatters that you are serious about protecting your application, well as protecting them against unwanted spam, advertising and bad language.

    So here is how it works and how you can impliment it.

    Step One:
    1)  Goto your server side script called chat.asc
    2)  Open the chat.asc file and scroll all the way to bottom. Locate the following code >>
         Code:
           if ( url_end != -1 )
             trailer = this.hiliteURLs( msg.substring(url_end) );

          hilited += "<font color=\"#0000FF\"><u><a href=\"" + urlref + "\" target=\"_blank\">" + urlstr + "</a></u></font>" + trailer;
          //hilited += "<font color=\"#0000FF\"><u><a href=\"" + urlstr + "\">" + urlstr + "</a></u></font>" + trailer;

          return hilited;
       }     



    3) Edit the above code so it looks like the code below. You can use your own text and you can name your new VAR's (variables) what ever you like.

    Edited Code:

    if ( url_end != -1 )
             trailer = this.hiliteURLs( msg.substring(url_end) );

         //ADDED CODE: These two lines of code have been added in order to help reduce the amount spam and unwanted advertising taking place in the chat room.
        //the new VARS will redefine the text and URL lINK prior to the FCS server sending the information to the chat room text area.
       //Date Added: October 23, 2005

                urlref  = replacement_LINK = "noSpam.html";
                urlstr  = replacement_TEXT = "NO SPAM: Please click here to read our No Spam TOS Rules";

    //-------------END ADDED CODE HERE-------------\\
           
            hilited += "<font color=\"#0000FF\"><u><a href=\"" + replacement_LINK + "\" target=\"_blank\">" + replacement_TEXT + "</a></u></font>" + trailer;
          //hilited += "<font color=\"#0000FF\"><u><a href=\"" + urlstr + "\">" + urlstr + "</a></u></font>" + trailer;

          return hilited;
       }     



    Well, I hope this can help someone. It is a very simple solution, but it pretty much does the job when someone tries to post links into your web chat room.

    Goodluck everyone....
    Jay