forked from x/icebergs
add some
This commit is contained in:
parent
26fe9b47f9
commit
8df263fceb
@ -29,7 +29,7 @@ func init() {
|
|||||||
DF = ": "
|
DF = ": "
|
||||||
)
|
)
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
EMAIL: {Name: "email name auto create mailbox", Help: "邮件", Actions: ice.MergeActions(ice.Actions{
|
EMAIL: {Name: "email name auto", Help: "邮件", Actions: ice.MergeActions(ice.Actions{
|
||||||
MAILBOX: {Help: "邮箱", Hand: func(m *ice.Message, arg ...string) { m.EchoIFrame(mdb.Config(m, MAILBOX)).ProcessInner() }},
|
MAILBOX: {Help: "邮箱", Hand: func(m *ice.Message, arg ...string) { m.EchoIFrame(mdb.Config(m, MAILBOX)).ProcessInner() }},
|
||||||
SEND: {Name: "send to*='shy@shylinux.com' cc subject*=hi content*:textarea=hello", Help: "发送", Hand: func(m *ice.Message, arg ...string) {
|
SEND: {Name: "send to*='shy@shylinux.com' cc subject*=hi content*:textarea=hello", Help: "发送", Hand: func(m *ice.Message, arg ...string) {
|
||||||
msg := m.Cmd("", m.OptionDefault(mdb.NAME, ADMIN))
|
msg := m.Cmd("", m.OptionDefault(mdb.NAME, ADMIN))
|
||||||
|
@ -34,7 +34,7 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
}, RoleAction(ACCEPT), mdb.ImportantHashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,status,invite,email,title,content")), Hand: func(m *ice.Message, arg ...string) {
|
}, RoleAction(ACCEPT), mdb.ImportantHashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,status,invite,email,title,content")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if !m.Warn(len(arg) == 0 && m.Option(ice.MSG_USERROLE) == VOID, ice.ErrNotRight) {
|
if !m.Warn(len(arg) == 0 && m.Option(ice.MSG_USERROLE) == VOID, ice.ErrNotRight) {
|
||||||
kit.If(mdb.HashSelect(m, arg...).FieldsIsDetail(), func() { m.PushAction(ACCEPT) }, func() { m.Action(mdb.CREATE) })
|
kit.If(mdb.HashSelect(m, arg...).FieldsIsDetail(), func() { m.PushAction(ACCEPT) })
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
@ -16,7 +16,7 @@ func _role_keys(key ...string) string {
|
|||||||
key[0] = _key
|
key[0] = _key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return strings.TrimPrefix(strings.TrimPrefix(strings.TrimSuffix(strings.Replace(path.Join(strings.Replace(kit.Keys(key), ice.PT, ice.PS, -1)), ice.PS, ice.PT, -1), ice.PT), ice.PT), "web.")
|
return strings.TrimPrefix(strings.TrimPrefix(strings.TrimSuffix(strings.ReplaceAll(path.Join(strings.ReplaceAll(kit.Keys(key), ice.PT, ice.PS)), ice.PS, ice.PT), ice.PT), ice.PT), "web.")
|
||||||
}
|
}
|
||||||
func _role_set(m *ice.Message, role, zone, key string, status bool) {
|
func _role_set(m *ice.Message, role, zone, key string, status bool) {
|
||||||
m.Logs(mdb.INSERT, mdb.KEY, ROLE, ROLE, role, zone, key)
|
m.Logs(mdb.INSERT, mdb.KEY, ROLE, ROLE, role, zone, key)
|
||||||
@ -68,6 +68,12 @@ const ROLE = "role"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
ROLE: {Name: "role role auto insert filter:text", Help: "角色", Actions: ice.MergeActions(ice.Actions{
|
ROLE: {Name: "role role auto insert filter:text", Help: "角色", Actions: ice.MergeActions(ice.Actions{
|
||||||
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
switch arg[0] {
|
||||||
|
case mdb.KEY:
|
||||||
|
mdb.HashInputs(m, ice.INDEX).CutTo(ice.INDEX, arg[0])
|
||||||
|
}
|
||||||
|
}},
|
||||||
mdb.CREATE: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
kit.For(arg, func(role string) {
|
kit.For(arg, func(role string) {
|
||||||
mdb.Rich(m, ROLE, nil, kit.Dict(mdb.NAME, role, BLACK, kit.Dict(), WHITE, kit.Dict()))
|
mdb.Rich(m, ROLE, nil, kit.Dict(mdb.NAME, role, BLACK, kit.Dict(), WHITE, kit.Dict()))
|
||||||
@ -110,6 +116,12 @@ func WhiteAction(key ...string) ice.Actions {
|
|||||||
kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, VOID, m.CommandKey(), ice.ACTION, key) })
|
kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, VOID, m.CommandKey(), ice.ACTION, key) })
|
||||||
}}}
|
}}}
|
||||||
}
|
}
|
||||||
|
func White(m *ice.Message, key ...string) {
|
||||||
|
kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, VOID, key) })
|
||||||
|
}
|
||||||
|
func Black(m *ice.Message, key ...string) {
|
||||||
|
kit.For(key, func(key string) { m.Cmd(ROLE, BLACK, VOID, key) })
|
||||||
|
}
|
||||||
func Right(m *ice.Message, key ...ice.Any) bool {
|
func Right(m *ice.Message, key ...ice.Any) bool {
|
||||||
if key := kit.Simple(key); len(key) > 2 && key[1] == ice.ACTION && kit.IsIn(kit.Format(key[2]), ice.RUN, ice.COMMAND) {
|
if key := kit.Simple(key); len(key) > 2 && key[1] == ice.ACTION && kit.IsIn(kit.Format(key[2]), ice.RUN, ice.COMMAND) {
|
||||||
return true
|
return true
|
||||||
@ -119,9 +131,3 @@ func Right(m *ice.Message, key ...ice.Any) bool {
|
|||||||
return m.Option(ice.MSG_USERROLE) == ROOT || !m.Warn(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key, logs.FileLineMeta(-1)) != ice.OK,
|
return m.Option(ice.MSG_USERROLE) == ROOT || !m.Warn(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key, logs.FileLineMeta(-1)) != ice.OK,
|
||||||
ice.ErrNotRight, kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(-1))
|
ice.ErrNotRight, kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(-1))
|
||||||
}
|
}
|
||||||
func White(m *ice.Message, key ...string) {
|
|
||||||
kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, VOID, key) })
|
|
||||||
}
|
|
||||||
func Black(m *ice.Message, key ...string) {
|
|
||||||
kit.For(key, func(key string) { m.Cmd(ROLE, BLACK, VOID, key) })
|
|
||||||
}
|
|
||||||
|
@ -33,7 +33,7 @@ const SESS = "sess"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
SESS: {Name: "sess hash auto prunes", Help: "会话", Actions: ice.MergeActions(ice.Actions{
|
SESS: {Name: "sess hash auto", Help: "会话", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.CREATE: {Name: "create username*", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create username*", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_sess_create(m, m.Option(USERNAME), UA, m.Option(ice.MSG_USERUA), IP, m.Option(ice.MSG_USERIP))
|
_sess_create(m, m.Option(USERNAME), UA, m.Option(ice.MSG_USERUA), IP, m.Option(ice.MSG_USERIP))
|
||||||
}},
|
}},
|
||||||
|
@ -46,7 +46,7 @@ func init() {
|
|||||||
SECRET = "secret"
|
SECRET = "secret"
|
||||||
)
|
)
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TOTP: {Name: "totp name auto create", Help: "令牌", Actions: ice.MergeActions(ice.Actions{
|
TOTP: {Name: "totp name auto", Help: "令牌", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.CREATE: {Name: "create name*=hi number*=6 period*=30 secret", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create name*=hi number*=6 period*=30 secret", Hand: func(m *ice.Message, arg ...string) {
|
||||||
kit.If(m.Option(SECRET) == "", func() { m.Option(SECRET, _totp_gen(kit.Int64(m.Option(PERIOD)))) })
|
kit.If(m.Option(SECRET) == "", func() { m.Option(SECRET, _totp_gen(kit.Int64(m.Option(PERIOD)))) })
|
||||||
mdb.HashCreate(m, m.OptionSimple(mdb.NAME, NUMBER, PERIOD, SECRET))
|
mdb.HashCreate(m, m.OptionSimple(mdb.NAME, NUMBER, PERIOD, SECRET))
|
||||||
@ -61,10 +61,11 @@ func init() {
|
|||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
m.PushQRCode(mdb.SCAN, kit.Format(mdb.Config(m, mdb.LINK), value[mdb.NAME], value[SECRET]))
|
m.PushQRCode(mdb.SCAN, kit.Format(mdb.Config(m, mdb.LINK), value[mdb.NAME], value[SECRET]))
|
||||||
m.Echo(m.Append(mdb.VALUE))
|
m.Echo(m.Append(mdb.VALUE))
|
||||||
} else {
|
|
||||||
m.PushAction(mdb.REMOVE).StatusTimeCount()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if len(arg) == 0 {
|
||||||
|
m.PushAction(mdb.REMOVE).Action(mdb.CREATE, mdb.PRUNES).StatusTimeCount()
|
||||||
|
}
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ const USER = "user"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
USER: {Name: "user username auto create", Help: "用户", Actions: ice.MergeActions(ice.Actions{
|
USER: {Name: "user username auto", Help: "用户", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch mdb.HashInputs(m, arg); arg[0] {
|
switch mdb.HashInputs(m, arg); arg[0] {
|
||||||
case USERNICK:
|
case USERNICK:
|
||||||
@ -48,7 +48,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.CREATE: {Name: "create usernick username* userrole=void,tech userzone", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create usernick username* userrole=void,tech userzone", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_user_create(m, m.Option(USERNAME), m.OptionSimple(USERNICK, USERROLE, USERZONE, BACKGROUND, AVATAR, AVATAR_URL, EMAIL, LANGUAGE)...)
|
_user_create(m, m.Option(USERNAME), m.OptionSimple(USERNICK, USERROLE, USERZONE, BACKGROUND, AVATAR, AVATAR_URL, LANGUAGE, EMAIL)...)
|
||||||
}},
|
}},
|
||||||
}, mdb.ImportantHashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone"))},
|
}, mdb.ImportantHashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone"))},
|
||||||
})
|
})
|
||||||
|
@ -65,7 +65,7 @@ const (
|
|||||||
PURPLE = "purple"
|
PURPLE = "purple"
|
||||||
YELLOW = "yellow"
|
YELLOW = "yellow"
|
||||||
RANDOM = "random"
|
RANDOM = "random"
|
||||||
GLASS = "#0000"
|
TRANS = "#0000"
|
||||||
LIGHT = "light"
|
LIGHT = "light"
|
||||||
DARK = "dark"
|
DARK = "dark"
|
||||||
)
|
)
|
||||||
|
@ -81,22 +81,22 @@ const (
|
|||||||
STATUS = "status"
|
STATUS = "status"
|
||||||
ERROR = "error"
|
ERROR = "error"
|
||||||
CLEAR = "clear"
|
CLEAR = "clear"
|
||||||
|
DELAY = "delay"
|
||||||
RELOAD = "reload"
|
RELOAD = "reload"
|
||||||
RESTART = "restart"
|
RESTART = "restart"
|
||||||
|
|
||||||
DELAY = "delay"
|
|
||||||
BEGIN = "begin"
|
BEGIN = "begin"
|
||||||
|
END = "end"
|
||||||
START = "start"
|
START = "start"
|
||||||
|
STOP = "stop"
|
||||||
OPEN = "open"
|
OPEN = "open"
|
||||||
CLOSE = "close"
|
CLOSE = "close"
|
||||||
STOP = "stop"
|
|
||||||
END = "end"
|
|
||||||
|
|
||||||
MAIN = "main"
|
MAIN = "main"
|
||||||
CODE = "code"
|
CODE = "code"
|
||||||
COST = "cost"
|
COST = "cost"
|
||||||
BACK = "back"
|
|
||||||
FROM = "from"
|
FROM = "from"
|
||||||
|
BACK = "back"
|
||||||
)
|
)
|
||||||
|
|
||||||
const DAEMON = "daemon"
|
const DAEMON = "daemon"
|
||||||
@ -147,20 +147,6 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func OpenCmds(m *ice.Message, arg ...string) {
|
|
||||||
if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if len(arg) == 0 || arg[0] == "" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Cmd(SYSTEM, "osascript", "-e", kit.Format(`
|
|
||||||
tell application "Terminal"
|
|
||||||
do script "%s"
|
|
||||||
activate
|
|
||||||
end tell
|
|
||||||
`, strings.Join(arg, "; ")))
|
|
||||||
}
|
|
||||||
func Opens(m *ice.Message, arg ...string) {
|
func Opens(m *ice.Message, arg ...string) {
|
||||||
if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||||
return
|
return
|
||||||
@ -183,3 +169,17 @@ func Opens(m *ice.Message, arg ...string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func OpenCmds(m *ice.Message, arg ...string) {
|
||||||
|
if !tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(arg) == 0 || arg[0] == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.Cmd(SYSTEM, "osascript", "-e", kit.Format(`
|
||||||
|
tell application "Terminal"
|
||||||
|
do script "%s"
|
||||||
|
activate
|
||||||
|
end tell
|
||||||
|
`, strings.Join(arg, "; ")))
|
||||||
|
}
|
||||||
|
@ -14,26 +14,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _path_sep() string { return kit.Select(nfs.DF, ";", strings.Contains(os.Getenv(PATH), ";")) }
|
func _path_sep() string { return kit.Select(nfs.DF, ";", strings.Contains(os.Getenv(PATH), ";")) }
|
||||||
func BinPath(arg ...string) string {
|
|
||||||
list := []string{}
|
|
||||||
push := func(p string) {
|
|
||||||
kit.If(kit.IndexOf(list, p) == -1, func() { list = append(list, kit.ReplaceAll(p, "\\", nfs.PS)) })
|
|
||||||
}
|
|
||||||
kit.For(arg, func(p string) {
|
|
||||||
list = append(list, kit.Path(p, ice.BIN), kit.Path(p, ice.USR_PUBLISH), kit.Path(p, ice.USR_LOCAL_BIN), kit.Path(p, ice.USR_LOCAL_GO_BIN))
|
|
||||||
kit.For(kit.Reverse(strings.Split(ice.Pulse.Cmdx(nfs.CAT, kit.Path(p, ice.ETC_PATH)), lex.NL)), func(l string) {
|
|
||||||
kit.If(strings.TrimSpace(l) != "" && !strings.HasPrefix(strings.TrimSpace(l), "#"), func() { push(kit.Path(p, l)) })
|
|
||||||
})
|
|
||||||
})
|
|
||||||
kit.For(strings.Split(kit.Env(PATH), _path_sep()), func(p string) { push(p) })
|
|
||||||
return kit.Join(list, _path_sep())
|
|
||||||
}
|
|
||||||
|
|
||||||
const FOREVER = "forever"
|
const FOREVER = "forever"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
FOREVER: {Name: "forever auto", Help: "启动", Actions: ice.Actions{
|
FOREVER: {Help: "启动", Actions: ice.Actions{
|
||||||
START: {Hand: func(m *ice.Message, arg ...string) {
|
START: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
env := []string{PATH, BinPath(""), HOME, kit.Select(kit.Path(""), os.Getenv(HOME))}
|
env := []string{PATH, BinPath(""), HOME, kit.Select(kit.Path(""), os.Getenv(HOME))}
|
||||||
kit.For(ENV_LIST, func(k string) { kit.If(kit.Env(k) != "", func() { env = append(env, k, kit.Env(k)) }) })
|
kit.For(ENV_LIST, func(k string) { kit.If(kit.Env(k) != "", func() { env = append(env, k, kit.Env(k)) }) })
|
||||||
@ -70,3 +56,18 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BinPath(arg ...string) string {
|
||||||
|
list := []string{}
|
||||||
|
push := func(p string) {
|
||||||
|
kit.If(kit.IndexOf(list, p) == -1, func() { list = append(list, kit.ReplaceAll(p, "\\", nfs.PS)) })
|
||||||
|
}
|
||||||
|
kit.For(arg, func(p string) {
|
||||||
|
list = append(list, kit.Path(p, ice.BIN), kit.Path(p, ice.USR_PUBLISH), kit.Path(p, ice.USR_LOCAL_BIN), kit.Path(p, ice.USR_LOCAL_GO_BIN))
|
||||||
|
kit.For(kit.Reverse(strings.Split(ice.Pulse.Cmdx(nfs.CAT, kit.Path(p, ice.ETC_PATH)), lex.NL)), func(l string) {
|
||||||
|
kit.If(strings.TrimSpace(l) != "" && !strings.HasPrefix(strings.TrimSpace(l), "#"), func() { push(kit.Path(p, l)) })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
kit.For(strings.Split(kit.Env(PATH), _path_sep()), func(p string) { push(p) })
|
||||||
|
return kit.Join(list, _path_sep())
|
||||||
|
}
|
||||||
|
@ -222,6 +222,7 @@ func HashSelect(m *ice.Message, arg ...string) *ice.Message {
|
|||||||
m.Cmdy(SELECT, m.PrefixKey(), m.Option(SUBKEY), HASH, HashShort(m), arg, logs.FileLineMeta(-1))
|
m.Cmdy(SELECT, m.PrefixKey(), m.Option(SUBKEY), HASH, HashShort(m), arg, logs.FileLineMeta(-1))
|
||||||
kit.If(Config(m, SORT), func(sort string) { m.Sort(sort) })
|
kit.If(Config(m, SORT), func(sort string) { m.Sort(sort) })
|
||||||
if m.PushAction(Config(m, ACTION), REMOVE); !m.FieldsIsDetail() {
|
if m.PushAction(Config(m, ACTION), REMOVE); !m.FieldsIsDetail() {
|
||||||
|
m.Action(CREATE, PRUNES)
|
||||||
return m.StatusTimeCount()
|
return m.StatusTimeCount()
|
||||||
}
|
}
|
||||||
return m.StatusTime()
|
return m.StatusTime()
|
||||||
|
@ -93,7 +93,7 @@ func init() {
|
|||||||
m.OptionDefault(wiki.MARGINX, "60")
|
m.OptionDefault(wiki.MARGINX, "60")
|
||||||
m.OptionDefault(wiki.MARGINY, "16")
|
m.OptionDefault(wiki.MARGINY, "16")
|
||||||
m.OptionDefault(wiki.PADDING, "10")
|
m.OptionDefault(wiki.PADDING, "10")
|
||||||
wiki.AddGroupOption(m, SHIP, wiki.FILL, cli.GLASS)
|
wiki.AddGroupOption(m, SHIP, wiki.FILL, cli.TRANS)
|
||||||
return &Chain{}
|
return &Chain{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ func init() {
|
|||||||
wiki.AddGroupOption(m, PREV, wiki.STROKE_DASHARRAY, "10 2")
|
wiki.AddGroupOption(m, PREV, wiki.STROKE_DASHARRAY, "10 2")
|
||||||
wiki.AddGroupOption(m, TEXT, wiki.FONT_SIZE, "16")
|
wiki.AddGroupOption(m, TEXT, wiki.FONT_SIZE, "16")
|
||||||
wiki.AddGroupOption(m, ECHO, wiki.FONT_SIZE, "12")
|
wiki.AddGroupOption(m, ECHO, wiki.FONT_SIZE, "12")
|
||||||
wiki.AddGroupOption(m, ARROW, wiki.HEIGHT, "6", wiki.WIDTH, "12", wiki.FILL, cli.GLASS)
|
wiki.AddGroupOption(m, ARROW, wiki.HEIGHT, "6", wiki.WIDTH, "12", wiki.FILL, cli.TRANS)
|
||||||
return &Sequence{}
|
return &Sequence{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user