From e33efbedec6b02dcc54b6ca0221c551abd7cb862 Mon Sep 17 00:00:00 2001 From: Negasus Date: Mon, 10 Apr 2023 10:43:31 +0300 Subject: [PATCH] - add helpers `bot.True()` and `bot.False()` for define *bool values --- CHANGELOG.md | 5 +++++ README.md | 15 +++++++++++++++ bot.go | 10 ++++++++++ methods_params.go | 2 +- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ca6963..9626502 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v0.7.4 (2023-04-10) + +- [BUGFIX] change field `SendPollParams.IsAnonymous` to *bool (#26) +- add helpers `bot.True()` and `bot.False()` for define *bool values + ## v0.7.3 (2023-04-05) - make `bot.ProcessUpdate` public diff --git a/README.md b/README.md index 83fc962..74ef1a2 100644 --- a/README.md +++ b/README.md @@ -308,6 +308,21 @@ Escape only unescaped special symbols for Telegram MarkdownV2 syntax Returns fast random a-zA-Z string with n length +### `True() bool`, `False() bool` + +Allows you to define *bool values for params, which require `*bool`, like `SendPoolParams` + +```go +p := &bot.SendPollParams{ + ChatID: chatID, + Question: "Question", + Options: []string{"Option 1", "Option 2"}, + IsAnonymous: bot.False(), +} + +b.SendPool(ctx, p) +``` + ## UI Components In the repo https://github.com/go-telegram/ui you can find a some UI elements for your bot. diff --git a/bot.go b/bot.go index dca1bd7..4a4728b 100644 --- a/bot.go +++ b/bot.go @@ -125,3 +125,13 @@ func (b *Bot) debug(format string, args ...interface{}) { log.Printf("[TGBOT] [DEBUG] "+format, args...) } + +func True() *bool { + b := true + return &b +} + +func False() *bool { + b := false + return &b +} diff --git a/methods_params.go b/methods_params.go index 31e989f..5a58c5b 100644 --- a/methods_params.go +++ b/methods_params.go @@ -255,7 +255,7 @@ type SendPollParams struct { MessageThreadID int `json:"message_thread_id,omitempty"` Question string `json:"question"` Options []string `json:"options"` - IsAnonymous *bool `json:"is_anonymous,omitempty"` + IsAnonymous *bool `json:"is_anonymous,omitempty"` Type string `json:"type,omitempty"` AllowsMultipleAnswers bool `json:"allows_multiple_answers,omitempty"` CorrectOptionID int `json:"correct_option_id"`