Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad word filter Feature (Ready to Use) :D #2940

Closed
wants to merge 3 commits into from

Conversation

x5engine
Copy link
Contributor

@x5engine x5engine commented Apr 19, 2016

Bad Words Filter (Feature)

Here is the bad words filter feature where you can filter all the bad words :

  • No need to add them just Enable/Disable in Settings-Message (default = enabled)
  • You can any words to filter and as much as you want ;)
  • It's Awesome you can try with some phrases like <censored> Only for test purposes :D

Try and enjoy :)

@x5engine
Copy link
Contributor Author

result would be ******* ************ with a big **** and nice ***** and I hate your ******* ****

@x5engine
Copy link
Contributor Author

@rodrigok it works and I tested it many times bro ;)

@engelgabriel
Copy link
Member

@capensisma this is an automated test o code quality, from https://www.codacy.com/app/RocketChat/Rocket-Chat/pullRequest?prid=220222

@x5engine
Copy link
Contributor Author

@engelgabriel there is nothing to be improved there, so ... and it works well and as intended

@x5engine
Copy link
Contributor Author

@engelgabriel
Copy link
Member

It may work well.. this is not the point.

The code QUALITY is bad because it doens't follow the standards.

@x5engine
Copy link
Contributor Author

code QUALITY is bad? okay show me better then!

@engelgabriel
Copy link
Member

What editor do you use? Can you install ESlint?

@x5engine
Copy link
Contributor Author

I can in the cloud c9.io that's all why is the editor related to this?

@rodrigok
Copy link
Member

rodrigok commented Apr 19, 2016

@capensisma a better code syntax looks like:

const Filter = Npm.require('bad-words');

RocketChat.callbacks.add('beforeSaveMessage', function(message) {

    if (RocketChat.settings.get('Message_AllowBadWordsFilter')) {
        const badWordsList = RocketChat.settings.get('Message_BadWordsFilterList');

        let filter;

        //Add words to the blacklist
        if (!!badWordsList && badWordsList.length) {
            filter = new Filter({ list: badWordsList.split(',') });
        } else {
            filter = new Filter();
        }

        message.msg = filter.clean(message.msg);
    }

    return message;
}, 1);

Your current code is:

var Filter = Npm.require('bad-words');

    RocketChat.callbacks.add( 'beforeSaveMessage' , function(message){
        // console.log(message)

        if( RocketChat.settings.get('Message_AllowBadWordsFilter') )
            {

                var badWordsList = RocketChat.settings.get('Message_BadWordsFilterList');
                    // console.log(badWordsList)
                    //Add words to the blacklist
                    if(!!badWordsList && badWordsList.length)
                        {   
                            // console.log(badWordsList)
                            var filter = new Filter({ list: badWordsList.split(',') });
                        }
                    else
                        var filter = new Filter();
                message.msg = filter.clean(message.msg);

            }
    return message;

    },1);

We have a lot of ESLint rules to keep the code quality, you can use the ESLint command line tool to check your code and you can integrate the ESLint with your code editor to get error hints.

var filter = new Filter({ list: badWordsList.split(',') });
}
else
var filter = new Filter();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@x5engine
Copy link
Contributor Author

What's the ETA on this? will never be merged or what? bros?

@geekgonecrazy
Copy link
Contributor

@capensisma can you take a look at the few code tweaks as included in the previous comment, and the comments on the commit?

All are listed here above. We review carefully anything that will directly interact with the messages. We want to make sure to prevent any issues from coming up. Fixing the above mentioned would give us more comfort :)

Appreciate the understanding!

@x5engine
Copy link
Contributor Author

I swear to God there is nothing to change or fix here, its just the codacy doesn't like the indentations or something and it's says var or like Keyword "if" must be followed by whitespace. this is code quality for CoffeeScript not Pure Javascript bros C'mon!

@geekgonecrazy
Copy link
Contributor

geekgonecrazy commented Apr 22, 2016

@capensisma The thing you have to remember about code you contribute. Once you check it in to the project and we accept it, you no longer have to maintain it. We do. Its because of this we are trying to improve code quality. This makes our life easier.

But no worries.. I'll take care of this. Thanks for contributing.

geekgonecrazy added a commit that referenced this pull request Apr 22, 2016
@geekgonecrazy
Copy link
Contributor

We'll review and merge via #2991

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants