forked from node-red/node-red-nodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
91-irc.html
238 lines (228 loc) · 9.99 KB
/
91-irc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<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> <span data-i18n="irc.label.ircserver"></span></label>
<input type="text" id="node-input-ircserver">
</div>
<div class="form-row">
<label for="node-input-channel"><i class="fa fa-random"></i> <span data-i18n="irc.label.channel"></span></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> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-tips"><span data-i18n="[html]irc.tip.in"></span></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>topic</td>
<td>a topic has been changed on a joined 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(/^#/)}
},
credentials: {
username: {type:"text"},
password: {type:"password"}
},
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> <span data-i18n="irc.label.ircserver"></span></label>
<input type="text" id="node-input-ircserver">
</div>
<div class="form-row">
<label for="node-input-channel"><i class="fa fa-random"></i> <span data-i18n="irc.label.channel"></span></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> <span data-i18n="irc.label.action"></span></label>
<select type="text" id="node-input-sendObject" style="display: inline-block; vertical-align: middle; width:70%;">
<option value="pay" data-i18n="irc.payload"></option>
<option value="true" data-i18n="irc.topic"></option>
<option value="false" data-i18n="irc.msg"></option>
</select>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-tips"><span data-i18n="[html]irc.tip.out"></span></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> <span data-i18n="irc.label.ircserver"></span></label>
<input type="text" id="node-config-input-server" placeholder="irc.freenode.net" style="width: 45%;" >
<label for="node-config-input-port" style="margin-left: 10px; width: 35px; "> <span data-i18n="irc.label.port"></span></label>
<input type="text" id="node-config-input-port" style="width:45px">
</div>
<div class="form-row">
<label> </label>
<input type="checkbox" id="node-config-input-ssl" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-ssl" style="width: 70%;"><span data-i18n="irc.label.ssl"></span></label>
</div>
<div class="form-row" id="certrow">
<label> </label>
<input type="checkbox" id="node-config-input-cert" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-cert" style="width: 70%;"><span data-i18n="irc.label.self"></span></label>
</div>
<div class="form-row">
<label for="node-config-input-nickname"><i class="fa fa-heart"></i> <span data-i18n="irc.label.nickname"></span></label>
<input type="text" id="node-config-input-nickname">
</div>
<div class="form-row">
<label for="node-config-input-username"><i class="fa fa-user"></i> <span data-i18n="irc.label.username"></span></label>
<input type="text" id="node-config-input-username" data-i18n="[placeholder]irc.placeholder.ifreq">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-lock"></i> <span data-i18n="irc.label.password"></span></label>
<input type="text" id="node-config-input-password" data-i18n="[placeholder]irc.placeholder.ifreq">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('irc-server',{
category: 'config',
defaults: {
server: {value:"",required:true},
port: {value:"6667"},
ssl: {value:false},
cert: {value:false},
nickname: {value:"",required:true}
},
credentials: {
username: {type:"text"},
password: {type:"password"}
},
label: function() {
return this.server;
},
oneditprepare: function() {
$("#node-config-input-ssl").change(function() {
if ($("#node-config-input-ssl").is(":checked")) {
$("#certrow").show();
}
else {
$("#certrow").hide();
}
});
},
oneditsave: function() {
this.ssl = $("#node-config-input-ssl").is(":checked");
this.cert = $("#node-config-input-cert").is(":checked");
}
});
</script>