From ad0b55e0e8d2e314cdb328bda50f51e3c5eed5ca Mon Sep 17 00:00:00 2001 From: Vladimir Utratenko Date: Sun, 5 Feb 2023 09:19:43 +0300 Subject: [PATCH] Add audio type (#127) Co-authored-by: Vladimir --- block.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/block.go b/block.go index 5ec0f55..8f33a9f 100644 --- a/block.go +++ b/block.go @@ -392,6 +392,29 @@ func (i Image) GetURL() string { return "" } +type AudioBlock struct { + BasicBlock + Audio Audio `json:"audio"` +} + +type Audio struct { + Caption []RichText `json:"caption,omitempty"` + Type FileType `json:"type"` + File *FileObject `json:"file,omitempty"` + External *FileObject `json:"external,omitempty"` +} + +// GetURL returns the external or internal URL depending on the image type. +func (i Audio) GetURL() string { + if i.File != nil { + return i.File.URL + } + if i.External != nil { + return i.External.URL + } + return "" +} + type CodeBlock struct { BasicBlock Code Code `json:"code"`