mime_type and file_size added for file messages

pull/33/head
Gleb Sinyavsky 10 years ago
parent a274ce7a9f
commit eb6b784a5a
  1. 4
      bot_test.go
  2. 10
      configs.go
  3. 2
      types_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 {

@ -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
}

@ -1,7 +1,7 @@
package tgbotapi_test
import (
"github.com/Syfaro/telegram-bot-api"
"github.com/zhulik/telegram-bot-api"
"testing"
"time"
)