init code

This commit is contained in:
thuanle
2024-10-24 09:53:23 +07:00
parent a7559b3f9d
commit 92a63c7885
43 changed files with 1115 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
package middlewares
import (
"fmt"
"github.com/rs/zerolog/log"
"gopkg.in/telebot.v3"
)
func SendErrorMiddleware(next telebot.HandlerFunc) telebot.HandlerFunc {
return func(c telebot.Context) error {
err := next(c) // continue execution chain
if err != nil {
log.Debug().Err(err).Msg("Chat Middleware error reply")
return c.Reply(fmt.Sprintf("Error: %v", err), telebot.RemoveKeyboard)
}
return nil
}
}

View File

@@ -0,0 +1,14 @@
package middlewares
import (
"gopkg.in/telebot.v3"
)
func IgnoreBot(next telebot.HandlerFunc) telebot.HandlerFunc {
return func(c telebot.Context) error {
if c.Sender().IsBot {
return nil
}
return next(c)
}
}