mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
update swearfilter
This commit is contained in:
parent
3d12a5318f
commit
c691b4eaa1
@ -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); }
|
||||
}
|
||||
});
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user