Closed sdrissen closed 4 years ago
Nevermind, I solved it
KeyboardButtonPollType
must be a pointer, to make omitempty working.
I am not sure, if this make something worse. But for the moment, it works for me.
Please change the file types.go
, if you think, that my solution would work for everyone.
And if not, let me know, how you would solve it.
// KeyboardButton is a button within a custom keyboard.
type KeyboardButton struct {
Text string `json:"text"`
RequestContact bool `json:"request_contact"`
RequestLocation bool `json:"request_location"`
RequestPoll *KeyboardButtonPollType `json:"request_poll,omitempty"`
}
// KeyboardButtonPollType represents type of a poll, which is allowed to
// be created and sent when the corresponding button is pressed.
type KeyboardButtonPollType struct {
Type string `json:"type,omitempty"`
}
Yes, that's how I would fix it. Thank you for opening this issue, it's now fixed in https://github.com/go-telegram-bot-api/telegram-bot-api/commit/774f1e72e7647a5e78d4d3345f54581249bbf110.
I work with the develop-branch and try to make KeyboardButtons with text only, but it always prompt a poll.
I tried the following in types.go: (explanation below)
As you see, I added omitempty to
RequestPoll
inKeyboardButton
and toType
inKeyboardButtonPollType
.But it has no use:
The telegram bot API doc says about
Type
inKeyboardButtonPollType
:I think the "Otherwise, the user will be allowed to create a poll of any type" is matched here, because
request_poll
is not omitted, and therefore the Type-String is neitherquiz
orregular
.By the way, why don't you omit every empty and optional parameters?