some changes
This commit is contained in:
@@ -2,8 +2,10 @@ package plugins
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
"ymgb/database"
|
||||
"ymgb/database/psql"
|
||||
|
||||
@@ -18,6 +20,7 @@ func RegisterAdmin() *laniakea.Plugin[database.Context] {
|
||||
p.AddCommand(laniakea.NewCommand(uploadPhoto, "uploadPhoto").SkipCommandAutoGen())
|
||||
p.AddCommand(laniakea.NewCommand(emojiId, "emojiId").SkipCommandAutoGen())
|
||||
p.AddCommand(laniakea.NewCommand(execSql, "sql").SkipCommandAutoGen())
|
||||
p.AddCommand(laniakea.NewCommand(test, "test").SkipCommandAutoGen())
|
||||
|
||||
p.AddMiddleware(AdminMiddleware())
|
||||
return p
|
||||
@@ -33,6 +36,17 @@ func AdminMiddleware() laniakea.Middleware[database.Context] {
|
||||
})
|
||||
return *m
|
||||
}
|
||||
func test(ctx *laniakea.MsgContext, _ *database.Context) {
|
||||
draft := ctx.NewDraft()
|
||||
for i := 0; i < 10; i++ {
|
||||
err := draft.Push(fmt.Sprintf("%d", i))
|
||||
if err != nil {
|
||||
ctx.Error(err)
|
||||
return
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
func execSql(ctx *laniakea.MsgContext, db *database.Context) {
|
||||
stmt := strings.Join(ctx.Args, " ")
|
||||
|
||||
Reference in New Issue
Block a user