mirror of
https://github.com/Skylar-Tech/node-red-contrib-matrix-chat.git
synced 2025-04-19 20:43:04 -06:00
361 lines
14 KiB
HTML
361 lines
14 KiB
HTML
<script type="text/javascript">
|
|
RED.nodes.registerType('matrix-receive',{
|
|
category: 'matrix',
|
|
color: '#00b7ca',
|
|
icon: "matrix.png",
|
|
outputLabels: ["message"],
|
|
inputs:0,
|
|
outputs:1,
|
|
defaults: {
|
|
name: { value: null },
|
|
server: { type: "matrix-server-config" },
|
|
roomId: {"value": null},
|
|
acceptOwnEvents: {"value": false},
|
|
acceptText: {"value": true},
|
|
acceptEmotes: {"value": true},
|
|
acceptNotices: {"value": true},
|
|
acceptStickers: {"value": true},
|
|
acceptReactions: {"value": true},
|
|
acceptFiles: {"value": true},
|
|
acceptAudio: {"value": true},
|
|
acceptImages: {"value": true},
|
|
acceptVideos: {"value": true},
|
|
acceptLocations: {"value": true},
|
|
},
|
|
label: function() {
|
|
return this.name || "Matrix Receive";
|
|
},
|
|
paletteLabel: 'Receive'
|
|
});
|
|
</script>
|
|
|
|
<script type="text/html" data-template-name="matrix-receive">
|
|
<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-server"></i> Matrix Server</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">
|
|
<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-tips">Enter a single room, comma separated list of rooms, or leave blank to get from all</div>
|
|
<div class="form-row" style="margin-left: 100px;margin-top:10px;font-weight:bold;">
|
|
Timeline event filters
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptOwnEvents"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptOwnEvents" style="width: auto">
|
|
Receive own events
|
|
</label>
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptText"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptText" style="width: auto">
|
|
Accept text <code style="text-transform: none;">m.text</code>
|
|
</label>
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptNotices"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptNotices" style="width: auto">
|
|
Accept notices <code style="text-transform: none;">m.notice</code>
|
|
</label>
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptEmotes"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptEmotes" style="width: auto">
|
|
Accept emotes <code style="text-transform: none;">m.emote</code>
|
|
</label>
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptStickers"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptStickers" style="width: auto">
|
|
Accept stickers <code style="text-transform: none;">m.sticker</code>
|
|
</label>
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptReactions"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptReactions" style="width: auto">
|
|
Accept reactions <code style="text-transform: none;">m.reaction</code>
|
|
</label>
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptFiles"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptFiles" style="width: auto">
|
|
Accept files <code style="text-transform: none;">m.file</code>
|
|
</label>
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptAudio"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptAudio" style="width: auto">
|
|
Accept files <code style="text-transform: none;">m.audio</code>
|
|
</label>
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptImages"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptImages" style="width: auto">
|
|
Accept images <code style="text-transform: none;">m.image</code>
|
|
</label>
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptVideos"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptVideos" style="width: auto">
|
|
Accept videos <code style="text-transform: none;">m.video</code>
|
|
</label>
|
|
</div>
|
|
<div class="form-row" style="margin-bottom:0;">
|
|
<input
|
|
type="checkbox"
|
|
id="node-input-acceptLocations"
|
|
style="width: auto; margin-left: 125px; vertical-align: top"
|
|
/>
|
|
<label for="node-input-acceptLocations" style="width: auto">
|
|
Accept locations <code style="text-transform: none;">m.location</code>
|
|
</label>
|
|
</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-receive">
|
|
<p>Receive events from Matrix.</p>
|
|
|
|
<h3>Outputs</h3>
|
|
<ul class="node-ports">
|
|
<li>Always Returned
|
|
<dl class="message-properties">
|
|
<dt>msg.type <span class="property-type">string</span></dt>
|
|
<dd>
|
|
the message type. For example this will be either m.text, m.reaction, m.file, m.image, etc
|
|
</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.isDM <span class="property-type">bool</span></dt>
|
|
<dd> returns true if message is from a direct message room.</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.encrypted <span class="property-type">bool</span></dt>
|
|
<dd> returns true if message was encrypted (e2ee).</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.redacted <span class="property-type">bool</span></dt>
|
|
<dd> returns true if the message was redacted (such as deleted by the user).</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.payload <span class="property-type">string</span></dt>
|
|
<dd>the body from the message's content.</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.userId <span class="property-type">string</span></dt>
|
|
<dd>the User ID of the message sender. Example: @john:matrix.org</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.topic <span class="property-type">string</span></dt>
|
|
<dd>the ID of the room. Example: !OGEhHVWSdvArJzumhm:matrix.org</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.event <span class="property-type">object</span></dt>
|
|
<dd>the event object returned by the Matrix server</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.eventId <span class="property-type">object</span></dt>
|
|
<dd>The event ID, e.g. $143350589368169JsLZx:localhost</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.content <span class="property-type">object</span></dt>
|
|
<dd>the message's content object</dd>
|
|
</dl>
|
|
</li>
|
|
|
|
<li><code>msg.type</code> == '<strong>m.text</strong>'
|
|
<div class="form-tips" style="margin-bottom: 12px;">
|
|
Doesn't return anything extra
|
|
</div>
|
|
</li>
|
|
|
|
<li><code>msg.type</code> == '<strong>m.reaction</strong>'
|
|
<dl class="message-properties">
|
|
<dt>msg.referenceEventId <span class="property-type">string</span></dt>
|
|
<dd>the message that the reaction relates to</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.payload <span class="property-type">string</span></dt>
|
|
<dd>the key of the reaction's content</dd>
|
|
</dl>
|
|
</li>
|
|
|
|
<li><code>msg.type</code> == '<strong>m.emote</strong>'
|
|
<div class="form-tips" style="margin-bottom: 12px;">
|
|
Doesn't return anything extra
|
|
</div>
|
|
</li>
|
|
|
|
<li><code>msg.type</code> == '<strong>m.sticker</strong>'
|
|
<dl class="message-properties">
|
|
<dt>msg.url <span class="property-type">string</span></dt>
|
|
<dd>URL to the sticker image</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.mxc_url <span class="property-type">string</span></dt>
|
|
<dd>Matrix URL to the sticker image</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.thumbnail_url <span class="property-type">string</span></dt>
|
|
<dd>URL to the thumbnail of the sticker</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.thumbnail_mxc_url <span class="property-type">string</span></dt>
|
|
<dd>Matrix URL to the thumbnail of the sticker</dd>
|
|
</dl>
|
|
</li>
|
|
|
|
<li><code>msg.type</code> == '<strong>m.file</strong>'
|
|
<dl class="message-properties">
|
|
<dt>msg.filename <span class="property-type">string</span></dt>
|
|
<dd>the file's parsed filename</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.url <span class="property-type">string</span></dt>
|
|
<dd>the file's URL</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.mxc_url <span class="property-type">string</span></dt>
|
|
<dd>the file's Matrix URL</dd>
|
|
</dl>
|
|
</li>
|
|
|
|
<li><code>msg.type</code> == '<strong>m.audio</strong>'
|
|
<dl class="message-properties">
|
|
<dt>msg.filename <span class="property-type">string</span></dt>
|
|
<dd>the image's parsed filename</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.mimetype <span class="property-type">string</span></dt>
|
|
<dd>audio file mimetype (ex: audio/ogg)</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.url <span class="property-type">string</span></dt>
|
|
<dd>the file's URL</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.mxc_url <span class="property-type">string</span></dt>
|
|
<dd>the file's Matrix URL</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.duration <span class="property-type">integer</span></dt>
|
|
<dd>duration of audio file in milliseconds</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.waveform <span class="property-type">array[int]</span></dt>
|
|
<dd>waveform of the audio clip</dd>
|
|
</dl>
|
|
</li>
|
|
|
|
<li><code>msg.type</code> == '<strong>m.image</strong>'
|
|
<dl class="message-properties">
|
|
<dt>msg.filename <span class="property-type">string</span></dt>
|
|
<dd>the image's parsed filename</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.url <span class="property-type">string</span></dt>
|
|
<dd>the image's URL</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.mxc_url <span class="property-type">string</span></dt>
|
|
<dd>the image's Matrix URL</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.thumbnail_url <span class="property-type">string</span></dt>
|
|
<dd>the image's thumbnail URL</dd>
|
|
</dl>
|
|
|
|
<dl class="message-properties">
|
|
<dt>msg.thumbnail_mxc_url <span class="property-type">string</span></dt>
|
|
<dd>the image's thumbnail Matrix URL</dd>
|
|
</dl>
|
|
</li>
|
|
|
|
<li><code>msg.type</code> == '<strong>m.location</strong>'
|
|
<dl class="message-properties">
|
|
<dt>msg.geo_uri <span class="property-type">string</span></dt>
|
|
<dd>URI format of the geolocation</dd>
|
|
</dl>
|
|
</li>
|
|
</ul>
|
|
</script> |