From c7d8d33e2c9120f621004da76b45ce766e0504ce Mon Sep 17 00:00:00 2001 From: shy Date: Mon, 3 Jan 2022 11:32:37 +0800 Subject: [PATCH] opt grant --- core/chat/grant.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 core/chat/grant.go diff --git a/core/chat/grant.go b/core/chat/grant.go new file mode 100644 index 00000000..5e741d7f --- /dev/null +++ b/core/chat/grant.go @@ -0,0 +1,30 @@ +package chat + +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/aaa" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/web" +) + +const GRANT = "grant" + +func init() { + Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ + GRANT: {Name: "grant space id auto insert", Help: "授权", Action: ice.MergeAction(map[string]*ice.Action{ + mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { + switch arg[0] { + case web.SPACE: + m.Cmdy(web.SPACE).RenameAppend(mdb.NAME, web.SPACE).Cut("space,type") + case GRANT: + m.Cmdy(web.SPACE, m.Option(web.SPACE), web.SPACE).RenameAppend(mdb.NAME, GRANT).Cut("grant,type") + case aaa.USERROLE: + m.Push(arg[0], m.Option(ice.MSG_USERROLE)) + case aaa.USERNAME: + m.Push(arg[0], m.Option(ice.MSG_USERNAME)) + } + }}, + mdb.INSERT: {Name: "insert space grant userrole username", Help: "添加"}, + }, mdb.ZoneAction(mdb.SHORT, web.SPACE, mdb.FIELD, "time,grant,userrole,username"))}, + }}) +}