From 398be22600866aae6bfea267fb817667f9d82f55 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Sat, 12 Nov 2022 22:14:56 +0800 Subject: [PATCH] opt chat --- core/chat/action.go | 14 ++++---------- core/chat/footer.go | 5 ++--- core/chat/header.go | 2 +- core/chat/river.go | 4 +--- core/chat/storm.go | 14 +++++--------- render.go | 3 --- 6 files changed, 13 insertions(+), 29 deletions(-) diff --git a/core/chat/action.go b/core/chat/action.go index 2fbbeb57..0fb82c23 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -54,12 +54,10 @@ func _action_share(m *ice.Message, arg ...string) { break } _action_exec(m, msg.Append(web.RIVER), msg.Append(web.STORM), arg[1], arg[2:]...) - case web.FIELD: if len(arg) == 1 { m.Push(TITLE, msg.Append(TITLE)) m.Push(TOPIC, msg.Append(TOPIC)) - m.Push(ctx.INDEX, msg.Append(mdb.NAME)) m.Push(ctx.ARGS, msg.Append(mdb.TEXT)) m.Cmdy(ctx.COMMAND, msg.Append(mdb.NAME)) break @@ -80,15 +78,11 @@ const ACTION = "action" func init() { Index.MergeCommands(ice.Commands{ web.P(ACTION): {Name: "/action river storm action arg...", Help: "工作台", Actions: ice.MergeActions(ice.Actions{ - ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - m.Cmd(aaa.ROLE, aaa.BLACK, aaa.VOID, m.CommandKey(), ctx.ACTION) - }}, + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.BLACK, aaa.VOID, m.CommandKey(), ctx.ACTION) }}, mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { 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...) - }}, + web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }}, }, ctx.CmdAction(nfs.PATH, ice.USR_LOCAL_RIVER), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) { return @@ -99,9 +93,9 @@ func init() { if len(arg) == 2 { m.OptionFromConfig(MENUS) _action_list(m, arg[0], arg[1]) - return + } else { + _action_exec(m, arg[0], arg[1], arg[2], arg[3:]...) } - _action_exec(m, arg[0], arg[1], arg[2], arg[3:]...) }}, }) } diff --git a/core/chat/footer.go b/core/chat/footer.go index 14d7a3b5..c7bb74bf 100644 --- a/core/chat/footer.go +++ b/core/chat/footer.go @@ -11,7 +11,6 @@ import ( const FOOTER = "footer" func init() { - const EMAIL = "email" Index.MergeCommands(ice.Commands{ web.P(FOOTER): {Name: "/footer", Help: "状态栏", Actions: ice.MergeActions(ice.Actions{ ice.RUN: {Hand: func(m *ice.Message, arg ...string) { @@ -21,8 +20,8 @@ func init() { } } }}, - }, ctx.CmdAction(EMAIL, `shylinuxc@gmail.com`), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { - m.Result(m.Configv(EMAIL)) + }, ctx.CmdAction(TITLE, `shylinuxc@gmail.com`), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { + m.Result(m.Configv(TITLE)) }}, }) } diff --git a/core/chat/header.go b/core/chat/header.go index 9035a09e..deaa1915 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -30,7 +30,7 @@ func _header_share(m *ice.Message, arg ...string) { func _header_check(m *ice.Message, arg ...string) bool { if m.Option(web.SHARE) != "" { m.Cmd(web.SHARE, m.Option(web.SHARE), ice.OptionFields(""), func(value ice.Maps) { - if m.Warn(value[mdb.TIME] < m.Time(), ice.ErrNotValid, m.Option(web.SHARE)) { + if m.Warn(value[mdb.TIME] < m.Time(), ice.ErrNotValid, m.Option(web.SHARE), value[mdb.TIME], m.Time()) { return } switch value[mdb.TYPE] { diff --git a/core/chat/river.go b/core/chat/river.go index 55a1a1bb..438cd742 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -40,9 +40,7 @@ const RIVER = "river" func init() { Index.MergeCommands(ice.Commands{ web.P(RIVER): {Name: "/river hash auto create", Help: "群组", Actions: ice.MergeActions(ice.Actions{ - ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - m.Cmd(aaa.ROLE, aaa.BLACK, aaa.VOID, m.CommandKey(), ctx.ACTION) - }}, + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.BLACK, aaa.VOID, m.CommandKey(), ctx.ACTION) }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case nfs.TEMPLATE: diff --git a/core/chat/storm.go b/core/chat/storm.go index 148b4ee4..87030d4f 100644 --- a/core/chat/storm.go +++ b/core/chat/storm.go @@ -35,15 +35,11 @@ func init() { } }}, }, Hand: func(m *ice.Message, arg ...string) { - if m.Option(ice.MSG_STORM) == "" { // 应用列表 - m.OptionFields("time,hash,name,text,count") - m.Cmdy(mdb.SELECT, RIVER, _river_key(m), mdb.HASH) - - } else if len(arg) == 0 || kit.Int(arg[0]) > 0 { // 工具列表 - m.OptionFields("time,id,space,index,args,style,display") - m.Cmdy(mdb.SELECT, RIVER, _storm_key(m), mdb.LIST, mdb.ID, arg) - - } else if aaa.Right(m, arg[0]) { // 静态群组 + if m.Option(ice.MSG_STORM) == "" { + m.Cmdy(mdb.SELECT, RIVER, _river_key(m), mdb.HASH, ice.OptionFields("time,hash,name,text,count")) + } else if len(arg) == 0 || kit.Int(arg[0]) > 0 { + m.Cmdy(mdb.SELECT, RIVER, _storm_key(m), mdb.LIST, mdb.ID, arg, ice.OptionFields("time,id,space,index,args,style,display")) + } else if aaa.Right(m, arg[0]) { m.Push(ctx.INDEX, arg[0]) } }}, diff --git a/render.go b/render.go index 0c172fd8..0bde13e1 100644 --- a/render.go +++ b/render.go @@ -29,7 +29,6 @@ func Render(m *Message, cmd string, args ...Any) string { return strings.Join(list, "") case RENDER_IMAGES: // src [height] - m.Debug("what %v", m.Option(MSG_USERUA)) if strings.Contains(m.Option(MSG_USERUA), "Mobile") { return kit.Format(``, arg[0], kit.Int(kit.Select(kit.Select("120", m.Option("width")), arg, 1))-24) } @@ -84,8 +83,6 @@ func (m *Message) RenderRedirect(args ...Any) *Message { return m.Render(RENDER_REDIRECT, args...) } func (m *Message) RenderDownload(args ...Any) *Message { - - m.Debug("what %v", kit.Format(args)) return m.Render(RENDER_DOWNLOAD, args...) } func (m *Message) RenderResult(args ...Any) *Message { // [fmt arg...]