-
Notifications
You must be signed in to change notification settings - Fork 0
/
nc-talk-bot.html
143 lines (135 loc) · 5.21 KB
/
nc-talk-bot.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
<script type="text/javascript">
RED.nodes.registerType('nc-talk-bot-credentials', {
category: 'config',
defaults: {
cname: {value: '', required: false},
address: {value: 'https://your.server.com', required: true},
insecure: {value: '', required: false}
},
credentials: {
url: {type:'text'},
secret: {type:'password'}
},
label: function() {
if (this.cname.length) {
return this.cname + ' (' + this.address + ')'
}
return this.address
}
})
</script>
<script type="text/x-red" data-template-name="nc-talk-bot-credentials">
<div class="form-row">
<label for="node-config-input-cname"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-cname">
</div>
<div class="form-row">
<label for="node-config-input-address"><i class="fa fa-server"></i> Server</label>
<input type="text" id="node-config-input-address">
</div>
<div class="form-row">
<label for="node-config-input-insecure"><i class="fa fa-server"></i> Security</label>
<input type="checkbox" value="1" id="node-config-input-insecure"
style="display: inline-block; width: auto; vertical-align: top">
<span style="width: 70%">Accept self signed certificates</span>
</div>
<div class="form-row">
<label for="node-config-input-user"><i class="fa fa-server"></i> Username</label>
<input type="text" id="node-config-input-user">
</div>
<div class="form-row">
<label for="node-config-input-pass"><i class="fa fa-key"></i> Password</label>
<input type="password" id="node-config-input-pass">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('nc-talk-bot', {
category: 'nextcloud',
color: '#0082C9',
paletteLabel: 'Talk Bot',
defaults: {
nodeName: { value: '', required: false },
ncUrl: { value: '', required: true },
secret: { value: '', required: true },
},
inputs: 1,
outputs: 1,
icon: 'nextcloud.png',
label: function () {
return this.nodeName || 'Nextcloud Talk Bot Message';
},
});
</script>
<script type="text/x-red" data-template-name="nc-talk-bot">
<div class="form-row">
<label for="node-input-nodeName"><i class="fa fa-link"></i>Name</label>
<input type="text" id="node-input-nodeName" placeholder="">
</div>
<div class="form-row">
<label for="node-input-ncUrl"><i class="fa fa-link"></i> Nextcloud URL</label>
<input type="text" id="node-input-ncUrl" placeholder="https://yout-nextcloud-url.org">
</div>
<div class="form-row">
<label for="node-input-secret"><i class="fa fa-key"></i> Secret</label>
<input type="password" id="node-input-secret">
</div>
</script>
<script type="text/x-red" data-help-name="nc-talk-bot">
<p>Sends message to a given room by a Nextcloud Talk Bot.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<dd> Incoming message and room token will trigger the action to send message.
The JSON must contain the following properties:</dd>
<dt>payload.message
<span class="property-type">string</span></dt>
<dd>Message is the text to send to the room.</dd>
<dt>payload.token
<span class="property-type">string</span>
</dt>
<dd>Room token is belongs the the chat room where the message should be sent to.</dd>
<h3>Sample input JSON in payload</h3>
<p>
<code>
{
"message": "Your Message Here",
"token": "your_room_token"
}
</code>
</p>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<dd>Outputs the ocs metadata with status.</dd>
<dt class="optional">payload.ocs.meta <span class="property-type">object</span></dt>
<dd>Response details as follows.</dd>
<dt class="optional">payload.ocs.meta.status <span class="property-type">string</span></dt>
<dd>The status message of the response.</dd>
<dt class="optional">payload.ocs.meta.statuscode <span class="property-type">integer</span></dt>
<dd>The statuscode of the response.</dd>
<dt class="optional">payload.ocs.meta.message <span class="property-type">integer</span></dt>
<dd>The message returned with the response.</dd>
<dt class="optional">payload.ocs.data <span class="property-type">array</span></dt>
<dd>Empty array.</dd>
<h3>Sample output JSON from payload</h3>
<p>
<code>
{
"ocs": {
"meta":{
"status":"ok",
"statuscode":201,
"message":"OK"
},
"data":[]
}
}
</code>
</p>
</dl>
</script>