2024-06-05 12:19:46 +02:00
|
|
|
---
|
|
|
|
sidebar_position: 4
|
|
|
|
---
|
|
|
|
|
|
|
|
# Send audio
|
|
|
|
Sends an audio file to a chat or channel
|
|
|
|
|
|
|
|
|
2024-07-10 10:59:55 +02:00
|
|
|
|
2024-07-10 12:58:29 +02:00
|
|
|
`Function SendAudio(Val Token, Val ChatID, Val Text, Val Audio, Val Keyboard = "", Val Markup = "Markdown") Export`
|
2024-06-05 12:19:46 +02:00
|
|
|
|
2024-08-13 14:52:26 +02: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 |
|
|
|
|
| Audio | --audio | BinaryData,String | Audio file |
|
|
|
|
| Keyboard | --keyboard | String | Keyboard JSON or path to .json |
|
|
|
|
| Markup | --parsemode | String | Text processing type (HTML, Markdown, MarkdownV2) |
|
|
|
|
|
|
|
|
|
|
|
|
Returns: Map Of KeyAndValue - Serialized JSON response from Telegram
|
2024-06-05 12:19:46 +02:00
|
|
|
|
2024-07-10 13:05:58 +02:00
|
|
|
<br/>
|
2024-07-10 10:59:55 +02:00
|
|
|
|
2024-07-10 12:58:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2024-06-05 12:19:46 +02:00
|
|
|
```bsl title="Code example"
|
2024-08-13 14:52:26 +02:00
|
|
|
Token = FunctionParameters["Telegram_Token"];
|
|
|
|
ChatID = FunctionParameters["Telegram_ChatID"];
|
|
|
|
ChannelID = FunctionParameters["Telegram_ChannelID"];
|
|
|
|
Text = FunctionParameters["String"];
|
|
|
|
Audio = FunctionParameters["Audio"];
|
|
|
|
|
|
|
|
AudioPath = GetTempFileName("mp3");
|
|
|
|
CopyFile(Audio, AudioPath);
|
|
|
|
|
|
|
|
AudioDD = New BinaryData(AudioPath);
|
|
|
|
|
|
|
|
Result = OPI_Telegram.SendAudio(Token, ChatID, Text, Audio);
|
|
|
|
|
|
|
|
OPI_TestDataRetrieval.WriteLog(Result, "SendAudio", "Telegram");
|
|
|
|
|
|
|
|
Result = OPI_Telegram.SendAudio(Token, ChannelID, Text, AudioPath);
|
|
|
|
|
|
|
|
OPI_TestDataRetrieval.WriteLog(Result, "SendAudio (Path)");
|
|
|
|
|
|
|
|
Result = OPI_Telegram.SendAudio(Token, ChannelID, Text, AudioDD);
|
2024-06-05 12:19:46 +02:00
|
|
|
```
|
2024-08-13 14:52:26 +02:00
|
|
|
|
2024-07-10 10:59:55 +02:00
|
|
|
|
2024-06-05 12:19:46 +02:00
|
|
|
|
|
|
|
```sh title="CLI command example"
|
2024-08-13 14:52:26 +02:00
|
|
|
|
|
|
|
oint telegram SendAudio --token "6129457865:AAFyzNYOAFbu..." --chat "461699897" --text "String value" --audio "https://openintegrations.dev/test_data/song.mp3" --keyboard %keyboard% --parsemode %parsemode%
|
2024-06-05 12:19:46 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```json title="Result"
|
2024-07-10 13:11:17 +02:00
|
|
|
{
|
2024-08-13 14:52:26 +02:00
|
|
|
"ok": true,
|
|
|
|
"result": {
|
|
|
|
"message_id": 4641,
|
|
|
|
"from": {
|
|
|
|
"id": 6129457865,
|
|
|
|
"is_bot": true,
|
|
|
|
"first_name": "Vitaly The Bot",
|
|
|
|
"username": "sicheebot"
|
|
|
|
},
|
|
|
|
"chat": {
|
|
|
|
"id": 461699897,
|
|
|
|
"first_name": "Anton",
|
|
|
|
"last_name": "Titowets",
|
|
|
|
"username": "JKIee",
|
|
|
|
"type": "private"
|
|
|
|
},
|
|
|
|
"date": 1717072399,
|
|
|
|
"audio": {
|
|
|
|
"duration": 228,
|
|
|
|
"file_name": "audio",
|
|
|
|
"mime_type": "audio/mpeg",
|
|
|
|
"title": "Dogs",
|
|
|
|
"performer": "Motorhead",
|
|
|
|
"file_id": "CQACAgIAAxkDAAISIWZYcg_Kxij0GylJNbAlQXeFsOL_AAKsUAACYCjISuJ28LqFPDf3NQQ",
|
|
|
|
"file_unique_id": "AgADrFAAAmAoyEo",
|
|
|
|
"file_size": 9229352
|
|
|
|
},
|
|
|
|
"caption": "String value"
|
|
|
|
}
|
|
|
|
}
|
2024-06-05 12:19:46 +02:00
|
|
|
```
|