Skip to content

Commit

Permalink
boost: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
demget committed Jun 10, 2024
1 parent 1acc928 commit 10fbde9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions boost.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func (c *Boost) ExpirationDate() time.Time {
type BoostSourceType = string

const (
BoostPremium = "premium"
BoostGiftCode = "gift_code"
BoostGiveaway = "giveaway"
BoostPremium BoostSourceType = "premium"
BoostGiftCode BoostSourceType = "gift_code"
BoostGiveaway BoostSourceType = "giveaway"
)

// BoostSource describes the source of a chat boost.
Expand Down
28 changes: 14 additions & 14 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ type Context interface {
// Topic returns the topic changes.
Topic() *Topic

// Boost returns the boost instance.
Boost() *BoostUpdated

// BoostRemoved returns the boost removed from a chat instance.
BoostRemoved() *BoostRemoved

// Sender returns the current recipient, depending on the context type.
// Returns nil if user is not presented.
Sender() *User
Expand Down Expand Up @@ -158,12 +164,6 @@ type Context interface {
// RespondAlert sends an alert response for the current callback query.
RespondAlert(text string) error

// Boost returns the boost instance.
Boost() *BoostUpdated

// BoostRemoved returns the boost removed from a chat instance.
BoostRemoved() *BoostRemoved

// Get retrieves data from the context.
Get(key string) interface{}

Expand All @@ -184,14 +184,6 @@ func (c *nativeContext) Bot() *Bot {
return c.b
}

func (c *nativeContext) Boost() *BoostUpdated {
return c.u.Boost
}

func (c *nativeContext) BoostRemoved() *BoostRemoved {
return c.u.BoostRemoved
}

func (c *nativeContext) Update() Update {
return c.u
}
Expand Down Expand Up @@ -279,6 +271,14 @@ func (c *nativeContext) Topic() *Topic {
return nil
}

func (c *nativeContext) Boost() *BoostUpdated {
return c.u.Boost
}

func (c *nativeContext) BoostRemoved() *BoostRemoved {
return c.u.BoostRemoved
}

func (c *nativeContext) Sender() *User {
switch {
case c.u.Callback != nil:
Expand Down

0 comments on commit 10fbde9

Please sign in to comment.