diff --git a/base/aaa/aaa.go b/base/aaa/aaa.go index ed78db77..537e9a55 100644 --- a/base/aaa/aaa.go +++ b/base/aaa/aaa.go @@ -5,6 +5,9 @@ import ( "github.com/shylinux/toolkits" ) +const ( + ErrNotAuth = "not auth: " +) const ( USERNICK = "usernick" USERNAME = "username" diff --git a/base/aaa/role.go b/base/aaa/role.go index c7737bbc..f6db5b6d 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -72,7 +72,7 @@ func _role_right(m *ice.Message, userrole string, keys ...string) (ok bool) { ok = true } } - if m.Warn(!ok, "%s no right %s", userrole, keys) { + if m.Warn(!ok, ErrNotAuth, userrole, " of ", keys) { return } // 普通用户 diff --git a/core/chat/action.go b/core/chat/action.go index 0ca8874f..a94a35b2 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -124,9 +124,11 @@ func _action_show(m *ice.Message, river, storm, index string, arg ...string) { cmds = kit.Simple(kit.Keys(value[CTX], value[CMD]), arg) } }) - } else if !m.Warn(!m.Right(index), "no right of %v", index) { + } else if m.Right(index) { // 定制命令 cmds = kit.Simple(index, arg) + } else { + return } if len(cmds) == 0 { m.Render("status", 404, "not found") diff --git a/core/code/inner.go b/core/code/inner.go index 93b1ba1e..c33fd0ba 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -37,6 +37,9 @@ func _inner_show(m *ice.Message, ext, file, dir string, arg ...string) { } } func _inner_list(m *ice.Message, ext, file, dir string, arg ...string) { + if !m.Right(strings.Split(dir, "/"), file) { + return + } if m.Cmdy(mdb.RENDER, ext, file, dir, arg); m.Result() == "" { if m.Conf(INNER, kit.Keys("meta.source", ext)) == "true" { if m.Cmdy(mdb.RENDER, nfs.FILE, file, dir, arg); m.Result() == "" { diff --git a/core/wiki/word.go b/core/wiki/word.go index a15e2a8c..fa1b6bfd 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -353,7 +353,9 @@ func init() { }}, FIELD: {Name: "field name cmd", Help: "插件", Action: map[string]*ice.Action{ "run": {Name: "run", Help: "运行", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(arg[1:]) + if m.Right(arg[1:]) { + m.Cmdy(arg[1:]) + } }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { _field_show(m, arg[0], arg[1], arg[2:]...) diff --git a/logs.go b/logs.go index 25f2873e..c4763a90 100644 --- a/logs.go +++ b/logs.go @@ -9,7 +9,8 @@ import ( ) var ErrWarn = "warn: " -var ErrNotFound = "not found " +var ErrNotAuth = "not auth: " +var ErrNotFound = "not found: " func (m *Message) log(level string, str string, arg ...interface{}) *Message { if str = strings.TrimSpace(kit.Format(str, arg...)); Log != nil { diff --git a/misc.go b/misc.go index 04d45a1c..44fe8f31 100644 --- a/misc.go +++ b/misc.go @@ -4,6 +4,7 @@ import ( kit "github.com/shylinux/toolkits" "fmt" + "strings" "sync/atomic" ) @@ -39,7 +40,7 @@ func (m *Message) Event(key string, arg ...string) *Message { return m } func (m *Message) Right(arg ...interface{}) bool { - return m.Option(MSG_USERROLE) == "root" || !m.Warn(m.Cmdx("aaa.role", "right", m.Option(MSG_USERROLE), kit.Keys(arg...)) != "ok", "no right") + return m.Option(MSG_USERROLE) == "root" || !m.Warn(m.Cmdx("aaa.role", "right", m.Option(MSG_USERROLE), kit.Keys(arg...)) != "ok", ErrNotAuth, strings.Join(kit.Simple(arg), ".")) } func (m *Message) Space(arg interface{}) []string { if arg == nil || arg == "" || kit.Format(arg) == m.Conf("cli.runtime", "node.name") { diff --git a/misc/lark/lark.go b/misc/lark/lark.go index 865d3db0..3056bf86 100644 --- a/misc/lark/lark.go +++ b/misc/lark/lark.go @@ -151,7 +151,7 @@ var Index = &ice.Context{Name: "lark", Help: "机器人", kit.Fetch(kit.Value(data, "data.user_list"), func(index int, value map[string]interface{}) { msg := m.Cmd(m.Prefix(USER), value[OPEN_ID]) m.Push("avatar", m.Cmdx(mdb.RENDER, web.RENDER.IMG, msg.Append("avatar_72"))) - m.Push("gender", kit.Select("男", "女", msg.Append("gender") == "1")) + m.Push("gender", kit.Select("男", "女", msg.Append("gender") == "2")) m.Push(kit.MDB_NAME, msg.Append(kit.MDB_NAME)) m.Push("description", msg.Append("description")) m.Push(OPEN_ID, msg.Append(OPEN_ID)) @@ -436,7 +436,8 @@ var Index = &ice.Context{Name: "lark", Help: "机器人", // }}, web.LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, "/msg": {Name: "/msg", Help: "聊天消息", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { - if data := m.Optionv(ice.MSG_USERDATA); kit.Value(data, "action") != nil { + data := m.Optionv(ice.MSG_USERDATA) + if kit.Value(data, "action") != nil { kit.Fetch(kit.Value(data, "action.value"), func(key string, value string) { m.Option(key, value) }) @@ -485,9 +486,13 @@ var Index = &ice.Context{Name: "lark", Help: "机器人", if m.Cmdy(TALK, strings.TrimSpace(m.Option("text_without_at_bot"))); len(m.Resultv()) > 0 { m.Cmd(SEND, m.Option(OPEN_CHAT_ID), m.Result()) } + } else { + m.Cmd(DUTY, m.Option("msg.type"), kit.Formats(data)) } } } + default: + m.Cmd(DUTY, m.Option("msg.type"), kit.Formats(data)) } }}, "/sso": {Name: "/sso", Help: "网页", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { diff --git a/misc/lark/lark.shy b/misc/lark/lark.shy index f9386eff..a96af071 100644 --- a/misc/lark/lark.shy +++ b/misc/lark/lark.shy @@ -11,9 +11,9 @@ refer "官网" ` field "ship" web.chat.lark.ship field "group" web.chat.lark.group -field "date" web.chat.lark.date -field "meta" web.chat.lark.meta - +# field "date" web.chat.lark.date +# field "meta" web.chat.lark.meta +# section "icebergs" field "icebergs_统计" web.code.git.trend args `[ icebergs ]` action `{ height 200 speed 20 }` field "icebergs_源码" web.code.inner args `[ usr/icebergs misc/lark/lark.go 74 ]`