slightly better IRC error catching

This commit is contained in:
Dave C-J 2013-10-02 21:15:12 +01:00
parent f6da96e7e1
commit 148f6f418e
2 changed files with 9 additions and 11 deletions

View File

@ -65,12 +65,12 @@
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">Sending complete object will stringify the whole msg object before sending.</div>
<div class="form-tips">Sending the complete object will stringify the whole msg object before sending.</div>
</script>
<script type="text/x-red" data-help-name="irc out">
<p>Connects to a channel on an IRC server</p>
<p>If you send something with NO msg.topic it will go to the channel - otherwise it will go to the id in the <b>msg.topic</b> field.</p>
<p>Sends messages to a channel on an IRC server</p>
<p>If you send something with NO <b>msg.topic</b> it will go to the configured channel - otherwise it will go to the id in the <b>msg.topic</b> field.</p>
<p>You can either just send the <b>msg.payload</b>, or you can send the complete <b>msg</b> object.</p>
</script>
@ -103,7 +103,7 @@
</div>
<div class="form-row">
<label for="node-config-input-channel"><i class="icon-tasks"></i> Channel</label>
<input type="text" id="node-config-input-channel" placeholder="#testing1234">
<input type="text" id="node-config-input-channel" placeholder="#node-red">
</div>
<div class="form-row">
<label for="node-config-input-nickname"><i class="icon-tasks"></i> Nickname</label>

View File

@ -16,6 +16,7 @@
var RED = require("../../red/red");
var irc = require("irc");
var util = require("util");
// The Server Definition - this opens (and closes) the connection
function IRCServerNode(n) {
@ -26,13 +27,15 @@ function IRCServerNode(n) {
this.ircclient = new irc.Client(this.server, this.nickname, {
channels: [this.channel]
});
this.ircclient.addListener('error', function(message) {
util.log('[irc] '+ JSON.stringify(message));
});
this._close = function() {
this.ircclient.disconnect();
}
}
RED.nodes.registerType("irc-server",IRCServerNode);
IRCServerNode.prototype.close = function() {
this._close();
}
@ -46,17 +49,12 @@ function IrcInNode(n) {
this.ircclient = this.serverConfig.ircclient;
var node = this;
this.ircclient.addListener('message', function (from, to, message) {
console.log(from + ' => ' + to + ': ' + message);
var msg = { "topic":from, "to":to, "payload":message };
node.send(msg);
});
this.ircclient.addListener('error', function(message) {
node.error(JSON.stringify(message));
});
}
RED.nodes.registerType("irc in",IrcInNode);
@ -71,7 +69,7 @@ function IrcOutNode(n) {
var node = this;
this.on("input", function(msg) {
console.log(msg);
//console.log(msg,node.channel);
if (node.sendAll) {
node.ircclient.say(node.channel, JSON.stringify(msg));
}