boost: refactor

pull/694/merge
Demian 4 months ago
parent 1acc928a92
commit 10fbde9b66

@ -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.

@ -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
@ -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{}
@ -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
}
@ -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:

Loading…
Cancel
Save