1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Improve IRC UI options to Fix Issue #53. Now a three way select - either send whole msg object to channel, just msg.payload to channel or msg.payload to users specified in msg.topic

This commit is contained in:
Dave C-J 2013-11-02 12:12:47 +00:00
parent ff5f2da7e7
commit 09348eb353
2 changed files with 72 additions and 62 deletions

View File

@ -57,9 +57,12 @@
<input type="text" id="node-input-ircserver"> <input type="text" id="node-input-ircserver">
</div> </div>
<div class="form-row"> <div class="form-row">
<label>&nbsp;</label> <label for="node-input-sendObject"><i class="icon-check"></i> Action</label>
<input type="checkbox" id="node-input-sendObject" placeholder="" style="display: inline-block; width: auto; vertical-align: top;"> <select type="text" id="node-input-sendObject" style="display: inline-block; vertical-align: middle; width:70%;">
<label for="node-input-sendObject" style="width: 70%;">Send complete msg object ?</label> <option value="pay">Send msg.payload to channel</option>
<option value="true">Send msg.payload to id in msg.topic</option>
<option value="false">Send complete msg object to channel</option>
</select>
</div> </div>
<div class="form-row"> <div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label> <label for="node-input-name"><i class="icon-tag"></i> Name</label>
@ -70,8 +73,8 @@
<script type="text/x-red" data-help-name="irc out"> <script type="text/x-red" data-help-name="irc out">
<p>Sends messages to a channel on an IRC server</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 send just the <b>msg.payload</b>, or the complete <b>msg</b> object to the selected channel,
<p>You can either just send the <b>msg.payload</b>, or you can send the complete <b>msg</b> object.</p> or you can select to use <b>msg.topic</b> to send the <b>msg.payload</b> to a specific user in the channel (private conversation).</p>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
@ -79,7 +82,7 @@
category: 'social-output', category: 'social-output',
defaults: { defaults: {
name: {value:""}, name: {value:""},
sendObject: {value:false}, sendObject: {value:"pay", required:true},
ircserver: {type:"irc-server", required:true} ircserver: {type:"irc-server", required:true}
}, },
color:"Silver", color:"Silver",

View File

@ -79,13 +79,20 @@ function IrcOutNode(n) {
this.on("input", function(msg) { this.on("input", function(msg) {
//console.log(msg,node.channel); //console.log(msg,node.channel);
if (node.sendAll) { if (msg._topic) { delete msg._topic; }
if (node.sendAll == "false") {
node.ircclient.say(node.channel, JSON.stringify(msg)); node.ircclient.say(node.channel, JSON.stringify(msg));
} }
else {
if (typeof msg.payload === "object") { msg.payload = JSON.stringify(msg.payload); }
if (node.sendAll == "pay") {
node.ircclient.say(node.channel, msg.payload);
}
else { else {
var to = msg.topic || node.channel; var to = msg.topic || node.channel;
node.ircclient.say(to, msg.payload); node.ircclient.say(to, msg.payload);
} }
}
}); });
} }
RED.nodes.registerType("irc out",IrcOutNode); RED.nodes.registerType("irc out",IrcOutNode);