2025-01-19 22:03:57 +02:00

489 lines
13 KiB
HTML

<script type="text/javascript">
RED.nodes.registerType("send-files", {
category: "telegram",
color: "#32a3e0",
defaults: {
name: { value: "" },
config: { type: "config", required: true },
chatId: { value: "", required: true },
files: { value: "", required: true },
caption: { value: "" },
forceDocument: { value: false },
fileSize: { value: 0 },
clearDraft: { value: false },
progressCallback: { value: "" },
replyTo: { value: "" },
attributes: { value: "" },
thumb: { value: "" },
voiceNote: { value: false },
videoNote: { value: false },
supportsStreaming: { value: false },
parseMode: { value: "" },
formattingEntities: { value: "" },
silent: { value: false },
scheduleDate: { value: 0 },
buttons: { value: "" },
workers: { value: 0 },
noforwards: { value: false },
commentTo: { value: "" },
topMsgId: { value: "" },
},
inputs: 1,
outputs: 1,
icon: "file.png",
paletteLabel: "Send Files",
label: function () {
return this.name || "Send Files";
},
});
</script>
<script type="text/html" data-template-name="send-files">
<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"
style="width: 60%"
ng-model="name"
/>
</div>
<div class="form-row">
<label for="node-input-config"> <i class="fa fa-tag"></i> Config </label>
<input
type="text"
id="node-input-config"
placeholder="Config"
style="width: 60%"
ng-model="config"
/>
</div>
<div class="form-row">
<label for="node-input-chatId"> <i class="fa fa-tag"></i> Chat ID </label>
<input
type="text"
id="node-input-chatId"
placeholder="Chat ID"
style="width: 60%"
ng-model="chatId"
/>
</div>
<div class="form-row">
<label for="node-input-files">
<i class="fa fa-tag"></i> Files (comma-separated)
</label>
<input
type="text"
id="node-input-files"
placeholder="url"
style="width: 60%"
ng-model="files"
/>
</div>
<div class="form-row">
<label for="node-input-caption"> <i class="fa fa-tag"></i> Caption </label>
<input
type="text"
id="node-input-caption"
placeholder="Caption"
style="width: 60%"
ng-model="caption"
/>
</div>
<div class="form-row">
<label for="node-input-forceDocument">
<i class="fa fa-tag"></i> Force Document
</label>
<input
type="checkbox"
id="node-input-forceDocument"
ng-model="forceDocument"
/>
</div>
<div class="form-row">
<label for="node-input-fileSize">
<i class="fa fa-tag"></i> File Size
</label>
<input
type="number"
id="node-input-fileSize"
placeholder="File Size"
style="width: 60%"
ng-model="fileSize"
/>
</div>
<div class="form-row">
<label for="node-input-clearDraft">
<i class="fa fa-tag"></i> Clear Draft
</label>
<input type="checkbox" id="node-input-clearDraft" ng-model="clearDraft" />
</div>
<div class="form-row">
<label for="node-input-progressCallback">
<i class="fa fa-tag"></i> Progress Callback
</label>
<input
type="text"
id="node-input-progressCallback"
placeholder="Progress Callback"
style="width: 60%"
ng-model="progressCallback"
/>
</div>
<div class="form-row">
<label for="node-input-replyTo"> <i class="fa fa-tag"></i> Reply To </label>
<input
type="text"
id="node-input-replyTo"
placeholder="Reply To"
style="width: 60%"
ng-model="replyTo"
/>
</div>
<div class="form-row">
<label for="node-input-attributes">
<i class="fa fa-tag"></i> Attributes
</label>
<input
type="text"
id="node-input-attributes"
placeholder="Attributes"
style="width: 60%"
ng-model="attributes"
/>
</div>
<div class="form-row">
<label for="node-input-thumb"> <i class="fa fa-tag"></i> Thumbnail </label>
<input
type="text"
id="node-input-thumb"
placeholder="Thumbnail"
style="width: 60%"
ng-model="thumb"
/>
</div>
<div class="form-row">
<label for="node-input-voiceNote">
<i class="fa fa-tag"></i> Voice Note
</label>
<input type="checkbox" id="node-input-voiceNote" ng-model="voiceNote" />
</div>
<div class="form-row">
<label for="node-input-videoNote">
<i class="fa fa-tag"></i> Video Note
</label>
<input type="checkbox" id="node-input-videoNote" ng-model="videoNote" />
</div>
<div class="form-row">
<label for="node-input-supportsStreaming">
<i class="fa fa-tag"></i> Supports Streaming
</label>
<input
type="checkbox"
id="node-input-supportsStreaming"
ng-model="supportsStreaming"
/>
</div>
<div class="form-row">
<label for="node-input-parseMode">
<i class="fa fa-tag"></i> Parse Mode
</label>
<input
type="text"
id="node-input-parseMode"
placeholder="Parse Mode"
style="width: 60%"
ng-model="parseMode"
/>
</div>
<div class="form-row">
<label for="node-input-formattingEntities">
<i class="fa fa-tag"></i> Formatting Entities
</label>
<input
type="text"
id="node-input-formattingEntities"
placeholder="Formatting Entities"
style="width: 60%"
ng-model="formattingEntities"
/>
</div>
<div class="form-row">
<label for="node-input-silent"> <i class="fa fa-tag"></i> Silent </label>
<input type="checkbox" id="node-input-silent" ng-model="silent" />
</div>
<div class="form-row">
<label for="node-input-scheduleDate">
<i class="fa fa-tag"></i> Schedule Date
</label>
<input
type="number"
id="node-input-scheduleDate"
placeholder="Schedule Date"
style="width: 60%"
ng-model="scheduleDate"
/>
</div>
<div class="form-row">
<label for="node-input-buttons"> <i class="fa fa-tag"></i> Buttons </label>
<input
type="text"
id="node-input-buttons"
placeholder="Buttons"
style="width: 60%"
ng-model="buttons"
/>
</div>
<div class="form-row">
<label for="node-input-workers"> <i class="fa fa-tag"></i> Workers </label>
<input
type="number"
id="node-input-workers"
placeholder="Workers"
style="width: 60%"
ng-model="workers"
/>
</div>
<div class="form-row">
<label for="node-input-noforwards">
<i class="fa fa-tag"></i> No Forwards
</label>
<input type="checkbox" id="node-input-noforwards" ng-model="noforwards" />
</div>
<div class="form-row">
<label for="node-input-commentTo">
<i class="fa fa-tag"></i> Comment To
</label>
<input
type="text"
id="node-input-commentTo"
placeholder="Comment To"
style="width: 60%"
ng-model="commentTo"
/>
</div>
<div class="form-row">
<label for="node-input-topMsgId">
<i class="fa fa-tag"></i> Top Message ID
</label>
<input
type="text"
id="node-input-topMsgId"
placeholder="Top Message ID"
style="width: 60%"
ng-model="topMsgId"
/>
</div>
</script>
<script type="text/html" data-help-name="send-files">
<p>
The <b>send-files</b> node allows you to send files to a Telegram chat or
user using the Telegram API. It supports a wide range of parameters,
including file attributes, captions, buttons, and scheduling options.
</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>
payload.chatId
<span class="property-type">string</span>
</dt>
<dd>The ID or username of the chat or user to send files to.</dd>
<dt>
payload.files
<span class="property-type">array</span>
</dt>
<dd>
A list of file paths or URLs to be sent. Multiple files can be specified.
</dd>
<dt>
payload.caption
<span class="property-type">string</span>
</dt>
<dd>
The caption text to include with the file. Supports Markdown or HTML
formatting.
</dd>
<dt>
payload.forceDocument
<span class="property-type">boolean</span>
</dt>
<dd>
If <code>true</code>, forces the file to be sent as a document instead of
its native media type.
</dd>
<dt>
payload.fileSize
<span class="property-type">number</span>
</dt>
<dd>Specifies the file size, if known. Useful for optimization.</dd>
<dt>
payload.clearDraft
<span class="property-type">boolean</span>
</dt>
<dd>
If <code>true</code>, clears the draft in the chat before sending the
file.
</dd>
<dt>
payload.progressCallback
<span class="property-type">function</span>
</dt>
<dd>A function to monitor the progress of file uploads.</dd>
<dt>
payload.replyTo
<span class="property-type">number</span>
</dt>
<dd>The ID of the message to reply to with the file.</dd>
<dt>
payload.attributes
<span class="property-type">object</span>
</dt>
<dd>Additional attributes for the file, such as file type or metadata.</dd>
<dt>
payload.thumb
<span class="property-type">string</span>
</dt>
<dd>A path or URL to a thumbnail image for the file.</dd>
<dt>
payload.voiceNote
<span class="property-type">boolean</span>
</dt>
<dd>If <code>true</code>, marks the file as a voice note.</dd>
<dt>
payload.videoNote
<span class="property-type">boolean</span>
</dt>
<dd>If <code>true</code>, marks the file as a video note.</dd>
<dt>
payload.supportsStreaming
<span class="property-type">boolean</span>
</dt>
<dd>If <code>true</code>, enables streaming support for video files.</dd>
<dt>
payload.parseMode
<span class="property-type">string</span>
</dt>
<dd>
Specifies the parse mode for captions (<code>Markdown</code> or
<code>HTML</code>).
</dd>
<dt>
payload.silent
<span class="property-type">boolean</span>
</dt>
<dd>
If <code>true</code>, sends the message silently without a notification.
</dd>
<dt>
payload.scheduleDate
<span class="property-type">string | number</span>
</dt>
<dd>
Schedules the message to be sent at a specific time. Accepts a UNIX
timestamp or date string.
</dd>
<dt>
payload.buttons
<span class="property-type">array</span>
</dt>
<dd>An array of buttons to include with the file message.</dd>
<dt>
payload.workers
<span class="property-type">number</span>
</dt>
<dd>The number of workers for parallel uploads.</dd>
<dt>
payload.noforwards
<span class="property-type">boolean</span>
</dt>
<dd>If <code>true</code>, prevents the message from being forwarded.</dd>
<dt>
payload.commentTo
<span class="property-type">number</span>
</dt>
<dd>The ID of the message to comment on in a channel.</dd>
<dt>
payload.topMsgId
<span class="property-type">number</span>
</dt>
<dd>The ID of the pinned message to associate with the file.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>
payload
<span class="property-type">object</span>
</dt>
<dd>
Contains the response from the Telegram API, including details of the sent
message or file.
</dd>
</dl>
<h3>Details</h3>
<p>
The <b>send-files</b> node allows advanced file-sending capabilities with
full customization. It supports various Telegram features such as captions
with rich text formatting, scheduled messages, silent delivery, and progress
tracking.
</p>
<h3>Example</h3>
<pre>
{
"payload": {
"chatId": "@examplechannel",
"files": ["path/to/file1.jpg", "path/to/file2.mp4"],
"caption": "Check out these files!",
"silent": true,
"parseMode": "Markdown",
"buttons": [
{ "text": "Visit Website", "url": "https://example.com" }
]
}
}
</pre
>
<p>
This example sends two files with a caption, using Markdown for formatting,
and includes a button linking to a website. The message is sent silently.
</p>
<h3>Error Handling</h3>
<p>
If an error occurs (e.g., invalid file path or chat ID), the node logs an
error message and does not send the file.
</p>
<h3>Configuration</h3>
<p>
The node can use a globally configured Telegram client or a client instance
provided in the message payload. Ensure the client has permissions to send
messages in the specified chat.
</p>
</script>