Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context: implement RespondText,RespondAlert methods #660

Merged
merged 2 commits into from
Feb 29, 2024

Conversation

Nash-Well
Copy link
Contributor

Closes #627

context.go Outdated
@@ -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(t string) error
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text string

context.go Outdated
RespondText(t string) error

// RespondAlert sends an alert response for the current callback query.
RespondAlert(t string) error
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text string

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

func (c *nativeContext) RespondText(t string) error {
return c.respondTextAlert(t)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return c.Respond(&CallbackResponse{Text: text})

context.go Outdated
}

func (c *nativeContext) RespondAlert(t string) error {
return c.respondTextAlert(t, true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return c.Respond(&CallbackResponse{Text: text, Alert: true})

context.go Outdated
Comment on lines 522 to 524
if c.u.Callback == nil {
return errors.New("telebot: context callback is nil")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c.Respond already does this job, the implementation can be simpler.

@demget demget added this to the v3.3 milestone Feb 28, 2024
@demget demget changed the base branch from v3 to v3.3 February 28, 2024 16:06
@demget demget merged commit af31945 into tucnak:v3.3 Feb 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

context: add RespondText and RespondAlert shortcuts for the Respond
2 participants