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
AllowsMultipleAnswers bool
CorrectOptionID int64
Explanation string
ExplanationParseMode string
OpenPeriod int
CloseDate int
IsClosed bool
}
@ -526,6 +530,10 @@ func (config SendPollConfig) params() (Params, error) {
params["allows_multiple_answers"] = strconv.FormatBool(config.AllowsMultipleAnswers)
params["correct_option_id"] = strconv.FormatInt(config.CorrectOptionID, 10)
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
}
@ -1666,6 +1674,8 @@ func (config MediaGroupConfig) params() (Params, error) {
// DiceConfig allows you to send a random dice roll to Telegram.
type DiceConfig struct {
BaseChat
Emoji string
}
func (config DiceConfig) method() string {
@ -1673,7 +1683,14 @@ func (config DiceConfig) method() string {
}
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.

View File

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

View File

@ -494,10 +494,15 @@ type Poll struct {
Type string `json:"type"`
AllowsMultipleAnswers bool `json:"allows_multiple_answers"`
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.
type Dice struct {
Emoji string `json:"emoji"`
Value int `json:"value"`
}
@ -535,7 +540,7 @@ type KeyboardButton struct {
Text string `json:"text"`
RequestContact bool `json:"request_contact"`
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