1
0
forked from x/icebergs
icebergs/misc/chrome/spide.go
2023-10-09 13:07:02 +08:00

40 lines
994 B
Go

package chrome
import (
"shylinux.com/x/ice"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/core/wiki"
)
type spide struct {
cache
demo string `name:"demo" event:"serve.start"`
list string `name:"list wid tid url auto insert" help:"节点"`
}
func (s spide) Demo(m *ice.Message, arg ...string) {
m.Debug("what %v", arg)
}
func (s spide) Download(m *ice.Message, arg ...string) {
m.Cmdy(s.cache, s.Create, arg).ProcessHold()
}
func (s spide) List(m *ice.Message, arg ...string) {
if len(arg) < 2 || arg[0] == "" || arg[1] == "" {
s.daemon.List(m, arg...)
return
}
s.send(m, arg[:2], "spide").Table(func(value ice.Maps) {
switch value[mdb.TYPE] {
case wiki.AUDIO:
m.PushAudios(mdb.SHOW, value[mdb.LINK])
case wiki.VIDEO:
m.PushVideos(mdb.SHOW, value[mdb.LINK])
case "img":
m.PushImages(mdb.SHOW, value[mdb.LINK])
default:
m.Push(mdb.SHOW, "")
}
}).Cut("show,type,name,link").PushAction(s.Download)
}
func init() { ice.CodeCtxCmd(spide{}) }