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 (23 loc) • 702 B
JavaScript
const utils = require('../lib/helpers/utils');
const when = utils.when;
const RegisterType = require('../lib/node-installer');
module.exports = function(RED) {
const registerType = RegisterType(RED);
function ChatBotAuthorized(config) {
RED.nodes.createNode(this, config);
var node = this;
this.on('input', function(msg) {
var chatContext = msg.chat();
when(chatContext.get('authorized'))
.then(function(authorized) {
// check
if (authorized === true) {
node.send([msg, null]);
} else {
node.send([null, msg]);
}
});
});
}
registerType('chatbot-authorized', ChatBotAuthorized);
};