mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt chat
This commit is contained in:
parent
55c606516a
commit
11b8bfd6be
62
core/chat/nodes.go
Normal file
62
core/chat/nodes.go
Normal file
@ -0,0 +1,62 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const NODES = "nodes"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
NODES: {Name: "nodes space index auto insert invite", Help: "设备", Actions: ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
gdb.Watch(m, web.SPACE_START, m.PrefixKey())
|
||||
gdb.Watch(m, web.DREAM_START, m.PrefixKey())
|
||||
}},
|
||||
web.SPACE_START: {Name: "start type name share river", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(ice.MSG_RIVER, m.Option(RIVER)) == "" {
|
||||
return
|
||||
}
|
||||
if msg := m.Cmd(web.SHARE, m.Option(web.SHARE)); msg.Append(mdb.TYPE) == RIVER {
|
||||
m.Cmdy("", mdb.INSERT, arg)
|
||||
}
|
||||
}},
|
||||
web.DREAM_START: {Name: "start type name share river", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(ice.MSG_RIVER, m.Option(RIVER)) == "" {
|
||||
return
|
||||
}
|
||||
m.Cmdy("", mdb.INSERT, arg)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(web.SPACE)
|
||||
}},
|
||||
mdb.INSERT: {Name: "insert type space share river", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(mdb.SHORT, web.SPACE)
|
||||
m.Cmdy(mdb.INSERT, RIVER, _river_key(m, m.CommandKey()), mdb.HASH, arg)
|
||||
}},
|
||||
mdb.DELETE: {Name: "delete", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.DELETE, RIVER, _river_key(m, m.CommandKey()), mdb.HASH, m.OptionSimple(web.SPACE))
|
||||
}},
|
||||
aaa.INVITE: {Name: "invite", Help: "邀请", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, RIVER))
|
||||
m.Cmdy("publish", ice.CONTEXTS, "tool")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.OptionFields("time,type,space,share")
|
||||
m.Cmdy(mdb.SELECT, RIVER, _river_key(m, m.CommandKey()), mdb.HASH)
|
||||
m.Tables(func(value ice.Maps) {
|
||||
m.PushAnchor(value[mdb.NAME], web.MergePod(m, kit.Keys(m.Option(ice.POD), value[mdb.NAME])))
|
||||
})
|
||||
m.PushAction(mdb.REMOVE)
|
||||
return
|
||||
}
|
||||
m.Cmdy(web.ROUTE, arg)
|
||||
}},
|
||||
})
|
||||
}
|
105
core/chat/template.go
Normal file
105
core/chat/template.go
Normal file
@ -0,0 +1,105 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const TEMPLATE = "template"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
TEMPLATE: {Name: "template river storm index auto 删除配置 查看配置", Help: "模板", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if gdb.Watch(m, RIVER_CREATE); m.Cmd("").Length() == 0 {
|
||||
kit.Fetch(_river_template, func(river string, value ice.Any) {
|
||||
m.Cmd("", mdb.CREATE, RIVER, river)
|
||||
kit.Fetch(value, func(storm string, value ice.Any) {
|
||||
m.Cmd("", mdb.INSERT, RIVER, river, mdb.TYPE, "", STORM, storm, mdb.TEXT, "")
|
||||
kit.Fetch(value, func(index int, value ice.Any) {
|
||||
m.Cmd("", "add", RIVER, river, STORM, storm, ctx.INDEX, value)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}},
|
||||
RIVER_CREATE: {Name: "river.create river template", Help: "建群", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Debug("fuck %v", 123)
|
||||
m.Cmd("", m.Option(TEMPLATE)).Tables(func(value ice.Maps) {
|
||||
m.Debug("fuck %v", value)
|
||||
h := m.Cmdx(STORM, mdb.CREATE, mdb.TYPE, "", mdb.NAME, value[STORM], mdb.TEXT, "")
|
||||
m.Cmd("", m.Option(TEMPLATE), value[STORM]).Tables(func(value ice.Maps) {
|
||||
m.Cmd(STORM, mdb.INSERT, mdb.HASH, h, kit.SimpleKV("space,index", value))
|
||||
})
|
||||
})
|
||||
}},
|
||||
mdb.CREATE: {Name: "create river", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(RIVER), kit.Dict(mdb.SHORT, RIVER))
|
||||
}},
|
||||
mdb.INSERT: {Name: "insert river type storm text", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(mdb.INSERT, m.PrefixKey(), kit.KeyHash(m.Option(RIVER)), mdb.HASH, arg[2:], kit.Dict(mdb.SHORT, STORM))
|
||||
}},
|
||||
"add": {Name: "add river storm index", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(mdb.INSERT, m.PrefixKey(), kit.KeyHash(m.Option(RIVER), kit.KeyHash(m.Option(STORM))), mdb.LIST, arg[4:])
|
||||
}},
|
||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(STORM) == "" {
|
||||
m.Cmd(mdb.DELETE, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(RIVER))
|
||||
} else {
|
||||
m.Cmd(mdb.DELETE, m.PrefixKey(), kit.KeyHash(m.Option(RIVER)), mdb.HASH, m.OptionSimple(STORM))
|
||||
}
|
||||
}},
|
||||
}), Hand: func(m *ice.Message, arg ...string) {
|
||||
switch len(arg) {
|
||||
case 0:
|
||||
m.OptionFields("time,river")
|
||||
m.Cmdy(mdb.SELECT, m.PrefixKey(), "", mdb.HASH)
|
||||
m.PushAction(mdb.REMOVE)
|
||||
m.Action(mdb.CREATE)
|
||||
case 1:
|
||||
m.OptionFields("time,type,storm,text")
|
||||
m.Cmdy(mdb.SELECT, m.PrefixKey(), kit.KeyHash(arg[0]), mdb.HASH)
|
||||
m.PushAction(mdb.REMOVE)
|
||||
m.Action(mdb.INSERT)
|
||||
case 2:
|
||||
m.OptionFields("time,index")
|
||||
m.Cmdy(mdb.SELECT, m.PrefixKey(), kit.KeyHash(arg[0], kit.KeyHash(arg[1])), mdb.LIST)
|
||||
m.Action("add")
|
||||
}
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
||||
var _river_template = kit.Dict(
|
||||
"base", kit.Dict(
|
||||
"info", kit.List(
|
||||
"web.chat.info",
|
||||
"web.chat.ocean",
|
||||
"web.chat.storm",
|
||||
"web.chat.node",
|
||||
),
|
||||
"scan", kit.List(
|
||||
"web.chat.scan",
|
||||
"web.chat.paste",
|
||||
"web.chat.files",
|
||||
"web.chat.location",
|
||||
"web.chat.meet.miss",
|
||||
"web.wiki.feel",
|
||||
),
|
||||
"task", kit.List(
|
||||
"web.team.task",
|
||||
"web.team.plan",
|
||||
"web.mall.asset",
|
||||
"web.mall.salary",
|
||||
"web.wiki.word",
|
||||
),
|
||||
"draw", kit.List(
|
||||
"web.wiki.draw",
|
||||
"web.wiki.data",
|
||||
"web.wiki.word",
|
||||
),
|
||||
),
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user