1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-04-27 12:32:33 +02:00

115 lines
3.4 KiB
Plaintext
Raw Normal View History

2024-10-15 10:50:56 +03:00
---
2024-10-15 10:16:04 +03:00
sidebar_position: 5
---
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 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`
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 |
| Document | --doc | BinaryData, String | ✔ | Document file |
| Keyboard | --keyboard | String | ✖ | Keyboard. See FormKeyboardFromButtonArray |
| Markup | --parsemode | String | ✖ | Text processing type (HTML, Markdown, MarkdownV2) |
| FileName | --filename | String | ✖ | Custom displayed file name with extension, if necessary |
2024-10-15 10:16:04 +03:00
Returns: Map Of KeyAndValue - serialized JSON response from Telegram
<br/>
:::tip
2024-10-29 17:14:45 +03:00
Method at API documentation: [sendDocument](https://core.telegram.org/bots/api#senddocument)<br/>
2024-10-15 13:51:58 +03:00
Parameters with Binary data type can also accept file paths on disk and URLs
2024-10-15 10:16:04 +03:00
:::
<br/>
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 = "Строковое значение";
Document = "https://api.athenaeum.digital/test_data/document.docx";
DocumentPath = GetTempFileName("docx");
CopyFile(Document, DocumentPath);
DocumentDD = New BinaryData(DocumentPath);
Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document);
Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document, , , "customname.docx");
Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentPath);
Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentDD, , , "customname.docx");
```
2024-10-20 22:36:03 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
oint telegram SendDocument \
2024-10-22 08:59:24 +03:00
--token "***" \
--chat "@testsichee" \
--text "Строковое значение" \
2024-11-17 16:09:58 +03:00
--doc "C:\Users\Administrator\AppData\Local\Temp\noku1z2d43c.docx" \
2024-10-22 08:59:24 +03:00
--filename "custom.docx"
2024-10-20 22:36:03 +03:00
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
oint telegram SendDocument ^
2024-10-22 08:59:24 +03:00
--token "***" ^
--chat "@testsichee" ^
--text "Строковое значение" ^
2024-11-17 16:09:58 +03:00
--doc "C:\Users\Administrator\AppData\Local\Temp\noku1z2d43c.docx" ^
2024-10-22 08:59:24 +03:00
--filename "custom.docx"
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": 8307,
"from": {
"id": 6129457865,
"is_bot": true,
"first_name": "Бот Виталий",
"username": "sicheebot"
},
"chat": {
"id": 461699897,
"first_name": "Anton",
"last_name": "Titowets",
"username": "JKIee",
"type": "private"
},
"date": 1728453390,
"document": {
"file_name": "document.docx",
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"file_id": "BQACAgIAAxkDAAIgc2cGGw4a6yPdiNLubNQsFLQQPLHoAAJPWgAC_cg4SJF9HYfiILIbNgQ",
"file_unique_id": "AgADT1oAAv3IOEg",
"file_size": 24069
},
"caption": "Строковое значение"
}
}
```