update swearfilter

This commit is contained in:
Dave Conway-Jones 2019-03-14 14:04:06 +00:00
parent 3d12a5318f
commit c691b4eaa1
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
2 changed files with 5 additions and 6 deletions

View File

@ -1,15 +1,14 @@
module.exports = function(RED) {
"use strict";
var badwords = require('badwords');
if (badwords.length === 0 ) { return; }
var badwordsRegExp = require('badwords/regexp');
function BadwordsNode(n) {
RED.nodes.createNode(this,n);
var badwordsRegExp = require('badwords/regexp');
var node = this;
this.on("input", function(msg) {
node.on("input", function(msg) {
if (typeof msg.payload === "string") {
badwordsRegExp.lastIndex = 0
if ( !badwordsRegExp.test(msg.payload) ) { node.send(msg); }
}
});

View File

@ -1,9 +1,9 @@
{
"name" : "node-red-node-badwords",
"version" : "0.0.5",
"version" : "0.1.0",
"description" : "A Node-RED node that attempts to filter out messages containing swearwords.",
"dependencies" : {
"badwords" : "0.0.3"
"badwords" : "^1.0.0"
},
"repository" : {
"type":"git",