From eb6b784a5a27882aa5c911db45bfacecc31dad98 Mon Sep 17 00:00:00 2001 From: Gleb Sinyavsky Date: Sun, 13 Dec 2015 20:00:20 +0300 Subject: [PATCH] mime_type and file_size added for file messages --- bot_test.go | 4 +++- configs.go | 10 ++++++++++ types_test.go | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bot_test.go b/bot_test.go index 17cedac..cd9cdcf 100644 --- a/bot_test.go +++ b/bot_test.go @@ -1,7 +1,7 @@ package tgbotapi_test import ( - "github.com/Syfaro/telegram-bot-api" + "github.com/zhulik/telegram-bot-api" "io/ioutil" "log" "net/http" @@ -184,6 +184,8 @@ func TestSendWithNewAudio(t *testing.T) { msg.Title = "TEST" msg.Duration = 10 msg.Performer = "TEST" + msg.MimeType = "audio/mpeg" + msg.FileSize = 688 _, err := bot.Send(msg) if err != nil { diff --git a/configs.go b/configs.go index 16afef1..0b390f8 100644 --- a/configs.go +++ b/configs.go @@ -93,6 +93,8 @@ type BaseFile struct { File interface{} FileID string UseExisting bool + MimeType string + FileSize int } // Params returns map[string]string representation of BaseFile @@ -118,6 +120,14 @@ func (file BaseFile) Params() (map[string]string, error) { params["reply_markup"] = string(data) } + if len(file.MimeType) > 0 { + params["mime_type"] = file.MimeType + } + + if file.FileSize > 0 { + params["file_size"] = strconv.Itoa(file.FileSize) + } + return params, nil } diff --git a/types_test.go b/types_test.go index 68c57bb..055877f 100644 --- a/types_test.go +++ b/types_test.go @@ -1,7 +1,7 @@ package tgbotapi_test import ( - "github.com/Syfaro/telegram-bot-api" + "github.com/zhulik/telegram-bot-api" "testing" "time" )