[CCSDK-28] populated the seed code for dgbuilder
[ccsdk/distribution.git] / dgbuilder / core_nodes / social / 91-irc.html
1 <!--
2   Copyright 2013 IBM Corp.
3
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7
8   http://www.apache.org/licenses/LICENSE-2.0
9
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15 -->
16
17 <script type="text/x-red" data-template-name="irc in">
18     <div class="form-row">
19         <label for="node-input-ircserver"><i class="fa fa-globe"></i> IRC Server</label>
20         <input type="text" id="node-input-ircserver">
21     </div>
22     <div class="form-row">
23         <label for="node-input-channel"><i class="fa fa-random"></i> Channel</label>
24         <input type="text" id="node-input-channel" placeholder="#nodered">
25     </div>
26     <div class="form-row">
27         <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
28         <input type="text" id="node-input-name" placeholder="Name">
29     </div>
30     <div class="form-tips">The channel to join must start with a # (as per normal irc rules...)<br/>
31     You may join multiple channels by comma separating a list - #chan1,#chan2,etc.</div>
32 </script>
33
34 <script type="text/x-red" data-help-name="irc in">
35     <p>Connects to a channel on an IRC server.</p>
36     <p>You may join multiple channels by comma separating a list - #chan1,#chan2,#etc.</p>
37     <p>Any messages on that channel will appear on the <code>msg.payload</code> at the output,
38     while <code>msg.topic</code> will contain who it is from.
39     <code>msg.to</code> contains either the name of the channel or PRIV in the case of a pm.</p>
40     <p>The second output provides a <code>msg.payload</code> that has any status messages such as joins, parts, kicks etc.</p>
41     <p>The type of the status message is set as <code>msg.payload.type</code>.</p>
42     <p>The possible status types are: <br />
43     <table border="1" cellpadding="1" cellspacing="1">
44     <thead>
45         <tr>
46             <th scope="col">Type</th>
47             <th scope="col">Description</th>
48         </tr>
49     </thead>
50     <tbody>
51         <tr>
52             <td>message</td>
53             <td>message is sent into the channel</td>
54         </tr>
55         <tr>
56             <td>pm</td>
57             <td>private message to the bot</td>
58         </tr>
59         <tr>
60             <td>join</td>
61             <td>a user joined the channel (also triggered when the bot joins a channel)</td>
62         </tr>
63         <tr>
64             <td>invite</td>
65             <td>the bot is being invited to a channel</td>
66         </tr>
67         <tr>
68             <td>part</td>
69             <td>a user leaves a channel</td>
70         </tr>
71         <tr>
72             <td>quit</td>
73             <td>a user quits a channel</td>
74         </tr>
75         <tr>
76             <td>kick</td>
77             <td>a user is kicked from a channel</td>
78         </tr>
79         <tr>
80             <td>names</td>
81             <td>retrieves the list of users when the bot joins a channel</td>
82         </tr>
83     </tbody>
84 </table>
85 </p>
86 </script>
87
88 <script type="text/javascript">
89     RED.nodes.registerType('irc in',{
90         category: 'social-input',
91         defaults: {
92             name: {value:""},
93             ircserver: {type:"irc-server", required:true},
94             channel: {value:"",required:true,validate:RED.validators.regex(/^#/)}
95         },
96         color:"Silver",
97         inputs:0,
98         outputs:2,
99         icon: "hash.png",
100         label: function() {
101             var ircNode = RED.nodes.node(this.ircserver);
102             return this.name || (ircNode ? ircNode.label() : "irc");
103         },
104         labelStyle: function() {
105             return this.name?"node_label_italic":"";
106         },
107         oneditprepare: function() {
108             if ((this.ircserver !== undefined) && (this.ircserver !== "")) {
109                 this.channel = this.channel || RED.nodes.node(this.ircserver).channel;
110                 $("#node-input-channel").val(this.channel);
111             }
112             else { this.channel = this.channel; }
113             $("#node-input-channel").val(this.channel);
114         }
115     });
116 </script>
117
118
119 <script type="text/x-red" data-template-name="irc out">
120     <div class="form-row">
121         <label for="node-input-ircserver"><i class="fa fa-globe"></i> IRC Server</label>
122         <input type="text" id="node-input-ircserver">
123     </div>
124     <div class="form-row">
125         <label for="node-input-channel"><i class="fa fa-random"></i> Channel</label>
126         <input type="text" id="node-input-channel" placeholder="#nodered">
127     </div>
128     <div class="form-row">
129         <label for="node-input-sendObject"><i class="fa fa-arrows"></i> Action</label>
130         <select type="text" id="node-input-sendObject" style="display: inline-block; vertical-align: middle; width:70%;">
131             <option value="pay">Send payload to channel(s)</option>
132             <option value="true">Use msg.topic to set nickname or channel(s)</option>
133             <option value="false">Send complete msg object to channel(s)</option>
134         </select>
135     </div>
136     <div class="form-row">
137         <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
138         <input type="text" id="node-input-name" placeholder="Name">
139     </div>
140     <div class="form-tips">The channel to join must start with a # (as per normal irc rules...)<br/>
141     Sending the complete object will stringify the whole msg object before sending.</div>
142 </script>
143
144 <script type="text/x-red" data-help-name="irc out">
145     <p>Sends messages to a channel on an IRC server</p>
146     <p>You can send just the <code>msg.payload</code>, or the complete <code>msg</code> object to the selected channel,
147     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>
148     <p>If multiple output channels are listed (eg. #chan1,#chan2), then the message will be sent to all of them.</p>
149     <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>
150     <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>
151 </script>
152
153 <script type="text/javascript">
154     RED.nodes.registerType('irc out',{
155         category: 'social-output',
156         defaults: {
157             name: {value:""},
158             sendObject: {value:"pay", required:true},
159             ircserver: {type:"irc-server", required:true},
160             channel: {value:"",required:true,validate:RED.validators.regex(/^#/)}
161         },
162         color:"Silver",
163         inputs:1,
164         outputs:0,
165         icon: "hash.png",
166         align: "right",
167         label: function() {
168             return this.name || (this.ircserver ? RED.nodes.node(this.ircserver).label() : "irc");
169         },
170         labelStyle: function() {
171             return this.name?"node_label_italic":"";
172         },
173         oneditprepare: function() {
174             if ((this.ircserver !== undefined) && (this.ircserver !== "")) {
175                 this.channel = this.channel || RED.nodes.node(this.ircserver).channel;
176                 $("#node-input-channel").val(this.channel);
177             }
178             else { this.channel = this.channel; }
179         }
180     });
181 </script>
182
183
184 <script type="text/x-red" data-template-name="irc-server">
185     <div class="form-row">
186         <label for="node-config-input-server"><i class="fa fa-globe"></i> IRC Server</label>
187         <input type="text" id="node-config-input-server" placeholder="irc.freenode.net">
188     </div>
189     <div class="form-row">
190         <label for="node-config-input-nickname"><i class="fa fa-user"></i> Nickname</label>
191         <input type="text" id="node-config-input-nickname" placeholder="joe123">
192     </div>
193 </script>
194
195 <script type="text/javascript">
196     RED.nodes.registerType('irc-server',{
197         category: 'config',
198         defaults: {
199             server: {value:"",required:true},
200             nickname: {value:"",required:true}
201         },
202         label: function() {
203             return this.server;
204         }
205     });
206 </script>