Skip to content

Commit

Permalink
context: add boost send cases, boost: fix UserBoosts
Browse files Browse the repository at this point in the history
  • Loading branch information
Nash-Well committed May 24, 2024
1 parent a26ba9f commit c127e0a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 5 additions & 3 deletions boost.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ func (b *Bot) UserBoosts(chat, user Recipient) ([]Boost, error) {
}

var resp struct {
Result []Boost `json:"boosts"`
Result struct {
Boosts []Boost `json:"boosts"`
}
}
if err := json.Unmarshal(data, &resp); err != nil {
return nil, wrapError(err)
return nil, err
}
return resp.Result, nil
return resp.Result.Boosts, nil
}
14 changes: 14 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,20 @@ func (c *nativeContext) Sender() *User {
return c.u.ChatMember.Sender
case c.u.ChatJoinRequest != nil:
return c.u.ChatJoinRequest.Sender
case c.u.Boost != nil:
b := c.u.Boost
if b.Boost == nil && b.Boost.Source == nil {
return nil
}

return b.Boost.Source.Booster
case c.u.BoostRemoved != nil:
src := c.u.BoostRemoved.Source
if src == nil {
return nil
}

return src.Booster
default:
return nil
}
Expand Down

0 comments on commit c127e0a

Please sign in to comment.