You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-11-29 22:27:42 +02:00
122 lines
3.8 KiB
Plaintext
Vendored
122 lines
3.8 KiB
Plaintext
Vendored
---
|
|
sidebar_position: 5
|
|
description: Send document 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 document
|
|
Sends a document to a chat or channel
|
|
|
|
|
|
|
|
`Function SendDocument(Val Token, Val ChatID, Val Text, Val Document, Val Keyboard = "", Val Markup = "Markdown", Val FileName = "") 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 |
|
|
| Document | --doc | BinaryData, String | ✔ | Document file |
|
|
| Keyboard | --keyboard | String, Structure Of KeyAndValue | ✖ | Keyboard. See FormKeyboardFromButtonArray |
|
|
| Markup | --parsemode | String | ✖ | Text processing type (HTML, Markdown, MarkdownV2) |
|
|
| FileName | --filename | String | ✖ | Custom displayed file name with extension, if necessary |
|
|
|
|
|
|
Returns: Map Of KeyAndValue - serialized JSON response from Telegram
|
|
|
|
<br/>
|
|
|
|
:::tip
|
|
Method at API documentation: [sendDocument](https://core.telegram.org/bots/api#senddocument)
|
|
|
|
Parameters with Binary data type can also accept file paths on disk and URLs
|
|
:::
|
|
<br/>
|
|
|
|
|
|
```bsl title="1C:Enterprise/OneScript code example"
|
|
Token = "6129457865:AAFyzNYOAFbu...";
|
|
ChatID = "461699897";
|
|
ChannelID = "@testsichee";
|
|
Text = "Строковое значение";
|
|
Document = "https://hut.openintegrations.dev/test_data/document.docx";
|
|
|
|
DocumentPath = GetTempFileName("docx");
|
|
CopyFile(Document, DocumentPath);
|
|
|
|
DocumentDD = New BinaryData(DocumentPath);
|
|
|
|
// In chat, by URL
|
|
Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document);
|
|
|
|
// In chat, by URL, with file name
|
|
Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document, , , "customname.docx");
|
|
|
|
// To channel, on disk
|
|
Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentPath);
|
|
|
|
// To channel, from binary data, with file name
|
|
Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentDD, , , "customname.docx");
|
|
```
|
|
|
|
|
|
<Tabs>
|
|
|
|
<TabItem value="bash" label="Bash" default>
|
|
```bash
|
|
oint telegram SendDocument \
|
|
--token "***" \
|
|
--chat "@testsichee" \
|
|
--text "Строковое значение" \
|
|
--doc "C:\Users\bayse\AppData\Local\Temp\av1ot2g2.lsn" \
|
|
--filename "customname.docx"
|
|
```
|
|
</TabItem>
|
|
|
|
<TabItem value="bat" label="CMD/Bat" default>
|
|
```batch
|
|
oint telegram SendDocument ^
|
|
--token "***" ^
|
|
--chat "@testsichee" ^
|
|
--text "Строковое значение" ^
|
|
--doc "C:\Users\bayse\AppData\Local\Temp\av1ot2g2.lsn" ^
|
|
--filename "customname.docx"
|
|
```
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
|
|
```json title="Result"
|
|
{
|
|
"ok": true,
|
|
"result": {
|
|
"message_id": 17748,
|
|
"from": {
|
|
"id": 6129457865,
|
|
"is_bot": true,
|
|
"first_name": "Бот Виталий",
|
|
"username": "sicheebot"
|
|
},
|
|
"chat": {
|
|
"id": 461699897,
|
|
"first_name": "Anton",
|
|
"last_name": "Titovets",
|
|
"username": "bayselonarrend",
|
|
"type": "private"
|
|
},
|
|
"date": 1761909126,
|
|
"document": {
|
|
"file_name": "document.docx",
|
|
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
"file_id": "BQACAgIAAxkDAAJFVGkEmYbnCvWpC2KZUhmmK2i0lV11AAK4fwACy8ooSMffuJJeW4RmNgQ",
|
|
"file_unique_id": "AgADuH8AAsvKKEg",
|
|
"file_size": 24069
|
|
},
|
|
"caption": "Строковое значение"
|
|
}
|
|
}
|
|
```
|