From a12978d0282016f04dd9eb1a2027f8e0bdfe3b7c Mon Sep 17 00:00:00 2001 From: shy Date: Sat, 2 Mar 2024 17:26:08 +0800 Subject: [PATCH] add some --- base/web/serve.go | 5 ++++- base/web/spide.go | 5 ++++- core/chat/action.go | 8 ++++++++ core/chat/rewrite.go | 14 ++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 core/chat/rewrite.go diff --git a/base/web/serve.go b/base/web/serve.go index 8f303151..1d999916 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -225,7 +225,10 @@ func init() { }}, tcp.HOST: {Help: "公网", Hand: func(m *ice.Message, arg ...string) { m.Echo(kit.Formats(PublicIP(m))) }}, cli.SYSTEM: {Help: "系统", Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, "System Settings.app") }}, - cli.START: {Name: "start dev proto host port=9020 nodename username usernick", Hand: func(m *ice.Message, arg ...string) { _serve_start(m) }}, + cli.START: {Name: "start dev proto host port=9020 nodename username usernick", Hand: func(m *ice.Message, arg ...string) { + m.Cmd(nfs.SAVE, "etc/local.sh", m.Spawn(ice.Maps{"pwd": kit.Path(""), "user": kit.UserName(), "args": kit.JoinCmds(arg...)}).Template("local.sh")+lex.NL) + _serve_start(m) + }}, SERVE_START: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(SPIDE, mdb.CREATE, ice.OPS, kit.Format("http://localhost:%s", m.Option(tcp.PORT)), nfs.REPOS, nfs.USR_ICONS_CONTEXTS) Count(m, m.ActionKey(), m.Option(tcp.PORT)) diff --git a/base/web/spide.go b/base/web/spide.go index 1badaccc..da0d4edf 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -359,7 +359,10 @@ func init() { DEV_CREATE_TOKEN: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(SPACE, tcp.DIAL, ice.DEV, m.Option(CLIENT_NAME), m.OptionSimple(TOKEN)).Sleep300ms() }}, - }, DevTokenAction(CLIENT_NAME, CLIENT_URL), mdb.HashAction(mdb.SHORT, CLIENT_NAME, mdb.FIELD, "time,icons,client.name,client.url,client.type,token")), Hand: func(m *ice.Message, arg ...string) { + }, DevTokenAction(CLIENT_NAME, CLIENT_URL), + mdb.HashAction(mdb.SHORT, CLIENT_NAME, mdb.FIELD, "time,icons,client.name,client.url,client.type,token"), + mdb.ImportantHashAction(), + ), Hand: func(m *ice.Message, arg ...string) { if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") { list := m.CmdMap(SPACE, mdb.NAME) mdb.HashSelect(m, kit.Slice(arg, 0, 1)...).Sort("client.type,client.name", []string{nfs.REPOS, ""}) diff --git a/core/chat/action.go b/core/chat/action.go index 87397db9..a2b66908 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -68,6 +68,14 @@ func init() { m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, m.OptionSimple(mdb.ID), arg) }}, web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }}, + ctx.COMMAND: {Hand: func(m *ice.Message, arg ...string) { + if msg := m.Cmd(REWRITE, kit.Hashs(kit.Fields(m.Option(ice.POD), arg[0]))); msg.Length() > 0 { + kit.If(msg.Append("to_space"), func(p string) { m.Option(ice.POD, p) }) + kit.If(msg.Append("to_index"), func(p string) { arg[0] = p }) + defer m.Push(web.SPACE, m.Option(ice.POD)) + } + ctx.Command(m, arg...) + }}, }, web.ApiAction(""), aaa.WhiteAction("", web.SHARE)), Hand: func(m *ice.Message, arg ...string) { if m.WarnNotLogin(m.Option(ice.MSG_USERNAME) == "", arg) { return diff --git a/core/chat/rewrite.go b/core/chat/rewrite.go new file mode 100644 index 00000000..f6ff7a19 --- /dev/null +++ b/core/chat/rewrite.go @@ -0,0 +1,14 @@ +package chat + +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" +) + +const REWRITE = "rewrite" + +func init() { + Index.MergeCommands(ice.Commands{ + REWRITE: {Actions: ice.MergeActions(ice.Actions{}, mdb.HashAction(mdb.SHORT, "space,index", mdb.FIELD, "time,hash,space,index,to_space,to_index"))}, + }) +}