Skip to content

Commit

Permalink
implement class ChatFullInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Apolisk committed Jun 19, 2024
1 parent 167b637 commit 34ec635
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ func (b *Bot) ChatByID(id int64) (*Chat, error) {
}

// ChatByUsername fetches chat info by its username.
func (b *Bot) ChatByUsername(name string) (*Chat, error) {
func (b *Bot) ChatByUsername(name string) (*ChatFullInfo, error) {
params := map[string]string{
"chat_id": name,
}
Expand Down
16 changes: 15 additions & 1 deletion chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ type Chat struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Username string `json:"username"`
}

type ChatFullInfo struct {
ID int64 `json:"id"`

// See ChatType and consts.
Type ChatType `json:"type"`

// Won't be there for ChatPrivate.
Title string `json:"title"`

FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Username string `json:"username"`

// Returns only in getChat
Bio string `json:"bio,omitempty"`
Expand Down Expand Up @@ -332,7 +346,7 @@ func (r ChatJoinRequest) Time() time.Time {
}

// Time returns the moment of the emoji status expiration.
func (c *Chat) Time() time.Time {
func (c *ChatFullInfo) Time() time.Time {
return time.Unix(c.EmojiExpirationUnixtime, 0)
}

Expand Down

0 comments on commit 34ec635

Please sign in to comment.