Skip to content

Commit eb6b784

Browse files
committed
mime_type and file_size added for file messages
1 parent a274ce7 commit eb6b784

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

bot_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package tgbotapi_test
22

33
import (
4-
"github.com/Syfaro/telegram-bot-api"
4+
"github.com/zhulik/telegram-bot-api"
55
"io/ioutil"
66
"log"
77
"net/http"
@@ -184,6 +184,8 @@ func TestSendWithNewAudio(t *testing.T) {
184184
msg.Title = "TEST"
185185
msg.Duration = 10
186186
msg.Performer = "TEST"
187+
msg.MimeType = "audio/mpeg"
188+
msg.FileSize = 688
187189
_, err := bot.Send(msg)
188190

189191
if err != nil {

configs.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ type BaseFile struct {
9393
File interface{}
9494
FileID string
9595
UseExisting bool
96+
MimeType string
97+
FileSize int
9698
}
9799

98100
// Params returns map[string]string representation of BaseFile
@@ -118,6 +120,14 @@ func (file BaseFile) Params() (map[string]string, error) {
118120
params["reply_markup"] = string(data)
119121
}
120122

123+
if len(file.MimeType) > 0 {
124+
params["mime_type"] = file.MimeType
125+
}
126+
127+
if file.FileSize > 0 {
128+
params["file_size"] = strconv.Itoa(file.FileSize)
129+
}
130+
121131
return params, nil
122132
}
123133

types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package tgbotapi_test
22

33
import (
4-
"github.com/Syfaro/telegram-bot-api"
4+
"github.com/zhulik/telegram-bot-api"
55
"testing"
66
"time"
77
)

0 commit comments

Comments
 (0)