forked from x/icebergs
opt oauth
This commit is contained in:
parent
0a1a28f13e
commit
c81980bd72
@ -139,9 +139,15 @@ func _config_load(m *ice.Message, name string, arg ...string) {
|
||||
data, msg := ice.Map{}, m.Spawn(m.Source())
|
||||
json.NewDecoder(f).Decode(&data)
|
||||
for k, v := range data {
|
||||
if k == "web.chat.header" {
|
||||
m.Debug("what %v", v)
|
||||
}
|
||||
msg.Search(k, func(p *ice.Context, s *ice.Context, key string, conf *ice.Config) {
|
||||
kit.If(s.Configs[key] == nil, func() { s.Configs[key] = &ice.Config{} })
|
||||
s.Configs[key].Value = v
|
||||
if key == "header" {
|
||||
m.Debug("what %v", v)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -210,12 +216,12 @@ func init() {
|
||||
}
|
||||
func Save(m *ice.Message, arg ...string) *ice.Message {
|
||||
kit.If(len(arg) == 0, func() { arg = kit.SortedKey(m.Target().Configs) })
|
||||
kit.For(arg, func(i int, k string) { arg[i] = m.Prefix(k) })
|
||||
kit.For(arg, func(i int, k string) { arg[i] = strings.Replace(m.Prefix(k), "/", "", 1) })
|
||||
return m.Cmd(CONFIG, SAVE, m.Prefix(nfs.JSON), arg)
|
||||
}
|
||||
func Load(m *ice.Message, arg ...string) *ice.Message {
|
||||
kit.If(len(arg) == 0, func() { arg = kit.SortedKey(m.Target().Configs) })
|
||||
kit.For(arg, func(i int, k string) { arg[i] = m.Prefix(k) })
|
||||
kit.For(arg, func(i int, k string) { arg[i] = strings.Replace(m.Prefix(k), "/", "", 1) })
|
||||
return m.Cmd(CONFIG, LOAD, m.Prefix(nfs.JSON), arg)
|
||||
}
|
||||
func ConfAction(arg ...ice.Any) ice.Actions { return ice.Actions{ice.CTX_INIT: mdb.AutoConfig(arg...)} }
|
||||
|
@ -160,6 +160,8 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands
|
||||
}
|
||||
case "args":
|
||||
m.Cmdy("command", INPUTS, m.Option("index"))
|
||||
case ICON:
|
||||
m.Cmdy("nfs.dir", "usr/icons/", "path")
|
||||
default:
|
||||
kit.Switch(arg[2],
|
||||
HASH, func() { _hash_inputs(m, arg[0], arg[1], kit.Select(NAME, arg, 3), kit.Select("", arg, 4)) },
|
||||
@ -243,12 +245,10 @@ func init() {
|
||||
|
||||
func AutoConfig(arg ...Any) *ice.Action {
|
||||
return &ice.Action{Hand: func(m *ice.Message, args ...string) {
|
||||
if cs := m.Target().Configs; len(arg) > 0 {
|
||||
if cs[m.CommandKey()] == nil {
|
||||
cs[m.CommandKey()] = &ice.Config{Value: kit.Data(arg...)}
|
||||
} else {
|
||||
kit.For(kit.Dict(arg...), func(k string, v Any) { Config(m, k, v) })
|
||||
}
|
||||
if cs := m.Target().Configs; cs[m.CommandKey()] == nil {
|
||||
cs[m.CommandKey()] = &ice.Config{Value: kit.Data(arg...)}
|
||||
} else {
|
||||
kit.For(kit.Dict(arg...), func(k string, v Any) { Config(m, k, v) })
|
||||
}
|
||||
if cmd := m.Target().Commands[m.CommandKey()]; cmd == nil {
|
||||
return
|
||||
@ -259,7 +259,6 @@ func AutoConfig(arg ...Any) *ice.Action {
|
||||
}
|
||||
if inputs := []Any{}; cmd.Meta[CREATE] == nil {
|
||||
kit.For(kit.Filters(kit.Split(Config(m, SHORT)), TIME, HASH, COUNT), func(k string) { inputs = append(inputs, k) })
|
||||
// kit.For(kit.Filters(kit.Split(kit.Select(Config(m, SHORT), Config(m, FIELDS))), TIME, HASH, COUNT), func(k string) { inputs = append(inputs, k) })
|
||||
m.Design(CREATE, "创建", inputs...)
|
||||
}
|
||||
} else if cmd.Actions[CREATE] != nil {
|
||||
|
@ -157,6 +157,8 @@ func _serve_auth(m *ice.Message, key string, cmds []string, w http.ResponseWrite
|
||||
const (
|
||||
SERVE_START = "serve.start"
|
||||
|
||||
SSO = "sso"
|
||||
URL = "url"
|
||||
HTTP = "http"
|
||||
HTTPS = "https"
|
||||
DOMAIN = "domain"
|
||||
@ -215,15 +217,13 @@ func init() {
|
||||
sub = kit.Select(P(key, sub), PP(key, sub), strings.HasSuffix(sub, nfs.PS))
|
||||
actions := ice.Actions{}
|
||||
for k, v := range cmd.Actions {
|
||||
if !kit.IsIn(k, ice.CTX_INIT, ice.CTX_EXIT) {
|
||||
actions[k] = v
|
||||
}
|
||||
kit.If(!kit.IsIn(k, ice.CTX_INIT, ice.CTX_EXIT), func() { actions[k] = v })
|
||||
}
|
||||
c.Commands[sub] = &ice.Command{Name: kit.Select(cmd.Name, action.Name), Actions: ice.MergeActions(actions, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
msg := m.Spawn(c, key, cmd)
|
||||
defer m.Copy(msg)
|
||||
action.Hand(msg, arg...)
|
||||
}}
|
||||
}, RawHand: action.Hand}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -66,13 +66,11 @@ func _space_fork(m *ice.Message) {
|
||||
case CHROME:
|
||||
m.Go(func() { m.Cmd(SPACE, name, cli.PWD, name) })
|
||||
case LOGIN:
|
||||
m.Debug("what %v", m.Option(ice.MSG_USERNAME))
|
||||
if m.Option(ice.MSG_SESSID) != "" && m.Option(ice.MSG_USERNAME) != "" {
|
||||
m.Cmd(SPACE, name, ice.MSG_SESSID, m.Option(ice.MSG_SESSID))
|
||||
}
|
||||
gdb.Event(m, SPACE_LOGIN, args)
|
||||
}
|
||||
m.Debug("what %v", m.Option(ice.MSG_USERNAME))
|
||||
_space_handle(m, false, name, c)
|
||||
}, kit.Join(kit.Simple(SPACE, name), lex.SP))
|
||||
}
|
||||
|
@ -73,24 +73,25 @@ const ACTION = "action"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.P(ACTION): {Name: "/action", Help: "工作台", Actions: ice.MergeActions(ice.Actions{
|
||||
ACTION: {Name: "action", Help: "工作台", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, m.OptionSimple(mdb.ID), arg)
|
||||
}},
|
||||
web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }},
|
||||
}, ctx.CmdAction(), aaa.WhiteAction(web.SHARE, ctx.COMMAND, ice.RUN)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) {
|
||||
return
|
||||
}
|
||||
if m.Option(ice.MSG_USERPOD) == "" && m.Warn(!_river_right(m, arg[0]), ice.ErrNotRight, arg) {
|
||||
return
|
||||
}
|
||||
if len(arg) == 2 {
|
||||
ctx.OptionFromConfig(m, MENUS)
|
||||
_action_list(m, arg[0], arg[1])
|
||||
} else {
|
||||
_action_exec(m, arg[0], arg[1], arg[2], arg[3:]...)
|
||||
}
|
||||
}},
|
||||
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) {
|
||||
return
|
||||
}
|
||||
if m.Option(ice.MSG_USERPOD) == "" && m.Warn(!_river_right(m, arg[0]), ice.ErrNotRight, arg) {
|
||||
return
|
||||
}
|
||||
if len(arg) == 2 {
|
||||
ctx.OptionFromConfig(m, MENUS)
|
||||
_action_list(m, arg[0], arg[1])
|
||||
} else {
|
||||
_action_exec(m, arg[0], arg[1], arg[2], arg[3:]...)
|
||||
}
|
||||
}},
|
||||
}, ctx.CmdAction(), aaa.WhiteAction(web.SHARE, ctx.COMMAND, ice.RUN))},
|
||||
})
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ const FOOTER = "footer"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.P(FOOTER): {Name: "/footer", Help: "状态栏", Actions: ice.MergeActions(ice.Actions{
|
||||
FOOTER: {Name: "footer", Help: "状态栏", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if aaa.Right(m, arg) {
|
||||
if m.Cmdy(arg); m.IsErrNotFound() {
|
||||
@ -37,8 +37,9 @@ func init() {
|
||||
"help": {Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.ProcessField(m, web.WIKI_WORD, []string{"src/document/" + arg[0] + "/list.shy"}, arg...)
|
||||
}},
|
||||
}, ctx.CmdAction(), aaa.WhiteAction(ctx.COMMAND, ice.RUN)), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Result(kit.Select(mdb.Config(m, TITLE), ice.Info.Make.Email))
|
||||
}},
|
||||
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Result(kit.Select(mdb.Config(m, TITLE), ice.Info.Make.Email))
|
||||
}},
|
||||
}, ctx.CmdAction(), aaa.WhiteAction(ctx.COMMAND, ice.RUN))},
|
||||
})
|
||||
}
|
||||
|
@ -69,9 +69,8 @@ const HEADER = "header"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.P(HEADER): {Name: "/header", Help: "标题栏", Actions: ice.MergeActions(ice.Actions{
|
||||
HEADER: {Name: "header", Help: "标题栏", Actions: ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, HEADER) }},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {}},
|
||||
aaa.LOGIN: {Hand: func(m *ice.Message, arg ...string) {}},
|
||||
aaa.LOGOUT: {Hand: aaa.SessLogout},
|
||||
aaa.PASSWORD: {Hand: _header_users},
|
||||
@ -79,32 +78,33 @@ func init() {
|
||||
aaa.LANGUAGE: {Hand: _header_users},
|
||||
aaa.BACKGROUND: {Hand: _header_users},
|
||||
aaa.AVATAR: {Hand: _header_users},
|
||||
web.SHARE: {Hand: _header_share},
|
||||
"webpack": {Hand: ctx.CmdHandler("webpack", "build")},
|
||||
"email": {Name: "email to subject content", Hand: func(m *ice.Message, arg ...string) {
|
||||
aaa.THEME: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||
m.Cmd(cli.SYSTEM, "osascript", "-e", `tell app "System Events" to tell appearance preferences to set dark mode to `+
|
||||
kit.Select(ice.TRUE, ice.FALSE, kit.IsIn(kit.Select(html.LIGHT, arg, 0), html.LIGHT, html.WHITE)))
|
||||
}
|
||||
}},
|
||||
aaa.EMAIL: {Name: "email to subject content", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Options("volcano", web.UserHost(m), "version", web.RenderVersion(m))
|
||||
m.Option(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"))
|
||||
}},
|
||||
"theme": {Hand: func(m *ice.Message, arg ...string) {
|
||||
if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||
web.SHARE: {Hand: _header_share},
|
||||
"webpack": {Hand: ctx.CmdHandler("webpack", "build")},
|
||||
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option("language.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.LANGUAGE), nfs.FILE).Appendv(nfs.FILE))
|
||||
m.Option("theme.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.THEME), nfs.FILE).Appendv(nfs.FILE))
|
||||
m.Option("spide.hub", m.Cmdv(web.SPIDE, ice.HUB, web.CLIENT_URL))
|
||||
if gdb.Event(m, HEADER_AGENT); !_header_check(m, arg...) {
|
||||
return
|
||||
}
|
||||
m.Cmd(cli.SYSTEM, "osascript", "-e", `tell app "System Events" to tell appearance preferences to set dark mode to `+
|
||||
kit.Select(ice.TRUE, ice.FALSE, kit.IsIn(kit.Select(html.LIGHT, arg, 0), html.LIGHT, html.WHITE)))
|
||||
msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME))
|
||||
kit.For([]string{aaa.USERNICK, aaa.LANGUAGE, aaa.EMAIL}, func(k string) { m.Option(k, msg.Append(k)) })
|
||||
kit.For([]string{aaa.AVATAR, aaa.BACKGROUND}, func(k string) { m.Option(k, web.RequireFile(m, msg.Append(k))) })
|
||||
kit.If(m.Option(aaa.LANGUAGE) == "", func() { m.Option(aaa.LANGUAGE, kit.Split(m.R.Header.Get(web.AcceptLanguage), ",;")[0]) })
|
||||
m.Option(MENUS, mdb.Config(m, MENUS))
|
||||
m.Echo(mdb.Config(m, TITLE))
|
||||
}},
|
||||
}, ctx.ConfAction(SSO, "")), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option("language.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.LANGUAGE), nfs.FILE).Appendv(nfs.FILE))
|
||||
m.Option("theme.list", m.Cmd(nfs.DIR, path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), aaa.THEME), nfs.FILE).Appendv(nfs.FILE))
|
||||
m.Option("spide.hub", m.Cmdv(web.SPIDE, ice.HUB, web.CLIENT_URL))
|
||||
if gdb.Event(m, HEADER_AGENT); !_header_check(m, arg...) {
|
||||
return
|
||||
}
|
||||
msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME))
|
||||
kit.For([]string{aaa.USERNICK, aaa.LANGUAGE, aaa.EMAIL}, func(k string) { m.Option(k, msg.Append(k)) })
|
||||
kit.For([]string{aaa.AVATAR, aaa.BACKGROUND}, func(k string) { m.Option(k, web.RequireFile(m, msg.Append(k))) })
|
||||
kit.If(m.Option(aaa.LANGUAGE) == "", func() { m.Option(aaa.LANGUAGE, kit.Split(m.R.Header.Get(web.AcceptLanguage), ",;")[0]) })
|
||||
m.Echo(mdb.Config(m, TITLE)).Option(MENUS, mdb.Config(m, MENUS))
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -28,8 +28,9 @@ const (
|
||||
GRANT_TYPE = "grant_type"
|
||||
STATE = "state"
|
||||
CODE = "code"
|
||||
API = "api"
|
||||
|
||||
API_PREFIX = "api_prefix"
|
||||
TOKEN_PREFIX = "token_prefix"
|
||||
ACCESS_TOKEN = "access_token"
|
||||
EXPIRES_IN = "expires_in"
|
||||
)
|
||||
@ -37,18 +38,16 @@ const (
|
||||
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,api,prefix"`
|
||||
field string `data:"time,hash,domain,client_id,client_secret,oauth_url,grant_url,token_url,users_url,api_prefix,token_prefix"`
|
||||
sso string `name:"sso name* icon*" help:"登录"`
|
||||
auth string `name:"auth" help:"授权"`
|
||||
user string `name:"user" help:"用户"`
|
||||
orgs string `name:"orgs" help:"组织"`
|
||||
repo string `name:"repo" help:"源码"`
|
||||
list string `name:"list hash auto" help:"授权"`
|
||||
login string `name:"login" role:"void"`
|
||||
}
|
||||
|
||||
func (s Client) Init(m *ice.Message, arg ...string) {
|
||||
aaa.White(m.Message, m.PrefixKey(), ctx.ACTION, aaa.LOGIN)
|
||||
s.Hash.Init(m, arg...)
|
||||
}
|
||||
func (s Client) Inputs(m *ice.Message, arg ...string) {
|
||||
switch s.Hash.Inputs(m, arg...); arg[0] {
|
||||
case web.DOMAIN:
|
||||
@ -62,12 +61,16 @@ func (s Client) Inputs(m *ice.Message, arg ...string) {
|
||||
m.Push(arg[0], "/login/oauth/access_token")
|
||||
case USERS_URL:
|
||||
m.Push(arg[0], "/api/v1/user")
|
||||
case lex.PREFIX:
|
||||
m.Push(arg[0], "token")
|
||||
case API:
|
||||
case API_PREFIX:
|
||||
m.Push(arg[0], "/api/v1/")
|
||||
case TOKEN_PREFIX:
|
||||
m.Push(arg[0], "token")
|
||||
}
|
||||
}
|
||||
func (s Client) Sso(m *ice.Message, arg ...string) {
|
||||
mdb.Conf(m, "web.chat.header", kit.Keym(web.SSO, m.Option(mdb.NAME), web.URL), kit.MergeURL2(m.Option(web.DOMAIN), m.Option(OAUTH_URL), m.OptionSimple(CLIENT_ID), REDIRECT_URI, s.RedirectURI(m), RESPONSE_TYPE, CODE, STATE, m.Option(mdb.HASH)))
|
||||
mdb.Conf(m, "web.chat.header", kit.Keym(web.SSO, m.Option(mdb.NAME), mdb.ICON), m.Option(mdb.ICON))
|
||||
}
|
||||
func (s Client) Auth(m *ice.Message, arg ...string) {
|
||||
m.Options(REDIRECT_URI, s.RedirectURI(m), RESPONSE_TYPE, CODE, STATE, m.Option(mdb.HASH))
|
||||
m.ProcessOpen(kit.MergeURL2(m.Option(web.DOMAIN), m.Option(OAUTH_URL), m.OptionSimple(CLIENT_ID, REDIRECT_URI, RESPONSE_TYPE, STATE)))
|
||||
@ -79,18 +82,10 @@ func (s Client) User(m *ice.Message, arg ...string) {
|
||||
m.OptionSimple(aaa.EMAIL, aaa.LANGUAGE, aaa.AVATAR_URL))
|
||||
}
|
||||
}
|
||||
func (s Client) Sso(m *ice.Message, arg ...string) {
|
||||
mdb.Conf(m, "web.chat.header", kit.Keym("sso.gitea.url"), kit.MergeURL2(m.Option(web.DOMAIN), m.Option(OAUTH_URL), m.OptionSimple(CLIENT_ID), REDIRECT_URI, s.RedirectURI(m), RESPONSE_TYPE, CODE, STATE, m.Option(mdb.HASH)))
|
||||
mdb.Conf(m, "web.chat.header", kit.Keym("sso.gitea.icon"), "usr/icons/gitea.png")
|
||||
}
|
||||
func (s Client) Orgs(m *ice.Message, arg ...string) {}
|
||||
func (s Client) Repo(m *ice.Message, arg ...string) {}
|
||||
func (s Client) List(m *ice.Message, arg ...string) {
|
||||
if s.Hash.List(m, arg...).PushAction(s.Sso, s.User, s.Auth, s.Remove); len(arg) == 0 {
|
||||
m.EchoScript(s.RedirectURI(m))
|
||||
} else {
|
||||
m.EchoScript("config header sso " + kit.MergeURL2(m.Append(web.DOMAIN), m.Append(OAUTH_URL), m.AppendSimple(CLIENT_ID), REDIRECT_URI, s.RedirectURI(m), RESPONSE_TYPE, CODE, STATE, arg[0]))
|
||||
}
|
||||
s.Hash.List(m, arg...).PushAction(s.User, s.Auth, s.Sso, s.Remove).EchoScript(s.RedirectURI(m))
|
||||
}
|
||||
|
||||
func init() { ice.ChatCtxCmd(Client{}) }
|
||||
@ -131,8 +126,8 @@ func (s Client) Delete(m *ice.Message, hash, api string, arg ...string) ice.Any
|
||||
func (s Client) request(m *ice.Message, hash, api string, arg ...string) []string {
|
||||
msg := s.Hash.List(m.Spawn(), hash)
|
||||
kit.If(msg.Append(ACCESS_TOKEN), func(p string) {
|
||||
m.Options(web.SPIDE_HEADER, ice.Maps{web.Authorization: msg.Append(lex.PREFIX) + lex.SP + p})
|
||||
m.Options(web.SPIDE_HEADER, ice.Maps{web.Authorization: msg.Append(TOKEN_PREFIX) + lex.SP + p})
|
||||
})
|
||||
kit.If(api == "", func() { api = path.Join(msg.Append(API), strings.ToLower(kit.FuncName(6))) })
|
||||
kit.If(api == "", func() { api = path.Join(msg.Append(API_PREFIX), strings.ToLower(kit.FuncName(6))) })
|
||||
return kit.Simple(kit.MergeURL2(msg.Append(web.DOMAIN), api), arg)
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ const RIVER = "river"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.P(RIVER): {Name: "/river", Help: "群组", Actions: ice.MergeActions(ice.Actions{
|
||||
RIVER: {Name: "river", Help: "群组", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashImport(m) }},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashExport(m) }},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -66,16 +66,17 @@ func init() {
|
||||
}
|
||||
gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg)
|
||||
}},
|
||||
}, aaa.WhiteAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,icon,name,text,template")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || !aaa.Right(m, RIVER, arg) {
|
||||
return
|
||||
} else if len(arg) == 0 {
|
||||
_river_list(m)
|
||||
} else if len(arg) > 1 && arg[1] == STORM {
|
||||
m.Cmdy(arg[1], arg[2:], kit.Dict(ice.MSG_RIVER, arg[0]))
|
||||
} else if len(arg) > 2 && arg[2] == STORM {
|
||||
m.Cmdy(arg[2], arg[3:], kit.Dict(ice.MSG_RIVER, arg[0], ice.MSG_STORM, arg[1]))
|
||||
}
|
||||
}},
|
||||
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || !aaa.Right(m, RIVER, arg) {
|
||||
return
|
||||
} else if len(arg) == 0 {
|
||||
_river_list(m)
|
||||
} else if len(arg) > 1 && arg[1] == STORM {
|
||||
m.Cmdy(arg[1], arg[2:], kit.Dict(ice.MSG_RIVER, arg[0]))
|
||||
} else if len(arg) > 2 && arg[2] == STORM {
|
||||
m.Cmdy(arg[2], arg[3:], kit.Dict(ice.MSG_RIVER, arg[0], ice.MSG_STORM, arg[1]))
|
||||
}
|
||||
}},
|
||||
}, aaa.WhiteAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,icon,name,text,template"))},
|
||||
})
|
||||
}
|
||||
|
@ -12,10 +12,11 @@ const SEARCH = "search"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
web.P(SEARCH): {Name: "/search", Help: "搜索框", Actions: ice.MergeActions(ice.Actions{
|
||||
SEARCH: {Name: "search", Help: "搜索框", Actions: ice.MergeActions(ice.Actions{
|
||||
cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, arg...) }},
|
||||
}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(web.Space(m, m.Option(ice.POD)), mdb.SEARCH, arg).StatusTimeCount()
|
||||
}},
|
||||
"/": {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(web.Space(m, m.Option(ice.POD)), mdb.SEARCH, arg).StatusTimeCount()
|
||||
}},
|
||||
}, ctx.CmdAction())},
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user