forked from x/icebergs
add some
This commit is contained in:
parent
7d138f1030
commit
a77ddbe902
@ -47,6 +47,9 @@ func init() {
|
||||
auth := smtp.PlainAuth("", msg.Append(USERNAME), msg.Append(PASSWORD), kit.Split(msg.Append(SERVICE), ice.DF)[0])
|
||||
m.Logs(EMAIL, SEND, string(content)).Warn(smtp.SendMail(msg.Append(SERVICE), auth, msg.Append(USERNAME), kit.Split(m.Option(TO)), content))
|
||||
}},
|
||||
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,service,username", ice.ACTION, SEND))},
|
||||
LOGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo("input email: ")
|
||||
}},
|
||||
}, RoleAction(LOGIN), mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,service,username", ice.ACTION, SEND))},
|
||||
})
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ func init() {
|
||||
DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.Switch(m.Option(mdb.TYPE), []string{WORKER, SERVER}, func() { m.PushButton(OPEN, ice.MAIN) })
|
||||
}},
|
||||
}, DreamAction(), mdb.ImportantHashAction(ctx.TOOLS, "web.space,web.route,web.code.git.search", mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, aaa.RoleAction(), DreamAction(), mdb.ImportantHashAction(ctx.TOOLS, "web.space,web.route,web.code.git.search", mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if ice.Info.NodeType == WORKER {
|
||||
return
|
||||
}
|
||||
|
@ -93,19 +93,20 @@ func init() {
|
||||
m.Options(ice.MSG_USERWEB, kit.MergeURL(m.Option(ice.MSG_USERWEB), web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN)))
|
||||
m.Cmdy(aaa.EMAIL, aaa.SEND, arg, aaa.CONTENT, nfs.Template(m, "email.html"))
|
||||
}},
|
||||
mdb.CREATE: {Name: "create name icon url", Hand: func(m *ice.Message, arg ...string) { mdb.HashCreate(m, m.OptionSimple()) }},
|
||||
mdb.CREATE: {Name: "create type*=oauth,plugin name* icons link order space index args", Hand: func(m *ice.Message, arg ...string) { mdb.HashCreate(m, m.OptionSimple()) }},
|
||||
mdb.REMOVE: {Hand: func(m *ice.Message, arg ...string) { mdb.HashRemove(m, m.OptionSimple(mdb.NAME)) }},
|
||||
}, web.ApiAction(), ctx.ConfAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,url")), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, web.ApiAction(), ctx.ConfAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icons,type,link,order,space,index,args")), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option("language.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.LANGUAGE)+nfs.PS, nfs.FILE).Appendv(nfs.FILE))
|
||||
m.Option("theme.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.THEME)+nfs.PS, nfs.FILE).Appendv(nfs.FILE))
|
||||
m.Option(nfs.REPOS, m.Cmdv(web.SPIDE, nfs.REPOS, web.CLIENT_URL))
|
||||
m.Option("icons", mdb.Conf(m, ICON, kit.Keym(nfs.PATH)))
|
||||
m.Option("icon.lib", mdb.Conf(m, ICON, kit.Keym(nfs.PATH)))
|
||||
m.Option(MENUS, mdb.Config(m, MENUS))
|
||||
m.Echo(mdb.Config(m, TITLE))
|
||||
if mdb.HashSelect(m); m.Length() == 0 {
|
||||
if mdb.HashSelect(m, arg...); m.Length() == 0 {
|
||||
kit.If(GetSSO(m), func(p string) {
|
||||
m.Push(mdb.TIME, m.Time()).Push(mdb.NAME, web.SERVE).Push(mdb.ICON, nfs.USR_ICONS_ICEBERGS).Push(web.URL, p)
|
||||
m.Push(mdb.TIME, m.Time()).Push(mdb.NAME, web.SERVE).Push(mdb.ICONS, nfs.USR_ICONS_ICEBERGS).Push(mdb.TYPE, "oauth").Push(web.LINK, p)
|
||||
})
|
||||
m.Sort("order", "int")
|
||||
}
|
||||
if gdb.Event(m, HEADER_AGENT); !_header_check(m, arg...) {
|
||||
return
|
||||
|
@ -42,7 +42,7 @@ type Client struct {
|
||||
ice.Hash
|
||||
short string `data:"domain,client_id"`
|
||||
field string `data:"time,hash,domain,client_id,client_secret,oauth_url,grant_url,token_url,users_url,scope,user_key,nick_key,api_prefix,token_prefix"`
|
||||
sso string `name:"sso name* icon*@icon" help:"登录"`
|
||||
sso string `name:"sso name* icons*" help:"登录"`
|
||||
auth string `name:"auth" help:"授权"`
|
||||
user string `name:"user" help:"用户"`
|
||||
orgs string `name:"orgs" help:"组织"`
|
||||
@ -86,7 +86,7 @@ func (s Client) Inputs(m *ice.Message, arg ...string) {
|
||||
}
|
||||
}
|
||||
func (s Client) Sso(m *ice.Message, arg ...string) {
|
||||
m.Cmd(web.CHAT_HEADER, mdb.CREATE, m.Option(mdb.NAME), m.Option(mdb.ICON), s.OAuthURL(m))
|
||||
m.Cmd(web.CHAT_HEADER, mdb.CREATE, "oauth", m.Option(mdb.NAME), m.Option(mdb.ICONS), s.OAuthURL(m))
|
||||
}
|
||||
func (s Client) Auth(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(s.OAuthURL(m))
|
||||
|
@ -9,44 +9,44 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const (
|
||||
BAIDU = "baidu"
|
||||
AUTH_URL = "http://openapi.baidu.com"
|
||||
API_URL = "https://pan.baidu.com/rest/2.0/xpan/"
|
||||
USER_INFO = "nas?method=uinfo"
|
||||
FILE_LIST = "file?method=list"
|
||||
FILE_META = "multimedia?method=filemetas"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
oauth.Client
|
||||
list string `name:"list hash path orgs:text repo:text auto" help:"仓库" icon:"gitea.png"`
|
||||
list string `name:"list hash path orgs:text repo:text auto" help:"仓库" icon:"netdisk.png"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
oauth.Inputs["baidu"] = map[string]string{
|
||||
oauth.OAUTH_URL: "/oauth/2.0/authorize",
|
||||
oauth.GRANT_URL: "/oauth/2.0/token",
|
||||
oauth.TOKEN_URL: "/oauth/2.0/token",
|
||||
oauth.USERS_URL: "https://pan.baidu.com/rest/2.0/xpan/nas?method=uinfo",
|
||||
oauth.NICK_KEY: "baidu_name",
|
||||
oauth.USER_KEY: "uk",
|
||||
oauth.SCOPE: "basic,netdisk",
|
||||
oauth.API_PREFIX: "/api/v1/",
|
||||
oauth.TOKEN_PREFIX: "",
|
||||
oauth.Inputs[BAIDU] = map[string]string{
|
||||
oauth.OAUTH_URL: "/oauth/2.0/authorize",
|
||||
oauth.GRANT_URL: "/oauth/2.0/token",
|
||||
oauth.TOKEN_URL: "/oauth/2.0/token",
|
||||
oauth.USERS_URL: API_URL + USER_INFO,
|
||||
oauth.NICK_KEY: "baidu_name",
|
||||
oauth.USER_KEY: "uk",
|
||||
oauth.SCOPE: "basic,netdisk",
|
||||
}
|
||||
}
|
||||
func (s Client) Init(m *ice.Message, arg ...string) {
|
||||
m.Cmd(web.SPIDE, mdb.CREATE, BAIDU, AUTH_URL)
|
||||
s.Hash.Init(m, arg...)
|
||||
}
|
||||
func (s Client) Login(m *ice.Message, arg ...string) {
|
||||
s.Client.Login2(m, arg...)
|
||||
}
|
||||
func (s Client) Show(m *ice.Message, arg ...string) {
|
||||
res := s.Client.Get(m, m.Option(mdb.HASH), "https://pan.baidu.com/rest/2.0/xpan/multimedia?method=filemetas", "dlink", "1", "fsids", kit.Format("%v", []string{m.Option(mdb.ID)}))
|
||||
// 1 视频、2 音频、3 图片、4 文档、5 应用、6 其他、7 种子
|
||||
p := "usr/local/disk/" + m.Option(mdb.ID)
|
||||
s.Save(m, m.Option(mdb.HASH), p, kit.Format(kit.Value(res, "list.0.dlink")))
|
||||
web.ToastSuccess(m.Message)
|
||||
switch kit.Format(kit.Value(res, "list.0.category")) {
|
||||
case "4":
|
||||
m.Cmdy(nfs.CAT, p)
|
||||
}
|
||||
}
|
||||
func (s Client) List(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
s.Client.List(m, arg...)
|
||||
return
|
||||
}
|
||||
res := s.Client.Get(m, arg[0], "https://pan.baidu.com/rest/2.0/xpan/file?method=list", "dir", kit.Select("", arg, 1))
|
||||
res := s.Client.Get(m, arg[0], API_URL+FILE_LIST, nfs.DIR, kit.Select("", arg, 1))
|
||||
kit.For(kit.Value(res, mdb.LIST), func(value ice.Map) {
|
||||
m.Push(mdb.TIME, kit.TimeUnix(value["server_mtime"]))
|
||||
m.Push(nfs.PATH, kit.Format(value[nfs.PATH])+kit.Select("", nfs.PS, kit.Format(value["isdir"]) == "1"))
|
||||
@ -54,7 +54,15 @@ func (s Client) List(m *ice.Message, arg ...string) {
|
||||
m.Push(mdb.ID, value["fs_id"])
|
||||
})
|
||||
m.PushAction("show")
|
||||
m.Echo(kit.Formats(res))
|
||||
}
|
||||
|
||||
func (s Client) Show(m *ice.Message, arg ...string) {
|
||||
res := s.Client.Get(m, m.Option(mdb.HASH), API_URL+FILE_META, "dlink", "1", "fsids", kit.Format("%v", []string{m.Option(mdb.ID)}))
|
||||
p := "usr/local/disk/" + m.Option(mdb.ID)
|
||||
s.Save(m, m.Option(mdb.HASH), p, kit.Format(kit.Value(res, "list.0.dlink")))
|
||||
defer web.ToastSuccess(m.Message)
|
||||
switch kit.Format(kit.Value(res, "list.0.category")) { // 1 视频、2 音频、3 图片、4 文档、5 应用、6 其他、7 种子
|
||||
case "4":
|
||||
m.Cmdy(nfs.CAT, p)
|
||||
}
|
||||
}
|
||||
func init() { ice.WikiCtxCmd(Client{}) }
|
||||
|
@ -82,8 +82,16 @@ func init() {
|
||||
}
|
||||
m.Echo(msg.Append(TICKET)).Status(msg.AppendSimple(EXPIRE))
|
||||
}},
|
||||
}, mdb.ImportantHashAction(mdb.SHORT, ACCESS, mdb.FIELD, "time,access,icons,usernick,appid", tcp.SERVER, CGI_BIN)), Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashSelect(m, arg...).StatusTimeCount(mdb.ConfigSimple(m, ACCESS, APPID), web.SERVE, web.MergeLink(m, "/chat/wx/login/"))
|
||||
web.SSO: {Name: "sso name*=微信授权", Help: "登录", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(web.CHAT_HEADER, mdb.CREATE, mdb.TYPE, mdb.PLUGIN, m.OptionSimple(mdb.NAME),
|
||||
ctx.INDEX, m.PrefixKey(), ctx.ARGS, kit.Join(kit.Simple(aaa.LOGIN, m.Option(ACCESS))))
|
||||
}},
|
||||
aaa.LOGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Options(ACCESS, arg[0]).Cmdy(SCAN, mdb.CREATE, mdb.TYPE, "QR_STR_SCENE",
|
||||
mdb.NAME, "授权登录", mdb.TEXT, m.Option(web.SPACE), ctx.INDEX, "web.chat.grant", ctx.ARGS, m.Option(web.SPACE))
|
||||
}},
|
||||
}, aaa.RoleAction(aaa.LOGIN), mdb.ImportantHashAction(mdb.SHORT, ACCESS, mdb.FIELD, "time,access,icons,usernick,appid", tcp.SERVER, CGI_BIN)), Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashSelect(m, arg...).PushAction(web.SSO, mdb.REMOVE).StatusTimeCount(mdb.ConfigSimple(m, ACCESS, APPID), web.SERVE, web.MergeLink(m, "/chat/wx/login/"))
|
||||
m.RewriteAppend(func(value, key string, index int) string {
|
||||
kit.If(key == cli.QRCODE, func() { value = ice.Render(m, ice.RENDER_QRCODE, value) })
|
||||
return value
|
||||
|
@ -35,7 +35,7 @@ const AGENT = "agent"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
AGENT: {Name: "agent auto", Actions: ice.MergeActions(ice.Actions{
|
||||
AGENT: {Name: "agent auto", Help: "代理", Actions: ice.MergeActions(ice.Actions{
|
||||
chat.HEADER_AGENT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(strings.Index(m.Option(ice.MSG_USERUA), "MicroMessenger") > -1, func() { m.Option(mdb.PLUGIN, m.PrefixKey()) })
|
||||
}},
|
||||
|
@ -17,17 +17,20 @@ const SCAN = "scan"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
SCAN: {Name: "scan access hash auto", Help: "桌牌", Meta: kit.Merge(Meta(), kit.Dict(ice.CTX_TRANS, kit.Dict(html.VALUE, kit.Dict(
|
||||
"QR_STR_SCENE", "临时码", "QR_LIMIT_STR_SCENE", "永久码",
|
||||
"QR_LIMIT_STR_SCENE", "永久码", "QR_STR_SCENE", "临时码", "valid", "有效", "expired", "失效",
|
||||
)))), Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.CREATE: {Name: "create type=QR_STR_SCENE,QR_LIMIT_STR_SCENE name*=1 text icons expire_seconds=3600 space index* args", Hand: func(m *ice.Message, arg ...string) {
|
||||
h := mdb.HashCreate(m.Spawn(), arg)
|
||||
res := SpidePost(m, QRCODE_CREATE, "action_name", m.Option(mdb.TYPE), "action_info.scene.scene_str", h, m.OptionSimple(EXPIRE_SECONDS))
|
||||
mdb.HashModify(m, mdb.HASH, h, mdb.LINK, kit.Value(res, web.URL), mdb.TIME, m.Time(kit.Format("%ss", kit.Select("60", m.Option(EXPIRE_SECONDS)))))
|
||||
m.EchoQRCode(kit.Format(kit.Value(res, web.URL)))
|
||||
}},
|
||||
}, mdb.ExportHashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,name,text,icons,space,index,args,type,link")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
m.Cmdy(ACCESS).PushAction("").Option(ice.MSG_ACTION, "")
|
||||
} else if mdb.HashSelect(m, arg[1:]...); len(arg) > 1 {
|
||||
} else if mdb.HashSelect(m, arg[1:]...); len(arg) == 1 {
|
||||
m.Table(func(value ice.Maps) { m.Push(mdb.STATUS, kit.Select("valid", "expired", value[mdb.TIME] < m.Time())) })
|
||||
} else {
|
||||
kit.If(m.Time() < m.Append(mdb.TIME), func() { m.PushQRCode(cli.QRCODE, m.Append(mdb.LINK)) })
|
||||
}
|
||||
}},
|
||||
|
@ -15,18 +15,4 @@ field web.chat.wx.users
|
||||
|
||||
chapter "数据"
|
||||
field web.chat.favor
|
||||
field web.chat.location
|
||||
return
|
||||
order `
|
||||
wx.go
|
||||
wx.shy
|
||||
access.go
|
||||
menu.go
|
||||
scan.go
|
||||
text.go
|
||||
login.go
|
||||
events.go
|
||||
users.go
|
||||
agent.go
|
||||
agent.js
|
||||
`
|
||||
field web.chat.location
|
Loading…
x
Reference in New Issue
Block a user