1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-29 22:27:42 +02:00
Files
OpenIntegrations/docs/en/md/Telegram/Data-sending/Send-text-message.mdx

102 lines
2.9 KiB
Plaintext
Raw Normal View History

2024-10-15 10:50:56 +03:00
---
2024-10-15 10:16:04 +03:00
sidebar_position: 1
2025-05-05 10:07:34 +03:00
description: "Send text message" and other functions to work with Telegram in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
2025-05-05 09:49:19 +03:00
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, Telegram]
2024-10-15 10:16:04 +03:00
---
2024-10-15 10:50:56 +03:00
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
2024-10-15 10:16:04 +03:00
# Send text message
Sends a text message to a chat or channel
`Function SendTextMessage(Val Token, Val ChatID, Val Text, Val Keyboard = "", Val Markup = "Markdown", Val RepliedID = 0) Export`
2024-10-15 15:15:47 +03:00
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Token | --token | String | ✔ | Bot token |
| ChatID | --chat | String, Number | ✔ | Target chat ID or ChatID*TopicID |
| Text | --text | String | ✔ | Message text |
2025-01-16 21:22:31 +03:00
| Keyboard | --keyboard | String, Structure Of KeyAndValue | ✖ | Keyboard. See FormKeyboardFromButtonArray |
2024-10-15 15:15:47 +03:00
| Markup | --parsemode | String | ✖ | Text processing type (HTML, Markdown, MarkdownV2) |
| RepliedID | --reply | String, Number | ✖ | Reply to message ID |
2024-10-15 10:16:04 +03:00
Returns: Map Of KeyAndValue - serialized JSON response from Telegram
<br/>
:::tip
2024-11-21 13:27:18 +03:00
Method at API documentation: [sendMessage](https://core.telegram.org/bots/api#sendmessage)
2024-10-15 10:16:04 +03:00
:::
<br/>
2024-12-16 19:38:57 +03:00
2024-10-15 21:15:56 +03:00
```bsl title="1C:Enterprise/OneScript code example"
2024-10-15 10:16:04 +03:00
Token = "6129457865:AAFyzNYOAFbu...";
ChatID = "461699897";
ChannelID = "@testsichee";
Text = "Строковое значение";
2025-01-16 21:22:31 +03:00
KeyboardButtonsArray = New Array;
KeyboardButtonsArray.Add("Button1");
KeyboardButtonsArray.Add("Button2");
Keyboard = OPI_Telegram.FormKeyboardFromButtonArray(KeyboardButtonsArray, True);
Result = OPI_Telegram.SendTextMessage(Token, ChatID, Text, Keyboard);
2024-10-15 10:16:04 +03:00
Result = OPI_Telegram.SendTextMessage(Token, ChannelID, Text);
```
2024-10-20 22:36:03 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
oint telegram SendTextMessage \
2024-10-22 08:59:24 +03:00
--token "***" \
--chat "@testsichee" \
--text "Text %%F0%%9F%%A5%%9D and emoji \(10%%\)" \
--parsemode "MarkdownV2"
2024-10-20 22:36:03 +03:00
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
oint telegram SendTextMessage ^
2024-10-22 08:59:24 +03:00
--token "***" ^
--chat "@testsichee" ^
--text "Text %%F0%%9F%%A5%%9D and emoji \(10%%\)" ^
--parsemode "MarkdownV2"
2024-10-20 22:36:03 +03:00
```
</TabItem>
</Tabs>
2024-10-15 10:16:04 +03:00
```json title="Result"
{
"ok": true,
"result": {
"message_id": 8302,
"from": {
"id": 6129457865,
"is_bot": true,
"first_name": "Бот Виталий",
"username": "sicheebot"
},
"chat": {
"id": 461699897,
"first_name": "Anton",
"last_name": "Titowets",
"username": "JKIee",
"type": "private"
},
"date": 1728453289,
"text": "Строковое значение"
}
}
```