mirror of
https://shylinux.com/x/icebergs
synced 2025-04-27 01:48:27 +08:00
opt chat
This commit is contained in:
parent
530bec2d3a
commit
7c0cc84652
@ -17,6 +17,9 @@ func init() {
|
|||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
SEARCH: {Name: "search type word text auto", Help: "搜索", Action: map[string]*ice.Action{
|
SEARCH: {Name: "search type word text auto", Help: "搜索", Action: map[string]*ice.Action{
|
||||||
CREATE: {Name: "create type cmd ctx", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
CREATE: {Name: "create type cmd ctx", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if kit.Select(arg[0], arg, 1) == "" {
|
||||||
|
m.Debug(m.Format("stack"))
|
||||||
|
}
|
||||||
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)))
|
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) {
|
||||||
@ -27,7 +30,7 @@ func init() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Option(FIELDS, kit.Select("ctx,cmd,time,size,type,name,text", kit.Select(m.Option(FIELDS), arg, 2)))
|
m.Option(ice.MSG_FIELDS, kit.Select("ctx,cmd,time,size,type,name,text", kit.Select(m.Option(ice.MSG_FIELDS), arg, 2)))
|
||||||
for _, k := range strings.Split(arg[0], ",") {
|
for _, k := range strings.Split(arg[0], ",") {
|
||||||
for _, kk := range strings.Split(arg[1], ",") {
|
for _, kk := range strings.Split(arg[1], ",") {
|
||||||
m.Richs(SEARCH, nil, k, func(key string, value map[string]interface{}) {
|
m.Richs(SEARCH, nil, k, func(key string, value map[string]interface{}) {
|
||||||
|
@ -3,7 +3,6 @@ package chat
|
|||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/aaa"
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
)
|
)
|
||||||
@ -14,7 +13,6 @@ var Index = &ice.Context{Name: CHAT, Help: "聊天中心",
|
|||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Cmd(web.SERVE, aaa.WHITE, HEADER, RIVER, ACTION, FOOTER)
|
m.Cmd(web.SERVE, aaa.WHITE, HEADER, RIVER, ACTION, FOOTER)
|
||||||
m.Cmd(mdb.SEARCH, mdb.CREATE, P_SEARCH, m.Prefix(P_SEARCH))
|
|
||||||
m.Watch(web.SPACE_START, m.Prefix(NODE))
|
m.Watch(web.SPACE_START, m.Prefix(NODE))
|
||||||
m.Watch(web.SPACE_STOP, m.Prefix(NODE))
|
m.Watch(web.SPACE_STOP, m.Prefix(NODE))
|
||||||
m.Load()
|
m.Load()
|
||||||
|
@ -4,12 +4,11 @@ chat.go
|
|||||||
chat.shy
|
chat.shy
|
||||||
|
|
||||||
header.go
|
header.go
|
||||||
search.go
|
|
||||||
river.go
|
river.go
|
||||||
action.go
|
action.go
|
||||||
|
|
||||||
|
search.go
|
||||||
footer.go
|
footer.go
|
||||||
|
|
||||||
scan.go
|
scan.go
|
||||||
paste.go
|
paste.go
|
||||||
files.go
|
files.go
|
||||||
|
@ -2,6 +2,7 @@ package chat
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/ctx"
|
"github.com/shylinux/icebergs/base/ctx"
|
||||||
"github.com/shylinux/icebergs/base/mdb"
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
@ -12,14 +13,14 @@ const P_SEARCH = "/search"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
P_SEARCH: {Name: "/search", Help: "搜索", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME)},
|
P_SEARCH: {Name: P_SEARCH, Help: "搜索", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
P_SEARCH: {Name: "/search", Help: "搜索引擎", Action: map[string]*ice.Action{
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Cmd(mdb.SEARCH, mdb.CREATE, P_SEARCH, m.Prefix(P_SEARCH))
|
||||||
|
}},
|
||||||
|
P_SEARCH: {Name: P_SEARCH, Help: "搜索引擎", Action: map[string]*ice.Action{
|
||||||
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if arg[0] != P_SEARCH && arg[0] != kit.MDB_FOREACH {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Richs(P_SEARCH, "", kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
m.Richs(P_SEARCH, "", kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||||
if value = kit.GetMeta(value); arg[1] != "" && !kit.Contains(value[kit.MDB_NAME], arg[1]) {
|
if value = kit.GetMeta(value); arg[1] != "" && !kit.Contains(value[kit.MDB_NAME], arg[1]) {
|
||||||
return
|
return
|
||||||
@ -31,13 +32,12 @@ func init() {
|
|||||||
m.Cmdy(m.Space(m.Option(POD)), mdb.RENDER, arg[1:])
|
m.Cmdy(m.Space(m.Option(POD)), mdb.RENDER, arg[1:])
|
||||||
}},
|
}},
|
||||||
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) > 0 && arg[0] == "run" {
|
m.Cmdy(ctx.COMMAND, arg)
|
||||||
if m.Right(arg[1:]) {
|
}},
|
||||||
|
cli.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if !m.Warn(!m.Right(arg), ice.ErrNotRight) {
|
||||||
m.Cmdy(arg[1:])
|
m.Cmdy(arg[1:])
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Cmdy(ctx.COMMAND, 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 kit.Contains(arg[1], ";") {
|
if kit.Contains(arg[1], ";") {
|
||||||
|
4
misc.go
4
misc.go
@ -97,11 +97,11 @@ func (m *Message) PushSearch(args ...interface{}) {
|
|||||||
case kit.SSH_CTX:
|
case kit.SSH_CTX:
|
||||||
m.Push(k, m.Prefix())
|
m.Push(k, m.Prefix())
|
||||||
case kit.SSH_CMD:
|
case kit.SSH_CMD:
|
||||||
m.Push(k, data[kit.SSH_CMD])
|
m.Push(k, kit.Format(data[kit.SSH_CMD]))
|
||||||
case kit.MDB_TIME:
|
case kit.MDB_TIME:
|
||||||
m.Push(k, kit.Select(m.Time(), data[k]))
|
m.Push(k, kit.Select(m.Time(), data[k]))
|
||||||
default:
|
default:
|
||||||
m.Push(k, kit.Select("", data[k]))
|
m.Push(k, kit.Format(kit.Select("", data[k])))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user