forked from x/icebergs
add some
This commit is contained in:
parent
19382e1f28
commit
001cbfd713
@ -258,7 +258,7 @@ func init() {
|
|||||||
cli.STOP: {Hand: func(m *ice.Message, arg ...string) {
|
cli.STOP: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
gdb.Event(m, DREAM_STOP, arg)
|
gdb.Event(m, DREAM_STOP, arg)
|
||||||
m.Cmd(SPACE, mdb.MODIFY, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
m.Cmd(SPACE, mdb.MODIFY, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
||||||
m.Go(func() { m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT) })
|
m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT)
|
||||||
m.Sleep300ms()
|
m.Sleep300ms()
|
||||||
}},
|
}},
|
||||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -72,6 +72,7 @@ func PushPodCmd(m *ice.Message, cmd string, arg ...string) {
|
|||||||
kit.For(list, func(index int, space string) {
|
kit.For(list, func(index int, space string) {
|
||||||
toast(space, index, len(list))
|
toast(space, index, len(list))
|
||||||
m.Cmd(SPACE, space, kit.Dict(ice.MSG_USERPOD, space), kit.Select(m.PrefixKey(), cmd), arg).Table(func(index int, val ice.Maps, head []string) {
|
m.Cmd(SPACE, space, kit.Dict(ice.MSG_USERPOD, space), kit.Select(m.PrefixKey(), cmd), arg).Table(func(index int, val ice.Maps, head []string) {
|
||||||
|
kit.If(!kit.IsIn(SPACE, head...), func() { head = append(head, SPACE) })
|
||||||
val[SPACE] = kit.Keys(space, val[SPACE])
|
val[SPACE] = kit.Keys(space, val[SPACE])
|
||||||
m.Push("", val, head)
|
m.Push("", val, head)
|
||||||
})
|
})
|
||||||
|
@ -89,7 +89,6 @@ func _space_handle(m *ice.Message, safe bool, name string, c *websocket.Conn) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
msg := m.Spawn(b)
|
msg := m.Spawn(b)
|
||||||
// msg.Option(ice.LOG_TRACEID, kit.Split(msg.Option(ice.LOG_TRACEID), "-")[0]+"-"+ice.Info.NodeName)
|
|
||||||
if safe { // 下行权限
|
if safe { // 下行权限
|
||||||
msg.OptionDefault(ice.MSG_USERROLE, aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME)))
|
msg.OptionDefault(ice.MSG_USERROLE, aaa.UserRole(msg, msg.Option(ice.MSG_USERNAME)))
|
||||||
} else { // 上行权限
|
} else { // 上行权限
|
||||||
@ -243,9 +242,9 @@ func init() {
|
|||||||
_space_dial(m, m.Option(ice.DEV), kit.Select(ice.Info.NodeName, m.Option(mdb.NAME)), arg...)
|
_space_dial(m, m.Option(ice.DEV), kit.Select(ice.Info.NodeName, m.Option(mdb.NAME)), arg...)
|
||||||
}},
|
}},
|
||||||
mdb.REMOVE: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.REMOVE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
defer mdb.HashModifyDeferRemove(m, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)()
|
mdb.HashModify(m, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
||||||
m.Cmd("", m.Option(mdb.NAME), ice.EXIT)
|
m.Cmd("", m.Option(mdb.NAME), ice.EXIT)
|
||||||
m.Sleep3s()
|
m.Sleep300ms()
|
||||||
}},
|
}},
|
||||||
DOMAIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_space_domain(m)) }},
|
DOMAIN: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_space_domain(m)) }},
|
||||||
LOGIN: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
LOGIN: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
ice "shylinux.com/x/icebergs"
|
ice "shylinux.com/x/icebergs"
|
||||||
"shylinux.com/x/icebergs/base/aaa"
|
|
||||||
"shylinux.com/x/icebergs/base/ctx"
|
"shylinux.com/x/icebergs/base/ctx"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
@ -22,14 +21,17 @@ const LOCATION = "location"
|
|||||||
func init() {
|
func init() {
|
||||||
get := func(m *ice.Message, api string, arg ...ice.Any) string {
|
get := func(m *ice.Message, api string, arg ...ice.Any) string {
|
||||||
return kit.Format(mdb.Cache(m, kit.Join(kit.Simple(api, arg)), func() ice.Any {
|
return kit.Format(mdb.Cache(m, kit.Join(kit.Simple(api, arg)), func() ice.Any {
|
||||||
res := kit.UnMarshal(m.Cmdx(http.MethodGet, "https://apis.map.qq.com/ws/"+api, mdb.KEY, mdb.Config(m, web.TOKEN), arg))
|
res := kit.UnMarshal(m.Cmdx(web.SPIDE, LOCATION, web.SPIDE_RAW, http.MethodGet, api, mdb.KEY, mdb.Config(m, web.TOKEN), arg))
|
||||||
m.Warn(kit.Format(kit.Value(res, "status")) != "0", kit.Format(res))
|
m.Warn(kit.Format(kit.Value(res, mdb.STATUS)) != "0", kit.Format(res))
|
||||||
m.Debug("what %v %v", api, kit.Format(res))
|
m.Debug("what %v %v", api, kit.Formats(res))
|
||||||
return kit.Format(res)
|
return res
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
LOCATION: {Help: "地图", Icon: "Maps.png", Actions: ice.MergeActions(ice.Actions{
|
LOCATION: {Help: "地图", Icon: "Maps.png", Actions: ice.MergeActions(ice.Actions{
|
||||||
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmd(web.SPIDE, mdb.CREATE, LOCATION, "https://apis.map.qq.com/ws/")
|
||||||
|
}},
|
||||||
"explore": {Help: "周边", Hand: func(m *ice.Message, arg ...string) {
|
"explore": {Help: "周边", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(get(m, "place/v1/explore", m.OptionSimple("keyword,boundary,page_index")))
|
m.Echo(get(m, "place/v1/explore", m.OptionSimple("keyword,boundary,page_index")))
|
||||||
}},
|
}},
|
||||||
@ -46,7 +48,7 @@ func init() {
|
|||||||
kit.If(arg[0] == mdb.TYPE, func() { m.Push(arg[0], LOCATION) })
|
kit.If(arg[0] == mdb.TYPE, func() { m.Push(arg[0], LOCATION) })
|
||||||
}},
|
}},
|
||||||
FAVOR_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
FAVOR_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
kit.If(m.Option(mdb.TYPE) == LOCATION, func() { m.PushButton(LOCATION) })
|
kit.If(m.Option(mdb.TYPE) == LOCATION, func() { m.PushButton(kit.Dict(LOCATION, "地图")) })
|
||||||
}},
|
}},
|
||||||
FAVOR_ACTION: {Hand: func(m *ice.Message, arg ...string) {
|
FAVOR_ACTION: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
kit.If(m.Option(mdb.TYPE) == LOCATION, func() { ctx.ProcessField(m, m.PrefixKey(), []string{m.Option(mdb.TEXT)}, arg...) })
|
kit.If(m.Option(mdb.TYPE) == LOCATION, func() { ctx.ProcessField(m, m.PrefixKey(), []string{m.Option(mdb.TEXT)}, arg...) })
|
||||||
@ -54,7 +56,7 @@ func init() {
|
|||||||
}, FavorAction(), mdb.ExportHashAction(mdb.FIELD, "time,hash,type,name,text,latitude,longitude,extra", nfs.SCRIPT, "https://map.qq.com/api/gljs?v=1.exp")), Hand: func(m *ice.Message, arg ...string) {
|
}, FavorAction(), mdb.ExportHashAction(mdb.FIELD, "time,hash,type,name,text,latitude,longitude,extra", nfs.SCRIPT, "https://map.qq.com/api/gljs?v=1.exp")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
mdb.HashSelect(m, kit.Slice(arg, 0, 1)...)
|
mdb.HashSelect(m, kit.Slice(arg, 0, 1)...)
|
||||||
// m.Option(LOCATION, m.Cmdx(web.SERVE, tcp.HOST))
|
// m.Option(LOCATION, m.Cmdx(web.SERVE, tcp.HOST))
|
||||||
m.Option(LOCATION, get(m, "location/v1/ip", aaa.IP, m.Option(ice.MSG_USERIP)))
|
// m.Option(LOCATION, get(m, "location/v1/ip", aaa.IP, m.Option(ice.MSG_USERIP)))
|
||||||
ctx.DisplayLocal(m.Options(nfs.SCRIPT, kit.MergeURL(mdb.Config(m, nfs.SCRIPT), mdb.KEY, mdb.Config(m, web.TOKEN))), "")
|
ctx.DisplayLocal(m.Options(nfs.SCRIPT, kit.MergeURL(mdb.Config(m, nfs.SCRIPT), mdb.KEY, mdb.Config(m, web.TOKEN))), "")
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
@ -124,6 +124,9 @@ func init() {
|
|||||||
m.Cmdy(nfs.DIR, ice.ETC_MISS_SH).Cmdy(nfs.CAT, ice.ETC_MISS_SH)
|
m.Cmdy(nfs.DIR, ice.ETC_MISS_SH).Cmdy(nfs.CAT, ice.ETC_MISS_SH)
|
||||||
}},
|
}},
|
||||||
nfs.MODULE: {Name: "module name*=hi help type*=Hash,Zone,Data,Lang,Code main*=main.go@key zone key", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
nfs.MODULE: {Name: "module name*=hi help type*=Hash,Zone,Data,Lang,Code main*=main.go@key zone key", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if m.Warn(!nfs.Exists(m, kit.Path(".git")), ice.ErrNotValid, "未初始化代码库") {
|
||||||
|
return
|
||||||
|
}
|
||||||
m.OptionDefault(mdb.ZONE, m.Option(mdb.NAME), mdb.HELP, m.Option(mdb.NAME))
|
m.OptionDefault(mdb.ZONE, m.Option(mdb.NAME), mdb.HELP, m.Option(mdb.NAME))
|
||||||
m.OptionDefault(mdb.KEY, Prefix(m.Option(mdb.ZONE), m.Option(mdb.NAME)))
|
m.OptionDefault(mdb.KEY, Prefix(m.Option(mdb.ZONE), m.Option(mdb.NAME)))
|
||||||
m.Option(nfs.FILE, path.Join(m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)))
|
m.Option(nfs.FILE, path.Join(m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)))
|
||||||
|
2
logs.go
2
logs.go
@ -160,9 +160,11 @@ func (m *Message) IsErr(arg ...string) bool {
|
|||||||
}
|
}
|
||||||
func (m *Message) IsErrNotFound() bool { return m.IsErr(ErrNotFound) }
|
func (m *Message) IsErrNotFound() bool { return m.IsErr(ErrNotFound) }
|
||||||
func (m *Message) Debug(str string, arg ...Any) {
|
func (m *Message) Debug(str string, arg ...Any) {
|
||||||
|
if m.Option(MSG_DEBUG) == TRUE {
|
||||||
kit.Format(str == "", func() { str = m.FormatMeta() })
|
kit.Format(str == "", func() { str = m.FormatMeta() })
|
||||||
m.log(LOG_DEBUG, str, arg...)
|
m.log(LOG_DEBUG, str, arg...)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Message) FormatTaskMeta() task.Meta {
|
func (m *Message) FormatTaskMeta() task.Meta {
|
||||||
return task.Meta{Prefix: m.FormatShip() + " ", FileLine: kit.FileLine(2, 3)}
|
return task.Meta{Prefix: m.FormatShip() + " ", FileLine: kit.FileLine(2, 3)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user