Updates for Bot API 4.8.

bot-api-6.1
Syfaro 2020-04-24 13:18:26 -05:00
parent 75e27e1380
commit 774f1e72e7
3 changed files with 38 additions and 15 deletions

View File

@ -510,6 +510,10 @@ type SendPollConfig struct {
Type string Type string
AllowsMultipleAnswers bool AllowsMultipleAnswers bool
CorrectOptionID int64 CorrectOptionID int64
Explanation string
ExplanationParseMode string
OpenPeriod int
CloseDate int
IsClosed bool IsClosed bool
} }
@ -526,6 +530,10 @@ func (config SendPollConfig) params() (Params, error) {
params["allows_multiple_answers"] = strconv.FormatBool(config.AllowsMultipleAnswers) params["allows_multiple_answers"] = strconv.FormatBool(config.AllowsMultipleAnswers)
params["correct_option_id"] = strconv.FormatInt(config.CorrectOptionID, 10) params["correct_option_id"] = strconv.FormatInt(config.CorrectOptionID, 10)
params.AddBool("is_closed", config.IsClosed) params.AddBool("is_closed", config.IsClosed)
params.AddNonEmpty("explanation", config.Explanation)
params.AddNonEmpty("explanation_parse_mode", config.ExplanationParseMode)
params.AddNonZero("open_period", config.OpenPeriod)
params.AddNonZero("close_date", config.CloseDate)
return params, err return params, err
} }
@ -1666,6 +1674,8 @@ func (config MediaGroupConfig) params() (Params, error) {
// DiceConfig allows you to send a random dice roll to Telegram. // DiceConfig allows you to send a random dice roll to Telegram.
type DiceConfig struct { type DiceConfig struct {
BaseChat BaseChat
Emoji string
} }
func (config DiceConfig) method() string { func (config DiceConfig) method() string {
@ -1673,7 +1683,14 @@ func (config DiceConfig) method() string {
} }
func (config DiceConfig) params() (Params, error) { func (config DiceConfig) params() (Params, error) {
return config.BaseChat.params() params, err := config.BaseChat.params()
if err != nil {
return params, err
}
params.AddNonEmpty("emoji", config.Emoji)
return params, err
} }
// GetMyCommandsConfig gets a list of the currently registered commands. // GetMyCommandsConfig gets a list of the currently registered commands.

View File

@ -918,9 +918,10 @@ func NewStopPoll(chatID int64, messageID int) StopPollConfig {
// NewSendDice allows you to send a random dice roll. // NewSendDice allows you to send a random dice roll.
func NewSendDice(chatID int64) DiceConfig { func NewSendDice(chatID int64) DiceConfig {
return DiceConfig{ return DiceConfig{
BaseChat{ BaseChat: BaseChat{
ChatID: chatID, ChatID: chatID,
}, },
Emoji: "",
} }
} }

View File

@ -494,10 +494,15 @@ type Poll struct {
Type string `json:"type"` Type string `json:"type"`
AllowsMultipleAnswers bool `json:"allows_multiple_answers"` AllowsMultipleAnswers bool `json:"allows_multiple_answers"`
CorrectOptionID int `json:"correct_option_id"` // optional CorrectOptionID int `json:"correct_option_id"` // optional
Explanation string `json:"explanation"` // optional
ExplanationEntities []MessageEntity `json:"explanation_entities"` // optional
OpenPeriod int `json:"open_period"` // optional
CloseDate int `json:"close_date"` // optional
} }
// Dice represents a single dice value. // Dice represents a single dice value.
type Dice struct { type Dice struct {
Emoji string `json:"emoji"`
Value int `json:"value"` Value int `json:"value"`
} }
@ -535,7 +540,7 @@ type KeyboardButton struct {
Text string `json:"text"` Text string `json:"text"`
RequestContact bool `json:"request_contact"` RequestContact bool `json:"request_contact"`
RequestLocation bool `json:"request_location"` RequestLocation bool `json:"request_location"`
RequestPoll KeyboardButtonPollType `json:"request_poll"` RequestPoll *KeyboardButtonPollType `json:"request_poll,omitempty"`
} }
// KeyboardButtonPollType represents type of a poll, which is allowed to // KeyboardButtonPollType represents type of a poll, which is allowed to