Skip to content

Commit

Permalink
context: implement RespondText,RespondAlert methods (tucnak#660)
Browse files Browse the repository at this point in the history
* context: implement RespondText,RespondAlert methods

* context: refactor
  • Loading branch information
Nash-Well authored Feb 29, 2024
1 parent 5ff8b89 commit af31945
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ type Context interface {
// See Respond from bot.go.
Respond(resp ...*CallbackResponse) error

// RespondText sends a popup response for the current callback query.
RespondText(text string) error

// RespondAlert sends an alert response for the current callback query.
RespondAlert(text string) error

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

Expand Down Expand Up @@ -481,6 +487,14 @@ func (c *nativeContext) Respond(resp ...*CallbackResponse) error {
return c.b.Respond(c.u.Callback, resp...)
}

func (c *nativeContext) RespondText(text string) error {
return c.Respond(&CallbackResponse{Text: text})
}

func (c *nativeContext) RespondAlert(text string) error {
return c.Respond(&CallbackResponse{Text: text, ShowAlert: true})
}

func (c *nativeContext) Answer(resp *QueryResponse) error {
if c.u.Query == nil {
return errors.New("telebot: context inline query is nil")
Expand Down

0 comments on commit af31945

Please sign in to comment.