Skip to content

Commit

Permalink
- add helpers bot.True() and bot.False() for define *bool values
Browse files Browse the repository at this point in the history
  • Loading branch information
negasus committed Apr 10, 2023
1 parent 0832fa8 commit e33efbe
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion methods_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit e33efbe

Please sign in to comment.