forked from x/icebergs
add river.node
This commit is contained in:
parent
60ddf0d12d
commit
2278ba3079
@ -6,6 +6,7 @@ import (
|
|||||||
aaa "github.com/shylinux/icebergs/base/aaa"
|
aaa "github.com/shylinux/icebergs/base/aaa"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/gdb"
|
"github.com/shylinux/icebergs/base/gdb"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
"github.com/shylinux/toolkits/task"
|
"github.com/shylinux/toolkits/task"
|
||||||
|
|
||||||
@ -186,6 +187,20 @@ func _space_handle(m *ice.Message, safe bool, send map[string]*ice.Message, c *w
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _space_search(m *ice.Message, kind, name, text string, arg ...string) {
|
||||||
|
m.Richs(SPACE, nil, kit.Select(kit.MDB_FOREACH, name), func(key string, value map[string]interface{}) {
|
||||||
|
if name != "" && name != value[kit.MDB_NAME] && !strings.Contains(kit.Format(value[kit.MDB_TEXT]), name) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.Push("pod", m.Option("pod"))
|
||||||
|
m.Push("ctx", "web")
|
||||||
|
m.Push("cmd", SPACE)
|
||||||
|
m.Push(key, value, []string{kit.MDB_TIME})
|
||||||
|
m.Push(kit.MDB_SIZE, kit.FmtSize(int64(len(kit.Format(value[kit.MDB_TEXT])))))
|
||||||
|
m.Push(key, value, []string{kit.MDB_TYPE, kit.MDB_NAME, kit.MDB_TEXT})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const SPACE = "space"
|
const SPACE = "space"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -208,6 +223,9 @@ func init() {
|
|||||||
"connect": {Name: "connect [dev [name]]", Help: "连接", Hand: func(m *ice.Message, arg ...string) {
|
"connect": {Name: "connect [dev [name]]", Help: "连接", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_space_dial(m, kit.Select("dev", arg, 0), kit.Select(cli.NodeName, arg, 2))
|
_space_dial(m, kit.Select("dev", arg, 0), kit.Select(cli.NodeName, arg, 2))
|
||||||
}},
|
}},
|
||||||
|
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
_space_search(m, arg[0], arg[1], arg[2], arg[3:]...)
|
||||||
|
}},
|
||||||
}, 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) < 2 {
|
if len(arg) < 2 {
|
||||||
_space_list(m, kit.Select("", arg, 0))
|
_space_list(m, kit.Select("", arg, 0))
|
||||||
|
@ -107,6 +107,7 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
m.Cmd(mdb.SEARCH, mdb.CREATE, FAVOR)
|
m.Cmd(mdb.SEARCH, mdb.CREATE, FAVOR)
|
||||||
m.Cmd(mdb.SEARCH, mdb.CREATE, SPIDE)
|
m.Cmd(mdb.SEARCH, mdb.CREATE, SPIDE)
|
||||||
m.Cmd(mdb.RENDER, mdb.CREATE, SPIDE)
|
m.Cmd(mdb.RENDER, mdb.CREATE, SPIDE)
|
||||||
|
m.Cmd(mdb.SEARCH, mdb.CREATE, SPACE)
|
||||||
|
|
||||||
m.Search("_render", func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
m.Search("_render", func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) {
|
||||||
for k := range cmd.Action {
|
for k := range cmd.Action {
|
||||||
|
@ -144,7 +144,7 @@ func _action_show(m *ice.Message, river, storm, index string, arg ...string) {
|
|||||||
m.Render("status", 403, "not auth")
|
m.Render("status", 403, "not auth")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Cmdy(_action_proxy(m), cmds).Option("cmds", cmds)
|
m.Cmdy(_action_proxy(m), cmds)
|
||||||
}
|
}
|
||||||
func _action_proxy(m *ice.Message) (proxy []string) {
|
func _action_proxy(m *ice.Message) (proxy []string) {
|
||||||
if m.Option(POD) != "" {
|
if m.Option(POD) != "" {
|
||||||
|
@ -28,6 +28,13 @@ func _river_list(m *ice.Message) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
func _river_node(m *ice.Message, river string, node ...string) {
|
||||||
|
prefix := kit.Keys(kit.MDB_HASH, river, NODE)
|
||||||
|
for _, v := range node {
|
||||||
|
m.Rich(RIVER, prefix, kit.Data(kit.MDB_NAME, v))
|
||||||
|
m.Log_INSERT(RIVER, river, NODE, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
func _river_user(m *ice.Message, river string, user ...string) {
|
func _river_user(m *ice.Message, river string, user ...string) {
|
||||||
prefix := kit.Keys(kit.MDB_HASH, river, USER)
|
prefix := kit.Keys(kit.MDB_HASH, river, USER)
|
||||||
for _, v := range user {
|
for _, v := range user {
|
||||||
@ -77,6 +84,7 @@ func _river_create(m *ice.Message, kind, name, text string, arg ...string) {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
USER = "user"
|
USER = "user"
|
||||||
|
NODE = "node"
|
||||||
TOOL = "tool"
|
TOOL = "tool"
|
||||||
)
|
)
|
||||||
const RIVER = "river"
|
const RIVER = "river"
|
||||||
@ -127,6 +135,9 @@ func init() {
|
|||||||
USER: {Name: "user user...", Help: "添加用户", Hand: func(m *ice.Message, arg ...string) {
|
USER: {Name: "user user...", Help: "添加用户", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_river_user(m, m.Option(ice.MSG_RIVER), arg...)
|
_river_user(m, m.Option(ice.MSG_RIVER), arg...)
|
||||||
}},
|
}},
|
||||||
|
NODE: {Name: "node node...", Help: "添加设备", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
_river_node(m, m.Option(ice.MSG_RIVER), arg...)
|
||||||
|
}},
|
||||||
}, 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 m.Option(ice.MSG_USERNICK) != "" {
|
if m.Option(ice.MSG_USERNICK) != "" {
|
||||||
m.Cmd(aaa.USER, mdb.MODIFY, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK))
|
m.Cmd(aaa.USER, mdb.MODIFY, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK))
|
||||||
|
@ -6,6 +6,7 @@ refer "" `
|
|||||||
文档 https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html
|
文档 https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html
|
||||||
源码 https://github.com/shylinux/icebergs/blob/master/misc/wx/wx.go
|
源码 https://github.com/shylinux/icebergs/blob/master/misc/wx/wx.go
|
||||||
`
|
`
|
||||||
|
image qrcode `https://weixin.qq.com`
|
||||||
|
|
||||||
chapter "应用"
|
chapter "应用"
|
||||||
field "user" user
|
field "user" user
|
||||||
|
Loading…
x
Reference in New Issue
Block a user