UNPKG

prisme-flow

Version:

prisme platform flow engine

30 lines (24 loc) 662 B
/** * Created by prisme.io on 09/06/2017. */ module.exports = function (RED) { function BotCommand (config) { RED.nodes.createNode(this, config) var node = this node.rules = config.rules this.on('input', function (msg) { var originalMessage = msg.originalMessage var rules = node.rules // do nothing if (originalMessage == null || rules.length == 0) { return } var output = [] rules.forEach(function (rule) { output.push(originalMessage.transport == rule.transport ? msg : null) }) node.send(output) }) } RED.nodes.registerType('bot-transport', BotCommand) }