bump laniakea to v0.3.10
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user