1
0
mirror of https://shylinux.com/x/icebergs synced 2025-05-03 20:07:01 +08:00
This commit is contained in:
shaoying 2020-06-29 11:40:00 +08:00
parent e9de89de7d
commit 3d8854b838
3 changed files with 17 additions and 68 deletions

View File

@ -13,13 +13,13 @@ func init() {
RENDER: {Name: "render", Help: "渲染引擎", Value: kit.Data(kit.MDB_SHORT, kit.MDB_TYPE)}, RENDER: {Name: "render", Help: "渲染引擎", Value: kit.Data(kit.MDB_SHORT, kit.MDB_TYPE)},
}, },
Commands: map[string]*ice.Command{ Commands: map[string]*ice.Command{
RENDER: {Name: "search type name text arg...", Help: "渲染引擎", Action: map[string]*ice.Action{ RENDER: {Name: "render type name text arg...", Help: "渲染引擎", Action: map[string]*ice.Action{
CREATE: {Name: "create type name [text]", Help: "创建", Hand: func(m *ice.Message, arg ...string) { CREATE: {Name: "create type [cmd [ctx]]", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Rich(RENDER, nil, kit.Dict(kit.MDB_TYPE, arg[0], kit.MDB_NAME, arg[1], kit.MDB_TEXT, kit.Select("", arg, 2))) m.Rich(RENDER, nil, kit.Dict(kit.MDB_TYPE, arg[0], kit.MDB_NAME, kit.Select(arg[0], arg, 1), kit.MDB_TEXT, kit.Select("", arg, 2)))
}}, }},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Richs(RENDER, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) { m.Richs(RENDER, nil, arg[0], func(key string, value map[string]interface{}) {
m.Cmdy(kit.Keys(value[kit.MDB_TEXT], value[kit.MDB_NAME]), arg[0], arg[1], kit.Select("", arg, 2)) m.Cmdy(kit.Keys(value[kit.MDB_TEXT], value[kit.MDB_NAME]), RENDER, arg[0], arg[1], kit.Select("", arg, 2))
}) })
}}, }},
}}, nil) }}, nil)

View File

@ -15,12 +15,17 @@ func init() {
SEARCH: {Name: "search", Help: "搜索引擎", Value: kit.Data(kit.MDB_SHORT, kit.MDB_TYPE)}, SEARCH: {Name: "search", Help: "搜索引擎", Value: kit.Data(kit.MDB_SHORT, kit.MDB_TYPE)},
}, },
Commands: map[string]*ice.Command{ Commands: map[string]*ice.Command{
SEARCH: {Name: "search word type...", Help: "搜索引擎", Action: map[string]*ice.Action{ SEARCH: {Name: "search word text type...", Help: "搜索引擎", Action: map[string]*ice.Action{
CREATE: {Name: "create type name [text]", Help: "创建", Hand: func(m *ice.Message, arg ...string) { CREATE: {Name: "create type [cmd [ctx]]", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Rich(SEARCH, nil, kit.Dict(kit.MDB_TYPE, arg[0], kit.MDB_NAME, arg[1], kit.MDB_TEXT, kit.Select("", arg, 2))) m.Rich(SEARCH, nil, kit.Dict(kit.MDB_TYPE, arg[0], kit.MDB_NAME, kit.Select(arg[0], arg, 1), kit.MDB_TEXT, kit.Select("", arg, 2)))
}}, }},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 || arg[0] == "" {
m.Richs(SEARCH, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
m.Push(key, value, []string{kit.MDB_TYPE, kit.MDB_NAME, kit.MDB_TEXT})
})
return
}
if strings.Contains(arg[0], ";") { if strings.Contains(arg[0], ";") {
arg = strings.Split(arg[0], ";") arg = strings.Split(arg[0], ";")
} }
@ -35,65 +40,6 @@ func init() {
m.Cmdy(kit.Keys(value[kit.MDB_TEXT], value[kit.MDB_NAME]), SEARCH, value[kit.MDB_TYPE], arg[0], kit.Select("", arg, 1)) m.Cmdy(kit.Keys(value[kit.MDB_TEXT], value[kit.MDB_NAME]), SEARCH, value[kit.MDB_TYPE], arg[0], kit.Select("", arg, 1))
}) })
} }
return
if len(arg) < 2 {
m.Cmdy("web.label", arg)
return
}
switch arg[0] {
case "add":
if m.Richs(cmd, nil, arg[1], nil) == nil {
m.Rich(cmd, nil, kit.Data(kit.MDB_NAME, arg[1]))
}
m.Richs(cmd, nil, arg[1], func(key string, value map[string]interface{}) {
m.Grow(cmd, kit.Keys(kit.MDB_HASH, key), kit.Dict(
kit.MDB_NAME, arg[2], kit.MDB_TEXT, arg[3:],
))
})
case "get":
wg := &sync.WaitGroup{}
m.Richs(cmd, nil, arg[1], func(key string, value map[string]interface{}) {
wg.Add(1)
m.Gos(m, func(m *ice.Message) {
m.Grows(cmd, kit.Keys(kit.MDB_HASH, key), "", "", func(index int, value map[string]interface{}) {
m.Cmdy(value[kit.MDB_TEXT], arg[2:])
})
wg.Done()
})
})
wg.Wait()
case "set":
if arg[1] != "" {
m.Cmdy("web.space", arg[1], "web.chat.search", "set", "", arg[2:])
break
}
m.Richs(cmd, nil, arg[2], func(key string, value map[string]interface{}) {
m.Grows(cmd, kit.Keys(kit.MDB_HASH, key), "", "", func(index int, value map[string]interface{}) {
m.Cmdy(value[kit.MDB_TEXT], "set", arg[3:])
})
})
default:
if len(arg) < 4 {
m.Richs(cmd, nil, kit.Select(kit.MDB_FOREACH, arg, 2), func(key string, val map[string]interface{}) {
if len(arg) < 3 {
m.Push(key, val[kit.MDB_META], []string{kit.MDB_TIME, kit.MDB_NAME, kit.MDB_COUNT})
return
}
m.Grows(cmd, kit.Keys(kit.MDB_HASH, key), "", "", func(index int, value map[string]interface{}) {
m.Push("", value, []string{kit.MDB_TIME})
m.Push("group", arg[2])
m.Push("", value, []string{kit.MDB_NAME, kit.MDB_TEXT})
})
})
break
}
m.Option("pod", "")
m.Cmdy("web.label", arg[0], arg[1], "web.chat.search", "get", arg[2:])
m.Sort("time", "time_r")
}
}}, }},
"commend": {Name: "commend label pod engine work auto", Help: "推荐引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { "commend": {Name: "commend label pod engine work auto", Help: "推荐引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) < 2 { if len(arg) < 2 {

View File

@ -109,6 +109,9 @@ func (c *Context) cmd(m *Message, cmd *Command, key string, arg ...string) *Mess
} }
} }
if len(arg) > 0 && arg[0] == "render" {
arg = arg[1:]
}
m.Log(LOG_CMDS, "%s.%s %d %v %s", c.Name, key, len(arg), arg, kit.FileLine(cmd.Hand, 3)) m.Log(LOG_CMDS, "%s.%s %d %v %s", c.Name, key, len(arg), arg, kit.FileLine(cmd.Hand, 3))
cmd.Hand(m, c, key, arg...) cmd.Hand(m, c, key, arg...)
return m return m