2024-06-05 10:19:46 +00:00
|
|
|
---
|
|
|
|
|
sidebar_position: 5
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# Send document
|
|
|
|
|
Sends a document to a chat or channel
|
|
|
|
|
|
|
|
|
|
|
2024-07-10 11:59:55 +03:00
|
|
|
|
2024-07-30 22:48:29 +03:00
|
|
|
`Function SendDocument(Val Token, Val ChatID, Val Text, Val Document, Val Keyboard = "", Val Markup = "Markdown", Val FileName = "") Export`
|
2024-06-05 10:19:46 +00:00
|
|
|
|
2024-08-13 15:52:26 +03:00
|
|
|
| Parameter | CLI option | Type | Description |
|
|
|
|
|
|-|-|-|-|
|
|
|
|
|
| Token | --token | String | Bot token |
|
|
|
|
|
| ChatID | --chat | String, Number | Target chat ID or ChatID*TopicID |
|
|
|
|
|
| Text | --text | String | Message text |
|
2024-10-11 09:59:59 +03:00
|
|
|
| Document | --doc | BinaryData, String | Document file |
|
|
|
|
|
| Keyboard | --keyboard | String | Keyboard. See FormKeyboardFromButtonArray |
|
2024-08-13 15:52:26 +03:00
|
|
|
| Markup | --parsemode | String | Text processing type (HTML, Markdown, MarkdownV2) |
|
|
|
|
|
| FileName | --filename | String | Custom displayed file name with extension, if necessary |
|
|
|
|
|
|
|
|
|
|
|
2024-10-09 09:42:00 +03:00
|
|
|
Returns: Map Of KeyAndValue - serialized JSON response from Telegram
|
2024-06-05 10:19:46 +00:00
|
|
|
|
2024-07-10 14:05:58 +03:00
|
|
|
<br/>
|
2024-07-10 11:59:55 +03:00
|
|
|
|
2024-10-11 09:59:59 +03:00
|
|
|
:::tip
|
|
|
|
|
Method at API documentation: [sendDocument](https://core.telegram.org/bots/api#senddocument)
|
|
|
|
|
:::
|
|
|
|
|
<br/>
|
2024-07-10 13:58:29 +03:00
|
|
|
|
|
|
|
|
|
2024-06-05 10:19:46 +00:00
|
|
|
```bsl title="Code example"
|
2024-09-24 11:38:18 +03:00
|
|
|
Token = "6129457865:AAFyzNYOAFbu...";
|
|
|
|
|
ChatID = "461699897";
|
|
|
|
|
ChannelID = "@testsichee";
|
|
|
|
|
Text = "Строковое значение";
|
2024-10-15 10:07:27 +03:00
|
|
|
Document = "https://api.athenaeum.digital/test_data/document.docx";
|
2024-08-13 16:47:32 +03:00
|
|
|
|
|
|
|
|
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-06-05 10:19:46 +00:00
|
|
|
```
|
2024-10-15 09:53:37 +03:00
|
|
|
|
2024-08-13 15:52:26 +03:00
|
|
|
|
2024-07-10 11:59:55 +03:00
|
|
|
|
2024-06-05 10:19:46 +00:00
|
|
|
|
|
|
|
|
```json title="Result"
|
2024-08-14 09:06:31 +03:00
|
|
|
{
|
2024-10-06 16:55:08 +03:00
|
|
|
"ok": true,
|
|
|
|
|
"result": {
|
2024-10-09 09:42:00 +03:00
|
|
|
"message_id": 8307,
|
2024-08-13 15:52:26 +03:00
|
|
|
"from": {
|
2024-10-06 16:55:08 +03:00
|
|
|
"id": 6129457865,
|
|
|
|
|
"is_bot": true,
|
|
|
|
|
"first_name": "Бот Виталий",
|
|
|
|
|
"username": "sicheebot"
|
2024-08-13 15:52:26 +03:00
|
|
|
},
|
|
|
|
|
"chat": {
|
2024-10-06 16:55:08 +03:00
|
|
|
"id": 461699897,
|
|
|
|
|
"first_name": "Anton",
|
|
|
|
|
"last_name": "Titowets",
|
|
|
|
|
"username": "JKIee",
|
|
|
|
|
"type": "private"
|
2024-08-13 15:52:26 +03:00
|
|
|
},
|
2024-10-09 09:42:00 +03:00
|
|
|
"date": 1728453390,
|
2024-08-13 15:52:26 +03:00
|
|
|
"document": {
|
2024-10-06 16:55:08 +03:00
|
|
|
"file_name": "document.docx",
|
|
|
|
|
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
2024-10-09 09:42:00 +03:00
|
|
|
"file_id": "BQACAgIAAxkDAAIgc2cGGw4a6yPdiNLubNQsFLQQPLHoAAJPWgAC_cg4SJF9HYfiILIbNgQ",
|
|
|
|
|
"file_unique_id": "AgADT1oAAv3IOEg",
|
2024-10-06 16:55:08 +03:00
|
|
|
"file_size": 24069
|
2024-08-13 15:52:26 +03:00
|
|
|
},
|
2024-10-06 16:55:08 +03:00
|
|
|
"caption": "Строковое значение"
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-06-05 10:19:46 +00:00
|
|
|
```
|