forked from x/icebergs
31 lines
947 B
Go
31 lines
947 B
Go
package bash
|
|
|
|
import (
|
|
ice "shylinux.com/x/icebergs"
|
|
"shylinux.com/x/icebergs/base/mdb"
|
|
"shylinux.com/x/icebergs/base/nfs"
|
|
"shylinux.com/x/icebergs/base/web"
|
|
kit "shylinux.com/x/toolkits"
|
|
)
|
|
|
|
func init() {
|
|
Index.MergeCommands(ice.Commands{
|
|
"/download": {Name: "/download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
|
if len(arg) == 0 || arg[0] == "" {
|
|
m.Cmdy("web.chat.files").Table()
|
|
return // 文件列表
|
|
}
|
|
|
|
// 下载文件
|
|
m.Cmdy(web.CACHE, m.Cmd("web.chat.files", arg[0]).Append(mdb.DATA))
|
|
m.Render(kit.Select(ice.RENDER_DOWNLOAD, ice.RENDER_RESULT, m.Append(nfs.FILE) == ""), m.Append(mdb.TEXT))
|
|
}},
|
|
"/upload": {Name: "/upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
|
msg := m.Cmd("web.chat.files", web.UPLOAD) // 上传文件
|
|
for _, k := range []string{mdb.DATA, mdb.TIME, mdb.TYPE, mdb.NAME, nfs.SIZE} {
|
|
m.Echo("%s: %s\n", k, msg.Append(k))
|
|
}
|
|
}},
|
|
})
|
|
}
|