New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

chat-censoring

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chat-censoring

Checks a message for bad words (and censor it)

latest
Source
npmnpm
Version
1.0.9
Version published
Maintainers
1
Created
Source

ChatCensoring

npm npm GitHub GitHub last commit (branch)


A tiny & simple package for your chat application that allows you to remove or censor bad words in chat.

Installation

npm:

npm i chat-censoring

Features

  • Check, if a message includes bad words
  • Check and censor (if needed) a message

Check message

This function takes your message as argument and checks, if it includes a bad word. As result it returns either true or false.

Parameters:

ParameterUsage
messageThe message you want to check

Example:

const censoring = require('chat-censoring');

const isInsult = censoring.check('You are great!');
console.log(isInsult); // Prints false
const censoring = require('chat-censoring');

const isInsult = censoring.check('You are fucking stupid!');
console.log(isInsult); // Prints true

Censor message

This function checks if there is a bad word in your provided message and replaces this word(s) with the character of your choise.

Parameter:

ParameterUsage
messageThe message you want to check and censor if needed
censoringCharThe char you want to use to censor bad words

Example:

const censoring = require('chat-censoring');

const friendlyMessage = censoring.censorMessage('This is fucking cool!', '*');
console.log(friendlyMessage); // Prints 'This is ******* cool!'

[Deprecated] Discord.js example

This package was created with the motivation to censor chat messages in Discord. Of course it can be used in other applications as well

Here is an example how you can use it for your Discord bot:

if(message.author.bot) return;

	if(!content.startsWith(prefix)) {

		if(censor.checkMessage(content)) {
			message.delete()
				.then(() => message.channel.send(`${message.author} said: ${censor.censorMessage(content, '#')}`))
				.catch(err => {
					console.log('An error occurred while censoring a message: ' + err);
					return message.channel.send('Unfortunately an error has occurred :(');
				});
		}
		return;
	}

Keywords

censoring

FAQs

Package last updated on 17 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts