Own-Programming-Language-Tu.../examples/network/okhttp_telegram_sendvoice.own

20 lines
504 B
Scala
Raw Permalink Normal View History

2023-09-09 15:52:32 +03:00
use std, okhttp
2019-05-22 19:10:48 +03:00
TOKEN = "your bot token"
println okhttp.request()
.url("https://api.telegram.org/bot" + TOKEN + "/sendVoice")
.post(MultipartBody.builder()
.setType(MultipartBody.FORM)
.addFormData({
"chat_id": "-1001100000123",
"caption": "sample text"
})
.addFormDataPart("voice", "file.ogg",
RequestBody.file("audio/ogg", "voice.ogg"))
.build()
)
.newCall(okhttp.client)
.execute()
.body()
.string()