Updates for Bot API 4.4 and 4.5.

This commit is contained in:
Syfaro 2020-01-06 01:44:13 -06:00
parent ffe77fb717
commit 5ce2767dad
6 changed files with 266 additions and 91 deletions

View file

@ -37,13 +37,6 @@ func (p Params) AddBool(key string, value bool) {
}
}
// AddNonNilBool adds the value of a bool pointer if not nil.
func (p Params) AddNonNilBool(key string, value *bool) {
if value != nil {
p[key] = strconv.FormatBool(*value)
}
}
// AddNonZeroFloat adds a floating point value that is not zero.
func (p Params) AddNonZeroFloat(key string, value float64) {
if value != 0 {
@ -76,14 +69,17 @@ func (p Params) AddFirstValid(key string, args ...interface{}) error {
case int:
if v != 0 {
p[key] = strconv.Itoa(v)
return nil
}
case int64:
if v != 0 {
p[key] = strconv.FormatInt(v, 10)
return nil
}
case string:
if v != "" {
p[key] = v
return nil
}
case nil:
default:
@ -93,6 +89,7 @@ func (p Params) AddFirstValid(key string, args ...interface{}) error {
}
p[key] = string(b)
return nil
}
}