bump laniakea to v0.3.10

This commit is contained in:
2026-02-04 17:30:34 +03:00
parent 62d91dfe07
commit a71b7d89d7
4 changed files with 21 additions and 11 deletions

4
go.mod
View File

@@ -4,7 +4,7 @@ go 1.25.6
require (
git.nix13.pw/scuroneko/extypes v1.0.3
git.nix13.pw/scuroneko/laniakea v0.3.9
git.nix13.pw/scuroneko/laniakea v0.3.10
git.nix13.pw/scuroneko/slog v1.0.2
github.com/google/uuid v1.6.0
github.com/joho/godotenv v1.5.1
@@ -15,7 +15,7 @@ require (
go.mongodb.org/mongo-driver/v2 v2.5.0
)
//replace git.nix13.pw/scuroneko/laniakea v0.3.9 => ./laniakea
//replace git.nix13.pw/scuroneko/laniakea v0.3.10 => ./laniakea
require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect

4
go.sum
View File

@@ -2,8 +2,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
git.nix13.pw/scuroneko/extypes v1.0.3 h1:9qhvrhE7Hh1uiF5JINVxaXPtqQ+w+b1eOgwDGxhFFuY=
git.nix13.pw/scuroneko/extypes v1.0.3/go.mod h1:uZVs8Yo3RrYAG9dMad6qR6lsYY67t+459D9c65QAYAw=
git.nix13.pw/scuroneko/laniakea v0.3.9 h1:fUsqdODk8eq0CRNkxUOTwlytlgidK0KwE7Ji9KvtEkY=
git.nix13.pw/scuroneko/laniakea v0.3.9/go.mod h1:g4NsbbsRW2/JpVEqjldzf3hoP+rJtDRVtZQD6K7ma+g=
git.nix13.pw/scuroneko/laniakea v0.3.10 h1:tTxuHAR/89ijBfEPTGedseAYhJcr+kPHwKRcP/e3Js8=
git.nix13.pw/scuroneko/laniakea v0.3.10/go.mod h1:g4NsbbsRW2/JpVEqjldzf3hoP+rJtDRVtZQD6K7ma+g=
git.nix13.pw/scuroneko/slog v1.0.2 h1:vZyUROygxC2d5FJHUQM/30xFEHY1JT/aweDZXA4rm2g=
git.nix13.pw/scuroneko/slog v1.0.2/go.mod h1:3Qm2wzkR5KjwOponMfG7TcGSDjmYaFqRAmLvSPTuWJI=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=

View File

@@ -9,10 +9,23 @@ import (
func RegisterAdmin(b *laniakea.Bot) {
p := laniakea.NewPlugin("Admin")
p = p.Command(uploadPhoto, "uploadPhoto")
p.Command(uploadPhoto, "uploadPhoto")
p.Command(test, "test")
p.Middleware(laniakea.NewPluginMiddleware(func(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) bool {
rep := psql.NewUserRepository(db)
u, err := rep.GetById(ctx.FromID)
if err != nil {
return false
}
return u.Group.IsAdmin
}))
b.AddPlugins(p.Build())
}
func test(ctx *laniakea.MsgContext, _ *laniakea.DatabaseContext) {
ctx.Answer("Ok")
}
func uploadPhoto(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
rep := psql.NewUserRepository(db)
user, err := rep.GetOrCreate(ctx.FromID, ctx.Msg.From.FirstName)

View File

@@ -12,9 +12,7 @@ import (
func InitLogsPlugin() {}
func InitLogMiddleware() laniakea.Middleware {
middle := laniakea.NewMiddleware("LogMiddleware")
middle = middle.SetExecutor(logMiddleware).SetAsync(true)
return middle.Build()
return laniakea.NewMiddleware("LogMiddleware", logMiddleware).SetAsync(true).Build()
}
func logMiddleware(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
@@ -30,7 +28,7 @@ func logMiddleware(ctx *laniakea.MsgContext, db *laniakea.DatabaseContext) {
}
err := mdb.WriteMessageLog(db, entry)
if err != nil {
fmt.Println(err)
ctx.Bot.Logger().Errorln(err)
}
}
@@ -58,6 +56,5 @@ func (w *DatabaseWriter) Print(level slog.LogLevel, prefix string, traceback []*
return err
}
func DatabaseLogger(db *laniakea.DatabaseContext) slog.LoggerWriter {
w := &DatabaseWriter{db: db}
return w
return &DatabaseWriter{db: db}
}