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

Migrate to bot middlewares #128

Open
javiyt opened this issue Feb 8, 2022 · 0 comments
Open

Migrate to bot middlewares #128

javiyt opened this issue Feb 8, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request go Pull requests that update Go code

Comments

@javiyt
Copy link
Owner

javiyt commented Feb 8, 2022

Use telebot middlewares https://github.com/tucnak/telebot/releases/tag/v3.0.0

// Global-scoped middleware:
b.Use(middleware.Logger()) // logs every incoming handled event
b.Use(middleware.AutoRespond()) // automatically responds to every callback

// Group-scoped middleware:
adminOnly := b.Group()
adminOnly.Use(middleware.Whitelist(adminIDs...))
adminOnly.Handle("/ban", onBan)
adminOnly.Handle("/kick", onKick)

// Handler-scoped middleware:
b.Handle(tele.OnText, onText, middleware.IgnoreVia())
@javiyt javiyt added enhancement New feature or request go Pull requests that update Go code labels Feb 8, 2022
@javiyt javiyt self-assigned this Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go Pull requests that update Go code
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant