merge main repo changes

bot-api-6.1
Amir Khazaie 2018-09-01 10:49:31 +04:30
commit d066ae74e6
5 changed files with 63 additions and 16 deletions

View File

@ -1,5 +1,6 @@
language: go language: go
go: go:
- 1.4 - '1.10'
- '1.11'
- tip - tip

1
bot.go
View File

@ -9,7 +9,6 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"log"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"

View File

@ -253,10 +253,10 @@ func (config PhotoConfig) params() (map[string]string, error) {
if config.Caption != "" { if config.Caption != "" {
params["caption"] = config.Caption params["caption"] = config.Caption
}
if config.ParseMode != "" { if config.ParseMode != "" {
params["parse_mode"] = config.ParseMode params["parse_mode"] = config.ParseMode
} }
}
return params, nil return params, nil
} }
@ -271,10 +271,11 @@ func (config PhotoConfig) values() (url.Values, error) {
v.Add(config.name(), config.FileID) v.Add(config.name(), config.FileID)
if config.Caption != "" { if config.Caption != "" {
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
}
if config.ParseMode != "" { if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode) v.Add("parse_mode", config.ParseMode)
} }
}
return v, nil return v, nil
} }
@ -292,6 +293,7 @@ func (config PhotoConfig) method() string {
type AudioConfig struct { type AudioConfig struct {
BaseFile BaseFile
Caption string Caption string
ParseMode string
Duration int Duration int
Performer string Performer string
Title string Title string
@ -317,6 +319,9 @@ func (config AudioConfig) values() (url.Values, error) {
} }
if config.Caption != "" { if config.Caption != "" {
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
} }
return v, nil return v, nil
@ -338,6 +343,9 @@ func (config AudioConfig) params() (map[string]string, error) {
} }
if config.Caption != "" { if config.Caption != "" {
params["caption"] = config.Caption params["caption"] = config.Caption
if config.ParseMode != "" {
params["parse_mode"] = config.ParseMode
}
} }
return params, nil return params, nil
@ -357,6 +365,7 @@ func (config AudioConfig) method() string {
type DocumentConfig struct { type DocumentConfig struct {
BaseFile BaseFile
Caption string Caption string
ParseMode string
} }
// values returns a url.Values representation of DocumentConfig. // values returns a url.Values representation of DocumentConfig.
@ -369,6 +378,9 @@ func (config DocumentConfig) values() (url.Values, error) {
v.Add(config.name(), config.FileID) v.Add(config.name(), config.FileID)
if config.Caption != "" { if config.Caption != "" {
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
} }
return v, nil return v, nil
@ -380,6 +392,9 @@ func (config DocumentConfig) params() (map[string]string, error) {
if config.Caption != "" { if config.Caption != "" {
params["caption"] = config.Caption params["caption"] = config.Caption
if config.ParseMode != "" {
params["parse_mode"] = config.ParseMode
}
} }
return params, nil return params, nil
@ -434,6 +449,7 @@ type VideoConfig struct {
BaseFile BaseFile
Duration int Duration int
Caption string Caption string
ParseMode string
} }
// values returns a url.Values representation of VideoConfig. // values returns a url.Values representation of VideoConfig.
@ -449,6 +465,9 @@ func (config VideoConfig) values() (url.Values, error) {
} }
if config.Caption != "" { if config.Caption != "" {
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
} }
return v, nil return v, nil
@ -460,6 +479,9 @@ func (config VideoConfig) params() (map[string]string, error) {
if config.Caption != "" { if config.Caption != "" {
params["caption"] = config.Caption params["caption"] = config.Caption
if config.ParseMode != "" {
params["parse_mode"] = config.ParseMode
}
} }
return params, nil return params, nil
@ -530,6 +552,7 @@ func (config VideoNoteConfig) method() string {
type VoiceConfig struct { type VoiceConfig struct {
BaseFile BaseFile
Caption string Caption string
ParseMode string
Duration int Duration int
} }
@ -546,6 +569,9 @@ func (config VoiceConfig) values() (url.Values, error) {
} }
if config.Caption != "" { if config.Caption != "" {
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode)
}
} }
return v, nil return v, nil
@ -560,6 +586,9 @@ func (config VoiceConfig) params() (map[string]string, error) {
} }
if config.Caption != "" { if config.Caption != "" {
params["caption"] = config.Caption params["caption"] = config.Caption
if config.ParseMode != "" {
params["parse_mode"] = config.ParseMode
}
} }
return params, nil return params, nil
@ -801,7 +830,9 @@ func (config EditMessageCaptionConfig) values() (url.Values, error) {
v, _ := config.BaseEdit.values() v, _ := config.BaseEdit.values()
v.Add("caption", config.Caption) v.Add("caption", config.Caption)
if config.ParseMode != "" {
v.Add("parse_mode", config.ParseMode) v.Add("parse_mode", config.ParseMode)
}
return v, nil return v, nil
} }

View File

@ -1,7 +1,6 @@
package tgbotapi package tgbotapi
import ( import (
"log"
"net/url" "net/url"
) )

17
log.go 100644
View File

@ -0,0 +1,17 @@
package tgbotapi
import (
"os"
"errors"
stdlog "log"
)
var log = stdlog.New(os.Stderr, "", stdlog.LstdFlags)
func SetLogger(newLog *stdlog.Logger) error {
if newLog == nil {
return errors.New("logger is nil")
}
log = newLog
return nil
}