Add documentation

This commit is contained in:
borovlioff 2024-12-31 19:05:12 +03:00
parent e771059809
commit b0d6c1382b
13 changed files with 681 additions and 16 deletions

View File

@ -14,6 +14,7 @@
"license": "MIT", "license": "MIT",
"node-red": { "node-red": {
"nodes": { "nodes": {
"telegram-account-auth": "sample/auth.js",
"telegram-account-config": "sample/config.js", "telegram-account-config": "sample/config.js",
"telegram-account-receiver": "sample/receiver.js", "telegram-account-receiver": "sample/receiver.js",
"telegram-account-command": "sample/command.js", "telegram-account-command": "sample/command.js",

View File

@ -58,3 +58,78 @@
</div> </div>
</script> </script>
<script type="text/html" data-help-name="command">
<p>The <b>command</b> node listens for specific commands or patterns in Telegram messages and triggers further processing when a match is found. It supports both exact matches and regex-based pattern matching.</p>
<h3>Inputs</h3>
<p>This node does not take any direct inputs. Instead, it listens for incoming messages from the Telegram bot or user.</p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload.update
<span class="property-type">object</span>
</dt>
<dd>The raw Telegram update object, containing the details of the matched message, including text, sender, chat ID, and other metadata.</dd>
</dl>
<h3>Configuration</h3>
<dl class="message-properties">
<dt>Command
<span class="property-type">string</span>
</dt>
<dd>The text or pattern to match against incoming messages. For example, <code>/start</code> or <code>/help</code>.</dd>
<dt>Regex
<span class="property-type">boolean</span>
</dt>
<dd>If checked, treats the <b>Command</b> field as a regular expression. This allows for advanced pattern matching (e.g., <code>^/command\\s*</code>).</dd>
<dt>Telegram Configuration
<span class="property-type">node</span>
</dt>
<dd>A configured Telegram client node to listen for messages. Ensure the client has the necessary permissions and is correctly authenticated.</dd>
</dl>
<h3>Details</h3>
<p>The <b>command</b> node integrates with the Telegram API to monitor incoming messages in real time. When a message matches the configured command or regex, the node outputs the Telegram update object for further processing. This is particularly useful for creating bots that respond to specific commands.</p>
<h3>Example</h3>
<pre>
{
"payload": {
"update": {
"message": {
"message": "/start",
"sender": {
"id": 123456789,
"username": "exampleuser"
},
"chat": {
"id": 987654321,
"type": "private"
}
}
}
}
}
</pre>
<p>This example output is triggered when the bot receives the <code>/start</code> command. The <code>update</code> object contains metadata about the message, sender, and chat.</p>
<h3>Error Handling</h3>
<p>If the Telegram client fails to authenticate or there is an error in the configuration, the node logs an error message and stops functioning.</p>
<h3>Advanced Usage</h3>
<p>By enabling the <b>Regex</b> option, you can create dynamic commands or match patterns such as:</p>
<ul>
<li><code>^/command\\s*</code>: Matches the command followed by optional whitespace.</li>
<li><code>^/start|/help$</code>: Matches either <code>/start</code> or <code>/help</code>.</li>
</ul>
<p>This makes the <b>command</b> node versatile for building complex Telegram bot functionality.</p>
<h3>Notes</h3>
<ul>
<li>Ensure the Telegram bot has sufficient permissions to receive messages in the configured chat or channel.</li>
<li>Regular expressions should be carefully tested to avoid unintended matches or errors.</li>
</ul>
</script>

View File

@ -1,6 +1,6 @@
const { NewMessage } = require("telegram/events"); const { NewMessage } = require("telegram/events");
// event.js
module.exports = function (RED) { module.exports = function (RED) {
function Command(config) { function Command(config) {
RED.nodes.createNode(this, config); RED.nodes.createNode(this, config);
@ -19,27 +19,25 @@ module.exports = function (RED) {
const regex = new RegExp(config.command); const regex = new RegExp(config.command);
if (regex.test(message)) { if (regex.test(message)) {
// Создаем объект сообщения для отправки в следующий узел
var msg = { var msg = {
payload: { payload: {
update update
// Другие поля сообщения, которые вы хотите передать
} }
}; };
// Отправляем объект сообщения в следующий узел
node.send(msg); node.send(msg);
} }
} else if (message === config.command) { } else if (message === config.command) {
// Создаем объект сообщения для отправки в следующий узел
var msg = { var msg = {
payload: { payload: {
update update
// Другие поля сообщения, которые вы хотите передать
} }
}; };
// Отправляем объект сообщения в следующий узел
node.send(msg); node.send(msg);
} }
} }

View File

@ -43,5 +43,54 @@
<script type="text/html" data-help-name="delete-message"> <script type="text/html" data-help-name="delete-message">
input config, chatId, messageIds <p>The <b>delete-message</b> node allows you to delete messages from a Telegram chat. It supports deleting multiple messages at once and provides an option to revoke messages for all chat participants.</p>
</script>
<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 from which the messages will be deleted. Use "me" for personal chats.</dd>
<dt>payload.messageIds
<span class="property-type">number | array</span>
</dt>
<dd>The ID or an array of IDs of the messages to be deleted.</dd>
<dt>payload.revoke
<span class="property-type">boolean</span>
</dt>
<dd>If true, the messages will be deleted for all participants in the chat (revoke). Defaults to true.</dd>
<dt>payload.client
<span class="property-type">object</span>
</dt>
<dd>An optional Telegram client instance if not configured globally.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">object</span>
</dt>
<dd>The response from the Telegram API, confirming the deletion.</dd>
</dl>
<h3>Details</h3>
<p>The <b>delete-message</b> node uses the Telegram API to delete messages from a specified chat. It can delete a single message or multiple messages at once. If the <code>revoke</code> parameter is set to true, the messages will be removed for all participants, not just the sender.</p>
<h3>Example</h3>
<pre>
{
"payload": {
"chatId": "@example_user",
"messageIds": [12345, 12346],
"revoke": true
}
}
</pre>
<p>This input deletes the messages with IDs 12345 and 12346 from the chat with the user <code>@example_user</code>, revoking them for all participants.</p>
<h3>Configuration</h3>
<p>The node can use a globally configured Telegram client or a client instance provided in the message payload. Ensure that the client has the necessary permissions to delete messages from the specified chat.</p>
</script>

View File

@ -40,3 +40,48 @@
/> />
</div> </div>
</script> </script>
<script type="text/html" data-help-name="get-entity">
<p>The <b>get-entity</b> node retrieves information about a Telegram entity (e.g., user, chat, or channel) using its identifier or URL.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload.input
<span class="property-type">string</span>
</dt>
<dd>The identifier (username, user ID, chat ID, or channel ID) or URL of the Telegram entity to retrieve. For example, "123456789", "@example_user", or "https://t.me/example_channel".</dd>
<dt>payload.client
<span class="property-type">object</span>
</dt>
<dd>An optional Telegram client instance if not configured globally.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload.input
<span class="property-type">object</span>
</dt>
<dd>The retrieved entity object containing details about the user, chat, or channel.</dd>
</dl>
<h3>Details</h3>
<p>The <b>get-entity</b> node uses the Telegram API to fetch details about a specified entity. If the input is a Telegram URL (e.g., "https://t.me/example_user"), the node extracts the username or channel name and fetches the corresponding entity. For non-URL inputs, it directly retrieves the entity using the provided identifier.</p>
<h3>Example</h3>
<pre>
{
"payload": {
"input": "https://t.me/example_user"
}
}
</pre>
<p>This input retrieves the entity information for the Telegram user <code>example_user</code>.</p>
<h3>Error Handling</h3>
<p>If an error occurs while retrieving the entity (e.g., the identifier is invalid or the entity does not exist), the node logs an error and sends a message with <code>payload.input</code> set to <code>null</code>.</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 the necessary permissions to access the requested entity.</p>
</script>

View File

@ -126,3 +126,87 @@
/> />
</div> </div>
</script> </script>
<script type="text/html" data-help-name="iter-dialogs">
<p>The <b>iter-dialogs</b> node retrieves a list of Telegram dialogs (chats, channels, or groups) by iterating through them using the Telegram API.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload.client
<span class="property-type">object</span>
</dt>
<dd>An optional Telegram client instance if not configured globally.</dd>
<dt>payload.limit
<span class="property-type">number</span>
</dt>
<dd>Limits the number of dialogs to retrieve. Default is no limit.</dd>
<dt>payload.offsetDate
<span class="property-type">string | number</span>
</dt>
<dd>Fetch dialogs starting from this date. Provide a UNIX timestamp or a date string.</dd>
<dt>payload.offsetId
<span class="property-type">number</span>
</dt>
<dd>Fetch dialogs starting from this message ID.</dd>
<dt>payload.offsetPeer
<span class="property-type">object</span>
</dt>
<dd>The peer object to start retrieving dialogs from.</dd>
<dt>payload.ignorePinned
<span class="property-type">boolean</span>
</dt>
<dd>Ignores pinned dialogs if set to <code>true</code>. Default is <code>false</code>.</dd>
<dt>payload.ignoreMigrated
<span class="property-type">boolean</span>
</dt>
<dd>Ignores migrated chats if set to <code>true</code>. Default is <code>false</code>.</dd>
<dt>payload.folder
<span class="property-type">number</span>
</dt>
<dd>Retrieves dialogs from a specific folder by folder ID.</dd>
<dt>payload.archived
<span class="property-type">boolean</span>
</dt>
<dd>Includes archived dialogs if set to <code>true</code>. Default is <code>false</code>.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload.dialogs
<span class="property-type">object</span>
</dt>
<dd>An object containing dialogs, where keys are dialog IDs and values are dialog details.</dd>
</dl>
<h3>Details</h3>
<p>The <b>iter-dialogs</b> node uses the Telegram API to iterate over all available dialogs. It allows filtering by various parameters, such as the number of dialogs to retrieve (<code>limit</code>), starting date or message (<code>offsetDate</code>, <code>offsetId</code>), and additional flags like <code>ignorePinned</code> or <code>archived</code>.</p>
<p>It supports advanced configurations such as folder-specific retrieval and skipping migrated chats, providing granular control over the dialogs to be processed.</p>
<h3>Example</h3>
<pre>
{
"payload": {
"limit": 10,
"offsetDate": "2023-12-01T00:00:00Z",
"archived": true
}
}
</pre>
<p>This input retrieves up to 10 archived dialogs starting from December 1, 2023.</p>
<h3>Error Handling</h3>
<p>If an error occurs during dialog retrieval (e.g., invalid parameters or API limitations), the node logs an error message and does not return a payload.</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 sufficient permissions to access the dialogs.</p>
</script>

View File

@ -254,3 +254,112 @@
/> />
</div> </div>
</script> </script>
<script type="text/html" data-help-name="iter-messages">
<p>The <b>iter-messages</b> node retrieves messages from a specified chat or user using the Telegram API. It supports a wide range of filtering and pagination options, allowing for efficient message iteration.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload.client
<span class="property-type">object</span>
</dt>
<dd>An optional Telegram client instance if not configured globally.</dd>
<dt>payload.chatId
<span class="property-type">string</span>
</dt>
<dd>The ID or username of the chat or user to retrieve messages from. Use "me" for personal messages.</dd>
<dt>payload.limit
<span class="property-type">number</span>
</dt>
<dd>Maximum number of messages to retrieve.</dd>
<dt>payload.offsetDate
<span class="property-type">string | number</span>
</dt>
<dd>Fetch messages starting from this date. Accepts a UNIX timestamp or a date string.</dd>
<dt>payload.offsetId
<span class="property-type">number</span>
</dt>
<dd>Fetch messages starting from this message ID.</dd>
<dt>payload.maxId
<span class="property-type">number</span>
</dt>
<dd>Fetch messages with IDs less than or equal to this value.</dd>
<dt>payload.minId
<span class="property-type">number</span>
</dt>
<dd>Fetch messages with IDs greater than or equal to this value.</dd>
<dt>payload.addOffset
<span class="property-type">number</span>
</dt>
<dd>An additional offset to apply when retrieving messages.</dd>
<dt>payload.search
<span class="property-type">string</span>
</dt>
<dd>Filters messages containing the specified search term.</dd>
<dt>payload.filter
<span class="property-type">object</span>
</dt>
<dd>Applies a specific message filter (e.g., photos, videos, documents).</dd>
<dt>payload.filters
<span class="property-type">array</span>
</dt>
<dd>Applies multiple message filters using Telegram API filter classes (e.g., <code>Api.InputMessagesFilterPhotos</code>).</dd>
<dt>payload.reverse
<span class="property-type">boolean</span>
</dt>
<dd>Retrieves messages in reverse order if set to <code>true</code>. Default is <code>false</code>.</dd>
<dt>payload.replyTo
<span class="property-type">number</span>
</dt>
<dd>Fetches messages replying to the specified message ID.</dd>
<dt>payload.scheduled
<span class="property-type">boolean</span>
</dt>
<dd>Includes scheduled messages if set to <code>true</code>.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload.messages
<span class="property-type">object</span>
</dt>
<dd>An object containing messages, where keys are message IDs and values are message details.</dd>
</dl>
<h3>Details</h3>
<p>The <b>iter-messages</b> node provides a flexible way to retrieve messages from a Telegram chat or user. It allows advanced configurations such as filtering messages by type, searching for specific terms, and paginating results using offsets and IDs.</p>
<p>The node also handles cases where a chat username needs to be resolved into an entity or peer ID. It supports using multiple filters in conjunction, enabling precise control over the messages to process.</p>
<h3>Example</h3>
<pre>
{
"payload": {
"chatId": "@examplechannel",
"limit": 50,
"search": "announcement",
"filters": ["InputMessagesFilterPhotos"]
}
}
</pre>
<p>This input retrieves up to 50 messages containing the term "announcement" and filters them to include only photos from the specified channel.</p>
<h3>Error Handling</h3>
<p>If an error occurs during message retrieval (e.g., invalid chat ID or API errors), the node logs an error message and does not return a payload.</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 access to the specified chat or user.</p>
</script>

View File

@ -51,8 +51,6 @@ module.exports = function (RED) {
if (offsetDate) { if (offsetDate) {
params.offsetDate = new Date(offsetDate).getTime() / 1000; params.offsetDate = new Date(offsetDate).getTime() / 1000;
} }
console.log("🚀 ~ file: iter-messages.js:58 ~ params:", params)
console.log(chatId)
if (chatId[0] === "@") { if (chatId[0] === "@") {
peerId = await client.getEntity(chatId); peerId = await client.getEntity(chatId);

View File

@ -54,3 +54,75 @@
</div> </div>
</script> </script>
<script type="text/html" data-help-name="receiver">
<p>The <b>receiver</b> node listens for incoming Telegram messages and forwards them as output messages in Node-RED. It supports filtering messages based on sender IDs to ignore specific users.</p>
<h3>Inputs</h3>
<p>This node does not take any direct inputs. It listens to all incoming messages from the configured Telegram client.</p>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload.update
<span class="property-type">object</span>
</dt>
<dd>The raw Telegram update object containing details about the incoming message, sender, chat, and metadata.</dd>
</dl>
<h3>Configuration</h3>
<dl class="message-properties">
<dt>Telegram Configuration
<span class="property-type">node</span>
</dt>
<dd>A configured Telegram client node to receive messages. Ensure the client is authenticated and has necessary permissions.</dd>
<dt>Ignore List
<span class="property-type">string</span>
</dt>
<dd>A newline-separated list of user IDs to ignore. Messages from these users will not trigger the output.</dd>
</dl>
<h3>Details</h3>
<p>The <b>receiver</b> node uses the Telegram client to listen for all new messages in real-time. It emits a message to the next connected Node-RED node whenever a new Telegram message is received, provided the sender's user ID is not in the ignore list.</p>
<h3>Example</h3>
<pre>
{
"payload": {
"update": {
"message": {
"message": "Hello, bot!",
"sender": {
"id": 123456789,
"username": "exampleuser"
},
"chat": {
"id": 987654321,
"type": "private"
}
}
}
}
}
</pre>
<p>In this example, the node outputs the raw Telegram update object when a user sends the message "Hello, bot!" to the Telegram bot.</p>
<h3>Error Handling</h3>
<p>If the Telegram client encounters an authentication issue or configuration error, the node logs an error message and stops listening for messages.</p>
<h3>Advanced Usage</h3>
<p>By configuring the <b>Ignore List</b>, you can filter out messages from specific users. For example:</p>
<pre>
123456789
987654321
</pre>
<p>In this case, messages from user IDs <code>123456789</code> and <code>987654321</code> will be ignored.</p>
<h3>Notes</h3>
<ul>
<li>Ensure the Telegram bot has sufficient permissions to receive messages in the configured chat or channel.</li>
<li>The <b>Ignore List</b> only filters messages based on the sender's user ID.</li>
<li>For advanced filtering based on message content, consider chaining this node with additional processing nodes in Node-RED.</li>
</ul>
</script>

View File

@ -1,6 +1,5 @@
const { NewMessage } = require("telegram/events"); const { NewMessage } = require("telegram/events");
// event.js
module.exports = function (RED) { module.exports = function (RED) {
function Receiver(config) { function Receiver(config) {
RED.nodes.createNode(this, config); RED.nodes.createNode(this, config);

View File

@ -314,3 +314,150 @@
/> />
</div> </div>
</script> </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>

View File

@ -210,3 +210,91 @@
<input type="text" id="node-input-topMsgId" placeholder="Top Msg ID"> <input type="text" id="node-input-topMsgId" placeholder="Top Msg ID">
</div> </div>
</script> </script>
<script type="text/html" data-help-name="send-message">
<p>The <b>send-message</b> node allows sending messages via Telegram using the <code>telegram</code> library. It supports various message types, formatting options, and additional features like scheduling and silent messages.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload.chatId
<span class="property-type">string</span>
</dt>
<dd>The recipient's chat ID, username (prefixed with <code>@</code>), or "me" for personal chats.</dd>
<dt>payload.message
<span class="property-type">string</span>
</dt>
<dd>The message text to send.</dd>
<dt>payload.parseMode
<span class="property-type">string</span>
</dt>
<dd>Specifies the formatting mode, such as <code>markdown</code> or <code>html</code>.</dd>
<dt>payload.schedule
<span class="property-type">string</span>
</dt>
<dd>The timestamp (or ISO date string) to schedule the message for later sending.</dd>
<dt>payload.replyTo
<span class="property-type">number</span>
</dt>
<dd>The ID of the message to reply to, if applicable.</dd>
<dt>payload.attributes
<span class="property-type">object</span>
</dt>
<dd>Additional attributes for the message.</dd>
<dt>payload.linkPreview
<span class="property-type">boolean</span>
</dt>
<dd>Determines whether to show link previews in the message.</dd>
<dt>payload.file
<span class="property-type">string</span>
</dt>
<dd>The path to a file to send (e.g., images, videos, documents).</dd>
<dt>payload.thumb
<span class="property-type">string</span>
</dt>
<dd>The path to a thumbnail for the file, if applicable.</dd>
<dt>payload.buttons
<span class="property-type">array</span>
</dt>
<dd>An array of button configurations for inline or reply keyboards.</dd>
<dt>payload.silent
<span class="property-type">boolean</span>
</dt>
<dd>If true, sends the message silently (no notification sound).</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload.response
<span class="property-type">object</span>
</dt>
<dd>The response from the Telegram API, containing details of the sent message.</dd>
</dl>
<h3>Details</h3>
<p>To use the <b>send-message</b> node, you must provide the recipient's chat ID and the message content. Additional parameters like <code>file</code>, <code>thumb</code>, and <code>buttons</code> enable sending multimedia messages or interactive content. The node automatically resolves usernames prefixed with <code>@</code> to their corresponding chat entities.</p>
<p>If scheduling is enabled, the <code>schedule</code> parameter should contain a valid timestamp or ISO date string. When sending files, ensure the <code>file</code> parameter specifies the correct path or URL.</p>
<h3>Example</h3>
<pre>
{
"payload": {
"chatId": "@example_user",
"message": "Hello, World!",
"parseMode": "markdown",
"silent": true
}
}
</pre>
<p>This input sends a silent message in Markdown format to the user <code>@example_user</code>.</p>
</script>

View File

@ -50,7 +50,6 @@ module.exports = function (RED) {
commentTo: commentTo !== "" ? commentTo : undefined, commentTo: commentTo !== "" ? commentTo : undefined,
topMsgId: topMsgId !== topMsgId ? commentTo : undefined, topMsgId: topMsgId !== topMsgId ? commentTo : undefined,
}; };
console.log("🚀 ~ file: send-message.js:60 ~ params:", params)
if (schedule) { if (schedule) {
params.schedule = new Date(schedule).getTime() / 1000; params.schedule = new Date(schedule).getTime() / 1000;
@ -77,6 +76,7 @@ module.exports = function (RED) {
} }
}); });
} }
RED.nodes.registerType('send-message', SendMessage); RED.nodes.registerType('send-message', SendMessage);