mirror of
https://github.com/Skylar-Tech/node-red-contrib-matrix-chat.git
synced 2025-04-20 04:53:06 -06:00
147 lines
5.7 KiB
HTML
147 lines
5.7 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 },
|
|
message: { value: null },
|
|
messageType: { value: 'm.text' },
|
|
messageFormat: { value: '' },
|
|
replaceMessage : { value: false }
|
|
},
|
|
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="fa fa-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-comments"></i> Room ID</label>
|
|
<input type="text" id="node-input-roomId" placeholder="msg.topic">
|
|
<pre class="form-tips" id="node-input-roomId-error" style="color: #721c24;background-color: #f8d7da;border-color: #f5c6cb;margin-bottom: 12px;margin-top: 12px;display:none;"></pre>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-input-message"><i class="fa fa-comment"></i> Message</label>
|
|
<textarea id="node-input-message" placeholder="msg.payload" style="width: 70%;"></textarea>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-replaceMessage"
|
|
style="width: auto; margin-left: 105px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-replaceMessage" style="width: auto;max-width:50%;">
|
|
Update existing message if <code>msg.eventId</code> is set
|
|
</label>
|
|
</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 type="text/javascript">
|
|
$(function(){
|
|
$("#node-input-roomId").on("keyup", function() {
|
|
if($(this).val() && !$(this).val().startsWith("!")) {
|
|
$("#node-input-roomId-error").html(`Room IDs start with exclamation point "!"<br />Example: !OGEhHVWSdvArJzumhm:matrix.org`).show();
|
|
} else {
|
|
$("#node-input-roomId-error").hide();
|
|
}
|
|
}).trigger('keyup');
|
|
});
|
|
</script>
|
|
</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. If configured on the node this is ignored otherwise it required. </dd>
|
|
|
|
<dt>msg.replace
|
|
<span class="property-type">bool</span>
|
|
</dt>
|
|
<dd> If true and <code>msg.eventId</code> is present it will update an existing message. Posts a new message if false or <code>msg.eventId</code> is missing. </dd>
|
|
|
|
<dt class="optional">msg.formatted_payload
|
|
<span class="property-type">string</span>
|
|
</dt>
|
|
<dd> the formatted HTML message (uses <code>msg.payload</code> 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> |