From 0b863d1eebc4ba7b1de092eb5f87bbfec4ced361 Mon Sep 17 00:00:00 2001 From: shaoying Date: Wed, 3 Feb 2021 20:32:57 +0800 Subject: [PATCH] opt chat --- core/chat/action.go | 22 +++++++++++----------- core/chat/footer.go | 5 +++-- core/chat/header.go | 3 ++- core/chat/search.go | 7 +++---- misc/wx/wx.shy | 8 ++++---- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/core/chat/action.go b/core/chat/action.go index a5c2c0cd..c39e37fb 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -10,13 +10,6 @@ import ( "path" ) -const ( - DOMAIN = "domain" - PUBLIC = "public" - PROTECTED = "protected" - PRIVATE = "private" -) - func _action_domain(m *ice.Message, cmd string, arg ...string) (domain string) { m.Option(ice.MSG_LOCAL, "") m.Option(ice.MSG_DOMAIN, "") @@ -94,6 +87,14 @@ func _action_upload(m *ice.Message, arg ...string) { m.Option(ice.MSG_UPLOAD, msg.Append(kit.MDB_HASH), msg.Append(kit.MDB_NAME)) } +const ( + DOMAIN = "domain" + PUBLIC = "public" + PROTECTED = "protected" + PRIVATE = "private" +) + +const P_ACTION = "/action" const ACTION = "action" func init() { @@ -102,7 +103,7 @@ func init() { ACTION: {Name: ACTION, Help: "应用", Value: kit.Data(DOMAIN, kit.Dict())}, }, Commands: map[string]*ice.Command{ - "/action": {Name: "/action river storm action arg...", Help: "工作台", Action: map[string]*ice.Action{ + P_ACTION: {Name: "/action river storm action arg...", Help: "工作台", Action: map[string]*ice.Action{ ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) { for _, k := range arg { m.Cmdy(ctx.COMMAND, k) @@ -112,10 +113,9 @@ func init() { if arg[0] == "_share" { switch msg := m.Cmd(web.SHARE, arg[1]); msg.Append(kit.MDB_TYPE) { case STORM: - m.Debug(msg.Format(kit.MDB_META)) + m.Option(kit.MDB_TITLE, msg.Append(kit.MDB_NAME)) arg[0] = msg.Append(RIVER) arg[1] = msg.Append(STORM) - m.Option(kit.MDB_TITLE, msg.Append(kit.MDB_NAME)) default: return } @@ -130,11 +130,11 @@ func init() { m.Option(ice.MSG_RIVER, arg[0]) m.Option(ice.MSG_STORM, arg[1]) + if len(arg) == 2 { _action_list(m, arg[0], arg[1]) return //命令列表 } - _action_show(m, arg[0], arg[1], arg[2], arg[3:]...) }}, }}) diff --git a/core/chat/footer.go b/core/chat/footer.go index c091f8f7..bb1d8137 100644 --- a/core/chat/footer.go +++ b/core/chat/footer.go @@ -8,17 +8,18 @@ import ( const ( LEGAL = "legal" ) +const P_FOOTER = "/footer" const FOOTER = "footer" func init() { Index.Merge(&ice.Context{ Configs: map[string]*ice.Config{ - FOOTER: {Name: "footer", Help: "状态栏", Value: kit.Dict( + FOOTER: {Name: FOOTER, Help: "状态栏", Value: kit.Dict( LEGAL, []interface{}{`shylinuxc@gmail.com`}, )}, }, Commands: map[string]*ice.Command{ - "/footer": {Name: "/footer", Help: "状态栏", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + P_FOOTER: {Name: "/footer", Help: "状态栏", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { kit.Fetch(m.Confv(FOOTER, LEGAL), func(index int, value string) { m.Echo(value) }) }}, }, diff --git a/core/chat/header.go b/core/chat/header.go index baf8ef9c..9fc03960 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -16,6 +16,7 @@ const ( BACKGROUND = "background" ) +const P_HEADER = "/header" const HEADER = "header" func init() { @@ -24,7 +25,7 @@ func init() { HEADER: {Name: HEADER, Help: "标题栏", Value: kit.Dict(TITLE, "github.com/shylinux/contexts")}, }, Commands: map[string]*ice.Command{ - "/header": {Name: "/header", Help: "标题栏", Action: map[string]*ice.Action{ + P_HEADER: {Name: "/header", Help: "标题栏", Action: map[string]*ice.Action{ LOGIN: {Name: "login", Help: "用户登录", Hand: func(m *ice.Message, arg ...string) { if aaa.UserLogin(m, arg[0], arg[1]) { m.Option(ice.MSG_SESSID, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME), m.Option(ice.MSG_USERROLE))) diff --git a/core/chat/search.go b/core/chat/search.go index 61304692..66829b73 100644 --- a/core/chat/search.go +++ b/core/chat/search.go @@ -27,6 +27,9 @@ func init() { m.PushSearch(kit.SSH_CMD, P_SEARCH, value) }) }}, + mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { + m.Cmdy(m.Space(m.Option(POD)), mdb.RENDER, arg[1:]) + }}, ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == "run" { m.Cmdy(arg[1:]) @@ -34,14 +37,10 @@ func init() { } m.Cmdy(ctx.COMMAND, arg) }}, - mdb.RENDER: {Name: "render", Help: "渲染", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(m.Space(m.Option(POD)), mdb.RENDER, arg[1:]) - }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if kit.Contains(arg[1], ";") { arg = kit.Split(arg[1], ";", ";", ";") } - if m.Cmdy(m.Space(m.Option(POD)), mdb.SEARCH, arg); arg[1] == "" { return } diff --git a/misc/wx/wx.shy b/misc/wx/wx.shy index 738befd7..45c94ba3 100644 --- a/misc/wx/wx.shy +++ b/misc/wx/wx.shy @@ -1,5 +1,5 @@ title "微信公众号" -refer "" ` +refer ` 官网 https://weixin.qq.com/ 后台 https://mp.weixin.qq.com/ 文档 https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html @@ -9,10 +9,10 @@ image qrcode `https://weixin.qq.com` spark chapter "应用" -field location web.chat.location -field paste web.chat.paste field scan web.chat.scan -field feel web.chat.feel +field paste web.chat.paste +field files web.chat.files +field location web.chat.location chapter "权限" field access web.chat.wx.access