UNPKG

node-red-contrib-chatbot

Version:

REDBot a Chat bot for a full featured chat bot for Telegram, Facebook Messenger and Slack. Almost no coding skills required

29 lines (19 loc) 552 B
module.exports = function(RED) { const { Events } = require('./mc')(RED); function MissionControlInput(config) { RED.nodes.createNode(this, config); const node = this; this.topic = config.topic; const handler = (topic, payload) => { if (topic === node.topic) { node.send({ topic, payload }); } } Events.on('message', handler); this.on('close', done => { Events.removeListener('message', handler); done(); }); } RED.nodes.registerType('mc-input', MissionControlInput); };