Skip to main content

Send audio

Sends an audio file to a chat or channel

Function SendAudio(Val Token, Val ChatID, Val Text, Val Audio, Val Keyboard = "", Val Markup = "Markdown") Export

ParameterCLI optionTypeRequiredDescription
Token--tokenStringBot token
ChatID--chatString, NumberTarget chat ID or ChatID*TopicID
Text--textStringMessage text
Audio--audioBinaryData, StringAudio file
Keyboard--keyboardStringKeyboard. See FormKeyboardFromButtonArray
Markup--parsemodeStringText processing type (HTML, Markdown, MarkdownV2)

Returns: Map Of KeyAndValue - serialized JSON response from Telegram


tip

Method at API documentation: sendAudio
Parameters with Binary data type can also accept file paths on disk and URLs


1C:Enterprise/OneScript code example
    Token     = "6129457865:AAFyzNYOAFbu...";
ChatID = "461699897";
ChannelID = "@testsichee";
Text = "Строковое значение";
Audio = "https://api.athenaeum.digital/test_data/song.mp3";

AudioPath = GetTempFileName("mp3");
CopyFile(Audio, AudioPath);

AudioDD = New BinaryData(AudioPath);

Result = OPI_Telegram.SendAudio(Token, ChatID, Text, Audio);

Result = OPI_Telegram.SendAudio(Token, ChannelID, Text, AudioPath);

Result = OPI_Telegram.SendAudio(Token, ChannelID, Text, AudioDD);
    oint telegram SendAudio \
--token "***" \
--chat "@testsichee" \
--text "Строковое значение" \
--audio "C:\Users\Administrator\AppData\Local\Temp\2o23egupqbi.mp3"
Result
{
"ok": true,
"result": {
"message_id": 8306,
"from": {
"id": 6129457865,
"is_bot": true,
"first_name": "Бот Виталий",
"username": "sicheebot"
},
"chat": {
"id": 461699897,
"first_name": "Anton",
"last_name": "Titowets",
"username": "JKIee",
"type": "private"
},
"date": 1728453355,
"audio": {
"duration": 228,
"file_name": "audio",
"mime_type": "audio/mpeg",
"title": "Dogs",
"performer": "Motorhead",
"file_id": "CQACAgIAAxkDAAIgcmcGGuszMgUnk-JaG65Sngu8yYGMAAJNWgAC_cg4SEo4WdCQr5DQNgQ",
"file_unique_id": "AgADTVoAAv3IOEg",
"file_size": 9229352
},
"caption": "Строковое значение"
}
}