1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-27 22:18:36 +02:00
Files
OpenIntegrations/docs/en/md/Telegram/Data-sending/Send-text-message.mdx
Vitaly the Alpaca (bot) aa10e4c564 Main build (Jenkins)
2025-10-21 11:36:43 +03:00

117 lines
3.1 KiB
Plaintext
Vendored

---
sidebar_position: 1
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
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, Telegram]
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# 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`
| 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 |
| Keyboard | --keyboard | String, Structure Of KeyAndValue | ✖ | Keyboard. See FormKeyboardFromButtonArray |
| Markup | --parsemode | String | ✖ | Text processing type (HTML, Markdown, MarkdownV2) |
| RepliedID | --reply | String, Number | ✖ | Reply to message ID |
Returns: Map Of KeyAndValue - serialized JSON response from Telegram
<br/>
:::tip
Method at API documentation: [sendMessage](https://core.telegram.org/bots/api#sendmessage)
:::
<br/>
```bsl title="1C:Enterprise/OneScript code example"
Token = "6129457865:AAFyzNYOAFbu...";
ChatID = "461699897";
ChannelID = "@testsichee";
Text = "Строковое значение";
KeyboardButtonsArray = New Array;
KeyboardButtonsArray.Add("Button1");
KeyboardButtonsArray.Add("Button2");
// With keyboard, in chat
Keyboard = OPI_Telegram.FormKeyboardFromButtonArray(KeyboardButtonsArray, True);
Result = OPI_Telegram.SendTextMessage(Token, ChatID, Text, Keyboard);
// Simple, to channel
Result = OPI_Telegram.SendTextMessage(Token, ChannelID, Text);
```
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
oint telegram SendTextMessage \
--token "***" \
--chat "-1001971186208*12117" \
--text "Строковое значение"
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
oint telegram SendTextMessage ^
--token "***" ^
--chat "-1001971186208*12117" ^
--text "Строковое значение"
```
</TabItem>
</Tabs>
```json title="Result"
{
"ok": true,
"result": {
"message_id": 17185,
"from": {
"id": 6129457865,
"is_bot": true,
"first_name": "Бот Виталий",
"username": "sicheebot"
},
"chat": {
"id": 461699897,
"first_name": "Anton",
"last_name": "Titovets",
"username": "bayselonarrend",
"type": "private"
},
"date": 1760516108,
"text": "Строковое значение",
"reply_markup": {
"inline_keyboard": [
[
{
"text": "Button1",
"callback_data": "Button1"
}
],
[
{
"text": "Button2",
"callback_data": "Button2"
}
]
]
}
}
}
```