mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
moved username and password into credentials, and upped the version of irc as ssl didn’t work with the older version.
This commit is contained in:
parent
994039de15
commit
41f397add7
@ -92,6 +92,10 @@
|
||||
ircserver: {type:"irc-server", required:true},
|
||||
channel: {value:"",required:true,validate:RED.validators.regex(/^#/)}
|
||||
},
|
||||
credentials: {
|
||||
username: {type:"text"},
|
||||
password: {type:"password"}
|
||||
},
|
||||
color:"Silver",
|
||||
inputs:0,
|
||||
outputs:2,
|
||||
@ -218,9 +222,7 @@
|
||||
port: {value:"6667"},
|
||||
ssl: {value:false},
|
||||
cert: {value:false},
|
||||
nickname: {value:"",required:true},
|
||||
username: {value:""},
|
||||
password: {value:""}
|
||||
nickname: {value:"",required:true}
|
||||
},
|
||||
credentials: {
|
||||
username: {type:"text"},
|
||||
|
@ -18,6 +18,7 @@ module.exports = function(RED) {
|
||||
"use strict";
|
||||
var irc = require("irc");
|
||||
|
||||
|
||||
// The Server Definition - this opens (and closes) the connection
|
||||
function IRCServerNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
@ -27,8 +28,6 @@ module.exports = function(RED) {
|
||||
this.cert = n.cert || false;
|
||||
this.channel = n.channel;
|
||||
this.nickname = n.nickname;
|
||||
this.username = n.username;
|
||||
this.password = n.password;
|
||||
this.lastseen = 0;
|
||||
this.ircclient = null;
|
||||
this.on("close", function() {
|
||||
@ -37,8 +36,23 @@ module.exports = function(RED) {
|
||||
this.ircclient.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
this.username = null;
|
||||
this.password = null;
|
||||
if (this.credentials && this.credentials.hasOwnProperty("username")) {
|
||||
this.username = this.credentials.username;
|
||||
}
|
||||
if (this.credentials && this.credentials.hasOwnProperty("password")) {
|
||||
this.password = this.credentials.password;
|
||||
}
|
||||
|
||||
}
|
||||
RED.nodes.registerType("irc-server",IRCServerNode);
|
||||
RED.nodes.registerType("irc-server",IRCServerNode, {
|
||||
credentials: {
|
||||
username: {type:"text"},
|
||||
password: {type:"password"}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// The Input Node
|
||||
@ -49,7 +63,7 @@ module.exports = function(RED) {
|
||||
this.channel = n.channel || this.serverConfig.channel;
|
||||
var node = this;
|
||||
if (node.serverConfig.ircclient === null) {
|
||||
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server);
|
||||
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server+" "+node.serverConfig.username+" "+node.serverConfig.ssl);
|
||||
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
|
||||
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000,userName:node.serverConfig.username,password:node.serverConfig.password};
|
||||
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options);
|
||||
@ -186,7 +200,7 @@ module.exports = function(RED) {
|
||||
if (node.serverConfig.ircclient === null) {
|
||||
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server);
|
||||
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
|
||||
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000,userName:node.serverConfig.username,password:node.serverConfig.password};
|
||||
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000,userName:node.username,password:node.password};
|
||||
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options);
|
||||
node.serverConfig.ircclient.setMaxListeners(0);
|
||||
node.serverConfig.ircclient.addListener('error', function(message) {
|
||||
|
@ -7,7 +7,9 @@
|
||||
"port": "Port",
|
||||
"ssl": "Use Secure SSL connection?",
|
||||
"self": "Allow self-signed certificates?",
|
||||
"nickname": "Nickname"
|
||||
"nickname": "Nickname",
|
||||
"username": "Server username",
|
||||
"password": "Server password"
|
||||
},
|
||||
"payload": "Send payload to channel(s)",
|
||||
"topic": "Use msg.topic to set nickname or channel(s)",
|
||||
@ -36,4 +38,4 @@
|
||||
"topicnotset": "msg.topic not set"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
"version" : "0.0.3",
|
||||
"description" : "A Node-RED node to talk to an IRC server",
|
||||
"dependencies" : {
|
||||
"irc" : "0.3.11"
|
||||
"irc" : "~0.4.0"
|
||||
},
|
||||
"repository" : {
|
||||
"type":"git",
|
||||
|
Loading…
Reference in New Issue
Block a user