go-telegram/bot

Cannot set SendPollParams.IsAnonymous to false

srgustafson8 opened this issue · 0 comments

You are unable to send a new poll that is non-anonymous. This seems to be because the IsAnonymous field on the SendPollParams type is a non-pointer bool, set to omitempty and defaults to true on the Telegram API. I believe this is why - false boolean is treated as empty and therefore omitted.

To reproduce

func main() {
	b, _ := bot.New(telegram_token)

	poll := &bot.SendPollParams{
		ChatID: chat_id,
		Question: "Test poll",
		Options: []string{"1", "2", "3"},
		AllowsMultipleAnswers: true,
		IsAnonymous: false,
	}

	msg, _ := b.SendPoll(context.TODO(), poll)
	log.Printf("Poll is anonymous?: %t", msg.Poll.IsAnonymous)
}
[stdout]
2023/04/08 20:10:20 Poll is anonymous?: true

I'll open a PR soon to set the type to be a *bool which I believe will fix it in this case.