- Fixed some nodes not matching how their docs describe how they function (such as node configuration should always take precedence over inputs)
112 lines
4.0 KiB
HTML
112 lines
4.0 KiB
HTML
<script type="text/javascript">
|
|
RED.nodes.registerType('matrix-send-message',{
|
|
category: 'matrix',
|
|
color: '#00b7ca',
|
|
icon: "matrix.png",
|
|
outputLabels: ["success", "error"],
|
|
inputs:1,
|
|
outputs:2,
|
|
defaults: {
|
|
name: { value: null },
|
|
server: { value: "", type: "matrix-server-config" },
|
|
roomId: { value: null },
|
|
messageType: { value: 'm.text' },
|
|
messageFormat: { value: '' },
|
|
},
|
|
label: function() {
|
|
return this.name || "Send Message";
|
|
},
|
|
paletteLabel: 'Send Message'
|
|
});
|
|
</script>
|
|
|
|
<script type="text/html" data-template-name="matrix-send-message">
|
|
<div class="form-row">
|
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-input-server"><i class="fa fa-user"></i> Matrix Server Config</label>
|
|
<input type="text" id="node-input-server">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-input-roomId"><i class="fa fa-user"></i> Room ID</label>
|
|
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-input-messageType">
|
|
Message Type
|
|
</label>
|
|
<select id="node-input-messageType">
|
|
<option value="m.text">m.text</option>
|
|
<option value="m.notice">m.notice</option>
|
|
<option value="msg.type">msg.type input</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-row form-tips">
|
|
It's recommended to use m.notice for bots because the message will render in a lighter text (at least in Element client) for users to distinguish bot and real user messages.
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-input-messageFormat">
|
|
Message Format
|
|
</label>
|
|
<select id="node-input-messageFormat">
|
|
<option value="">Default (plaintext)</option>
|
|
<option value="html">HTML</option>
|
|
<option value="msg.format">msg.format input</option>
|
|
</select>
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/html" data-help-name="matrix-send-message">
|
|
<h3>Details</h3>
|
|
<p>Sends a message to a Matrix room. Messages are auto encrypted if necessary.</p>
|
|
|
|
<h3>Inputs</h3>
|
|
<dl class="message-properties">
|
|
<dt>msg.topic
|
|
<span class="property-type">string</span>
|
|
</dt>
|
|
<dd> Room ID to send image to. Optional if configured on the node. If configured on the node this input will be overridden.</dd>
|
|
|
|
<dt>msg.payload
|
|
<span class="property-type">string</span>
|
|
</dt>
|
|
<dd> the message text. </dd>
|
|
|
|
<dt class="optional">msg.formatted_payload
|
|
<span class="property-type">string</span>
|
|
</dt>
|
|
<dd> the formatted HTML message (uses msg.payload if not defined). This only affects HTML messages.</dd>
|
|
|
|
<dt class="optional">msg.type
|
|
<span class="property-type">string | null</span>
|
|
</dt>
|
|
<dd> This is only used and required when configured so on the node. Must be set to either <code>'m.text'</code> or <code>'m.notice'</code></dd>
|
|
|
|
<dt class="optional">msg.format
|
|
<span class="property-type">string | null</span>
|
|
</dt>
|
|
<dd> This is only used and required when configured so on the node. Set to <code>null</code> for plain text and <code>'html'</code> for HTML.</dd>
|
|
</dl>
|
|
|
|
<h3>Outputs</h3>
|
|
<ol class="node-ports">
|
|
<li>Success
|
|
<dl class="message-properties">
|
|
<dt>msg.eventId <span class="property-type">string</span></dt>
|
|
<dd>the eventId from the posted message.</dd>
|
|
</dl>
|
|
</li>
|
|
<li>Error
|
|
<dl class="message-properties">
|
|
<dt>msg.error <span class="property-type">string</span></dt>
|
|
<dd>the error that occurred.</dd>
|
|
</dl>
|
|
</li>
|
|
</ol>
|
|
</script> |