Skip to content

Commit

Permalink
add tochat method
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSonOfLars committed May 6, 2024
1 parent 6e83d72 commit a564ebb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions custom_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ func (im InaccessibleMessage) ToMessage() *Message {
}
}

// ToChat is a helper function to turn a ChatFullInfo struct into a Chat.
func (c ChatFullInfo) ToChat() Chat {
return Chat{
Id: c.Id,
Type: c.Type,
Title: c.Title,
Username: c.Username,
FirstName: c.FirstName,
LastName: c.LastName,
IsForum: c.IsForum,
}
}

// SendMessage is a helper function to easily call Bot.SendMessage in a chat.
func (c Chat) SendMessage(b *Bot, text string, opts *SendMessageOpts) (*Message, error) {
return b.SendMessage(c.Id, text, opts)
Expand Down

0 comments on commit a564ebb

Please sign in to comment.