Add main IRC node to node-red-nodes in anticipation of deprecation from core

This commit is contained in:
dceejay 2015-04-08 09:57:09 +01:00
parent 6158aa2b73
commit 25c10cfd58
5 changed files with 755 additions and 0 deletions

206
social/irc/91-irc.html Normal file
View File

@ -0,0 +1,206 @@
<!--
Copyright 2013,2014 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/x-red" data-template-name="irc in">
<div class="form-row">
<label for="node-input-ircserver"><i class="fa fa-globe"></i> IRC Server</label>
<input type="text" id="node-input-ircserver">
</div>
<div class="form-row">
<label for="node-input-channel"><i class="fa fa-random"></i> Channel</label>
<input type="text" id="node-input-channel" placeholder="#nodered">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">The channel to join must start with a # (as per normal irc rules...)<br/>
You may join multiple channels by comma separating a list - #chan1,#chan2,etc.</div>
</script>
<script type="text/x-red" data-help-name="irc in">
<p>Connects to a channel on an IRC server.</p>
<p>You may join multiple channels by comma separating a list - #chan1,#chan2,#etc.</p>
<p>Any messages on that channel will appear on the <code>msg.payload</code> at the output,
while <code>msg.topic</code> will contain who it is from.
<code>msg.to</code> contains either the name of the channel or PRIV in the case of a pm.</p>
<p>The second output provides a <code>msg.payload</code> that has any status messages such as joins, parts, kicks etc.</p>
<p>The type of the status message is set as <code>msg.payload.type</code>.</p>
<p>The possible status types are: <br />
<table border="1" cellpadding="1" cellspacing="1">
<thead>
<tr>
<th scope="col">Type</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>message</td>
<td>message is sent into the channel</td>
</tr>
<tr>
<td>pm</td>
<td>private message to the bot</td>
</tr>
<tr>
<td>join</td>
<td>a user joined the channel (also triggered when the bot joins a channel)</td>
</tr>
<tr>
<td>invite</td>
<td>the bot is being invited to a channel</td>
</tr>
<tr>
<td>part</td>
<td>a user leaves a channel</td>
</tr>
<tr>
<td>quit</td>
<td>a user quits a channel</td>
</tr>
<tr>
<td>kick</td>
<td>a user is kicked from a channel</td>
</tr>
<tr>
<td>names</td>
<td>retrieves the list of users when the bot joins a channel</td>
</tr>
</tbody>
</table>
</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('irc in',{
category: 'social-input',
defaults: {
name: {value:""},
ircserver: {type:"irc-server", required:true},
channel: {value:"",required:true,validate:RED.validators.regex(/^#/)}
},
color:"Silver",
inputs:0,
outputs:2,
icon: "hash.png",
label: function() {
var ircNode = RED.nodes.node(this.ircserver);
return this.name || (ircNode ? ircNode.label() : "irc");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
if ((this.ircserver !== undefined) && (this.ircserver !== "")) {
this.channel = this.channel || RED.nodes.node(this.ircserver).channel;
$("#node-input-channel").val(this.channel);
}
else { this.channel = this.channel; }
$("#node-input-channel").val(this.channel);
}
});
</script>
<script type="text/x-red" data-template-name="irc out">
<div class="form-row">
<label for="node-input-ircserver"><i class="fa fa-globe"></i> IRC Server</label>
<input type="text" id="node-input-ircserver">
</div>
<div class="form-row">
<label for="node-input-channel"><i class="fa fa-random"></i> Channel</label>
<input type="text" id="node-input-channel" placeholder="#nodered">
</div>
<div class="form-row">
<label for="node-input-sendObject"><i class="fa fa-arrows"></i> Action</label>
<select type="text" id="node-input-sendObject" style="display: inline-block; vertical-align: middle; width:70%;">
<option value="pay">Send payload to channel(s)</option>
<option value="true">Use msg.topic to set nickname or channel(s)</option>
<option value="false">Send complete msg object to channel(s)</option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">The channel to join must start with a # (as per normal irc rules...)<br/>
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>Sends messages to a channel on an IRC server</p>
<p>You can send just the <code>msg.payload</code>, or the complete <code>msg</code> object to the selected channel,
or you can select to use <code>msg.topic</code> to send the <code>msg.payload</code> to a specific user (private message) or channel.</p>
<p>If multiple output channels are listed (eg. #chan1,#chan2), then the message will be sent to all of them.</p>
<p><b>Note:</b> you can only send to channels you have previously joined so they MUST be specified in the node - even if you then decide to use a subset in msg.topic</p>
<p>You may send RAW commands using <code>msg.raw</code> - This must contain an array of parameters - eg. <pre>["privmsg","#nodered","Hello world"]</pre></p>
</script>
<script type="text/javascript">
RED.nodes.registerType('irc out',{
category: 'social-output',
defaults: {
name: {value:""},
sendObject: {value:"pay", required:true},
ircserver: {type:"irc-server", required:true},
channel: {value:"",required:true,validate:RED.validators.regex(/^#/)}
},
color:"Silver",
inputs:1,
outputs:0,
icon: "hash.png",
align: "right",
label: function() {
return this.name || (this.ircserver ? RED.nodes.node(this.ircserver).label() : "irc");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
if ((this.ircserver !== undefined) && (this.ircserver !== "")) {
this.channel = this.channel || RED.nodes.node(this.ircserver).channel;
$("#node-input-channel").val(this.channel);
}
else { this.channel = this.channel; }
}
});
</script>
<script type="text/x-red" data-template-name="irc-server">
<div class="form-row">
<label for="node-config-input-server"><i class="fa fa-globe"></i> IRC Server</label>
<input type="text" id="node-config-input-server" placeholder="irc.freenode.net">
</div>
<div class="form-row">
<label for="node-config-input-nickname"><i class="fa fa-user"></i> Nickname</label>
<input type="text" id="node-config-input-nickname" placeholder="joe123">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('irc-server',{
category: 'config',
defaults: {
server: {value:"",required:true},
nickname: {value:"",required:true}
},
label: function() {
return this.server;
}
});
</script>

277
social/irc/91-irc.js Normal file
View File

@ -0,0 +1,277 @@
/**
* Copyright 2013,2014 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
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);
this.server = n.server;
this.channel = n.channel;
this.nickname = n.nickname;
this.lastseen = 0;
this.ircclient = null;
this.on("close", function() {
if (this.ircclient != null) {
this.ircclient.removeAllListeners();
this.ircclient.disconnect();
}
});
}
RED.nodes.registerType("irc-server",IRCServerNode);
// The Input Node
function IrcInNode(n) {
RED.nodes.createNode(this,n);
this.ircserver = n.ircserver;
this.serverConfig = RED.nodes.getNode(this.ircserver);
this.channel = n.channel || this.serverConfig.channel;
var node = this;
if (node.serverConfig.ircclient === null) {
node.log("CONNECT: "+node.serverConfig.server);
node.status({fill:"grey",shape:"dot",text:"connecting"});
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname,{autoConnect:true,autoRejoin:false,floodProtection:true,retryDelay:20000});
node.serverConfig.ircclient.setMaxListeners(0);
node.serverConfig.ircclient.addListener('error', function(message) {
if (RED.settings.verbose) { node.log("ERR: "+JSON.stringify(message)); }
});
node.serverConfig.ircclient.addListener('netError', function(message) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log("NET: "+JSON.stringify(message)); }
node.status({fill:"red",shape:"ring",text:"net error"});
});
node.serverConfig.ircclient.addListener('connect', function() {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log("CONNECTED "); }
});
node.serverConfig.ircclient.addListener('registered', function(message) {
node.serverConfig.lastseen = Date.now();
node.log(node.serverConfig.ircclient.nick+" ONLINE: "+message.server);
node.status({fill:"yellow",shape:"dot",text:"connected"});
node.serverConfig.ircclient.join( node.channel, function(data) {
node.log(data+" JOINED: "+node.channel);
node.status({fill:"green",shape:"dot",text:"joined"});
});
});
node.serverConfig.ircclient.addListener('ping', function(server) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log("PING from "+JSON.stringify(server)); }
node.status({fill:"green",shape:"dot",text:"ok"});
});
node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log("QUIT: "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); }
node.status({fill:"grey",shape:"ring",text:"quit"});
//node.serverConfig.ircclient.disconnect( function() {
// node.serverConfig.ircclient.connect();
//});
//if (RED.settings.verbose) { node.log("restart"); } // then retry
});
node.serverConfig.ircclient.addListener('raw', function (message) { // any message received means we are alive
//console.log("RAW:"+JSON.stringify(message));
if (message.commandType === "reply") {
//console.log("RAW:"+JSON.stringify(message));
node.serverConfig.lastseen = Date.now();
}
});
node.recon = setInterval( function() {
//console.log("CHK ",(Date.now()-node.serverConfig.lastseen)/1000);
if ((Date.now()-node.serverConfig.lastseen) > 240000) { // if more than 4 mins since last seen
node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link
}
if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins
//node.serverConfig.ircclient.disconnect();
//node.serverConfig.ircclient.connect();
node.status({fill:"grey",shape:"ring",text:"no connection"});
if (RED.settings.verbose) { node.log("CONNECTION LOST ?"); }
}
//node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link
}, 60000); // check every 1 min
//node.serverConfig.ircclient.connect();
}
else { node.status({text:""}); }
node.ircclient = node.serverConfig.ircclient;
node.ircclient.addListener('registered', function(message) {
//node.log(node.ircclient.nick+" ONLINE");
node.status({fill:"yellow",shape:"dot",text:"connected"});
node.ircclient.join( node.channel, function(data) {
// node.log(data+" JOINED "+node.channel);
node.status({fill:"green",shape:"dot",text:"joined"});
});
});
node.ircclient.addListener('message', function (from, to, message) {
//node.log(from + ' => ' + to + ' : ' + message);
if (~node.channel.toLowerCase().indexOf(to.toLowerCase())) {
var msg = { "topic":from, "from":from, "to":to, "payload":message };
node.send([msg,null]);
}
//else { console.log(node.channel,to); }
});
node.ircclient.addListener('pm', function(from, message) {
//node.log("PM => "+from + ': ' + message);
var msg = { "topic":from, "from":from, "to":"PRIV", "payload":message };
node.send([msg,null]);
});
node.ircclient.addListener('join', function(channel, who) {
var msg = { "payload": { "type":"join", "who":who, "channel":channel } };
node.send([null,msg]);
//node.log(who+' has joined '+channel);
});
node.ircclient.addListener('invite', function(channel, from, message) {
var msg = { "payload": { "type":"invite", "who":from, "channel":channel, "message":message } };
node.send([null,msg]);
//node.log(from+' sent invite to '+channel+': '+message);
});
node.ircclient.addListener('part', function(channel, who, reason) {
var msg = { "payload": { "type":"part", "who":who, "channel":channel, "reason":reason } };
node.send([null,msg]);
//node.log(who+' has left '+channel+': '+reason);
});
node.ircclient.addListener('quit', function(nick, reason, channels, message) {
var msg = { "payload": { "type":"quit", "who":nick, "channel":channels, "reason":reason } };
node.send([null,msg]);
//node.log(nick+' has quit '+channels+': '+reason);
});
node.ircclient.addListener('kick', function(channel, who, by, reason) {
var msg = { "payload": { "type":"kick", "who":who, "channel":channel, "by":by, "reason":reason } };
node.send([null,msg]);
//node.log(who+' was kicked from '+channel+' by '+by+': '+reason);
});
node.ircclient.addListener('names', function (channel, nicks) {
var msg = { "payload": { "type": "names", "channel": channel, "names": nicks} };
node.send([null, msg]);
});
node.ircclient.addListener('raw', function (message) { // any message means we are alive
node.serverConfig.lastseen = Date.now();
});
node.on("close", function() {
node.ircclient.removeAllListeners();
if (node.recon) { clearInterval(node.recon); }
});
}
RED.nodes.registerType("irc in",IrcInNode);
// The Output Node
function IrcOutNode(n) {
RED.nodes.createNode(this,n);
this.sendFlag = n.sendObject;
this.ircserver = n.ircserver;
this.serverConfig = RED.nodes.getNode(this.ircserver);
this.channel = n.channel || this.serverConfig.channel;
var node = this;
if (node.serverConfig.ircclient === null) {
node.log("CONNECT: "+node.serverConfig.server);
node.status({fill:"grey",shape:"dot",text:"connecting"});
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname,{autoConnect:true,autoRejoin:false,floodProtection:true,retryDelay:20000});
node.serverConfig.ircclient.setMaxListeners(0);
node.serverConfig.ircclient.addListener('error', function(message) {
if (RED.settings.verbose) { node.log("ERR: "+JSON.stringify(message)); }
});
node.serverConfig.ircclient.addListener('netError', function(message) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log("NET: "+JSON.stringify(message)); }
node.status({fill:"red",shape:"ring",text:"net error"});
});
node.serverConfig.ircclient.addListener('connect', function() {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log("CONNECTED "); }
});
node.serverConfig.ircclient.addListener('registered', function(message) {
node.serverConfig.lastseen = Date.now();
node.log(node.serverConfig.ircclient.nick+" ONLINE: "+message.server);
node.status({fill:"yellow",shape:"dot",text:"connected"});
node.serverConfig.ircclient.join( node.channel, function(data) {
node.log(data+" JOINED: "+node.channel);
node.status({fill:"green",shape:"dot",text:"joined"});
});
});
node.serverConfig.ircclient.addListener('ping', function(server) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log("PING from "+JSON.stringify(server)); }
node.status({fill:"green",shape:"dot",text:"ok"});
});
node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) {
node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log("QUIT: "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); }
node.status({fill:"grey",shape:"ring",text:"quit"});
//node.serverConfig.ircclient.disconnect( function() {
// node.serverConfig.ircclient.connect();
//});
//if (RED.settings.verbose) { node.log("restart"); } // then retry
});
node.serverConfig.ircclient.addListener('raw', function (message) { // any message received means we are alive
//console.log("RAW:"+JSON.stringify(message));
if (message.commandType === "reply") {
//console.log("RAW:"+JSON.stringify(message));
node.serverConfig.lastseen = Date.now();
}
});
node.recon = setInterval( function() {
//console.log("CHK ",(Date.now()-node.serverConfig.lastseen)/1000);
if ((Date.now()-node.serverConfig.lastseen) > 240000) { // if more than 4 mins since last seen
node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link
}
if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins
//node.serverConfig.ircclient.disconnect();
//node.serverConfig.ircclient.connect();
node.status({fill:"grey",shape:"ring",text:"no connection"});
if (RED.settings.verbose) { node.log("CONNECTION LOST ?"); }
}
//node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link
}, 60000); // check every 1 min
//node.serverConfig.ircclient.connect();
}
else { node.status({text:""}); }
node.ircclient = node.serverConfig.ircclient;
node.on("input", function(msg) {
if (Object.prototype.toString.call( msg.raw ) === '[object Array]') {
if (RED.settings.verbose) { node.log("RAW command:"+msg.raw); }
node.ircclient.send.apply(node.ircclient,msg.raw);
}
else {
if (msg._topic) { delete msg._topic; }
var ch = node.channel.split(","); // split on , so we can send to multiple
if (node.sendFlag == "true") { // override channels with msg.topic
if ((msg.hasOwnProperty('topic'))&&(typeof msg.topic === "string")) {
ch = msg.topic.split(","); // split on , so we can send to multiple
}
else { node.warn("msg.topic not set"); }
}
for (var c = 0; c < ch.length; c++) {
if (node.sendFlag == "false") { // send whole message object to each channel
node.ircclient.say(ch[c], JSON.stringify(msg));
}
else { // send just the payload to each channel
if (typeof msg.payload === "object") { msg.payload = JSON.stringify(msg.payload); }
node.ircclient.say(ch[c], msg.payload);
}
}
}
});
node.on("close", function() {
node.ircclient.removeAllListeners();
if (node.recon) { clearInterval(node.recon); }
});
}
RED.nodes.registerType("irc out",IrcOutNode);
}

177
social/irc/LICENSE Normal file
View File

@ -0,0 +1,177 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

71
social/irc/README.md Normal file
View File

@ -0,0 +1,71 @@
node-red-node-irc
=================
A <a href="http://nodered.org" target="_new">Node-RED</a> node to talk to an IRC server.
**Note** : This is the same node as is/was in the core of Node-RED. If you already
have it installed you do NOT need this node. However it will be deprecated from
the core in due course, at which point you will need to install it from here if
still required.
Install
-------
Run the following command in the root directory of your Node-RED install, usually
this is ~/.node-red .
npm install node-red-node-irc
During install there may be multiple messages about libiconv charset support.
These report as failure to compile errors - but are warnings and the node will
still install (assuming nothing else failed) and you'll be able to use it, just
not the character set features.
Usage
-----
Provides two nodes - one to receive messages, and one to send.
###Input
Connects to an IRC server to receive messages.</p>
The **IRC Server** field needs to be configured to a valid server, and
you must select a default channel to join. You may join multiple channels by
comma separating a list - #chan1,#chan2,#etc.
Incoming messages will appear as **msg.payload** on the first output, while
**msg.topic** will contain who it is from. **msg.to** contains either the name of the channel or PRIV in the case of a pm.
The second output provides a **msg.payload** that has any status messages such as joins, parts, kicks etc.
The type of the status message is set as **msg.payload.type**. The possible status types are:
- **message** : message is sent into the channel
- **pm** : private message to the bot
- **join** : a user joined the channel (also triggered when the bot joins a channel)
- **invite** : the bot is being invited to a channel
- **part** : a user leaves a channel
- **quit** : a user quits a channe
- **kick** : a user is kicked from a channel
###Output
Sends messages to a channel on an IRC server.
You can send just the **msg.payload**, or the complete **msg** object to the
selected channel, or you can select to use **msg.topic** to send the
**msg.payload** to a specific user (private message) or channel.
If multiple output channels are listed (eg. #chan1,#chan2), then the message
will be sent to all of them.
**Note:** you can only send to channels you have previously joined so they
MUST be specified in the node - even if you then decide to use a subset of them in msg.topic
You may send RAW commands using **msg.raw** - This must contain an array of
parameters - eg.
["privmsg","#nodered","Hello world"]

24
social/irc/package.json Normal file
View File

@ -0,0 +1,24 @@
{
"name" : "node-red-node-irc",
"version" : "0.0.1",
"description" : "A Node-RED node to talk to an IRC server",
"dependencies" : {
"irc" : "0.3.11"
},
"repository" : {
"type":"git",
"url":"https://github.com/node-red/node-red-nodes/tree/master/social/irc"
},
"license": "Apache-2.0",
"keywords": [ "node-red", "irc" ],
"node-red" : {
"nodes" : {
"irc": "91-irc.js"
}
},
"author": {
"name": "Dave Conway-Jones",
"email": "ceejay@vnet.ibm.com",
"url": "http://nodered.org"
}
}