Bot API 4.6: Polls 2.0, misc. changes

This commit is contained in:
TJ Horner 2020-01-24 22:42:19 -05:00
parent 5ce2767dad
commit 5aaa0b2d03
4 changed files with 59 additions and 22 deletions

View file

@ -3,6 +3,7 @@ package tgbotapi
import (
"io"
"net/url"
"strconv"
)
// Telegram constants
@ -503,8 +504,13 @@ func (config ContactConfig) method() string {
// SendPollConfig allows you to send a poll.
type SendPollConfig struct {
BaseChat
Question string
Options []string
Question string
Options []string
IsAnonymous bool
Type string
AllowsMultipleAnswers bool
CorrectOptionID int64
IsClosed bool
}
func (config SendPollConfig) params() (Params, error) {
@ -515,6 +521,11 @@ func (config SendPollConfig) params() (Params, error) {
params["question"] = config.Question
err = params.AddInterface("options", config.Options)
params["is_anonymous"] = strconv.FormatBool(config.IsAnonymous)
params.AddNonEmpty("type", config.Type)
params["allows_multiple_answers"] = strconv.FormatBool(config.AllowsMultipleAnswers)
params["correct_option_id"] = strconv.FormatInt(config.CorrectOptionID, 10)
params["is_closed"] = strconv.FormatBool(config.IsClosed)
return params, err
}