mirror of
https://shylinux.com/x/icebergs
synced 2025-04-28 18:22:02 +08:00
opt some
This commit is contained in:
parent
d73015258e
commit
5b41af897b
@ -13,7 +13,6 @@ func _sess_list(m *ice.Message) {
|
|||||||
}
|
}
|
||||||
func _sess_auth(m *ice.Message, sessid string, username string, userrole string) {
|
func _sess_auth(m *ice.Message, sessid string, username string, userrole string) {
|
||||||
m.Richs(SESS, nil, sessid, func(value map[string]interface{}) {
|
m.Richs(SESS, nil, sessid, func(value map[string]interface{}) {
|
||||||
m.Debug("fuck %v", m.Option(ice.MSG_USERROLE))
|
|
||||||
if m.Option(ice.MSG_USERROLE) == ROOT {
|
if m.Option(ice.MSG_USERROLE) == ROOT {
|
||||||
value[USERROLE] = userrole
|
value[USERROLE] = userrole
|
||||||
} else if m.Option(ice.MSG_USERROLE) == TECH && userrole != ROOT {
|
} else if m.Option(ice.MSG_USERROLE) == TECH && userrole != ROOT {
|
||||||
@ -32,12 +31,15 @@ func _sess_check(m *ice.Message, sessid string) {
|
|||||||
})
|
})
|
||||||
m.Log_AUTH(
|
m.Log_AUTH(
|
||||||
USERNAME, m.Option(ice.MSG_USERNAME, value[USERNAME]),
|
USERNAME, m.Option(ice.MSG_USERNAME, value[USERNAME]),
|
||||||
USERROLE, m.Option(ice.MSG_USERROLE, value[USERROLE]),
|
USERROLE, m.Option(ice.MSG_USERROLE, kit.Select(UserRole(m, value[USERNAME]), value[USERROLE])),
|
||||||
USERNICK, m.Option(ice.MSG_USERROLE),
|
USERNICK, m.Option(ice.MSG_USERROLE),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func _sess_create(m *ice.Message, username string) string {
|
func _sess_create(m *ice.Message, username string) string {
|
||||||
|
if m.Richs(USER, nil, username, nil) == nil {
|
||||||
|
_user_create(m, username, "")
|
||||||
|
}
|
||||||
h := m.Rich(SESS, nil, kit.Dict(
|
h := m.Rich(SESS, nil, kit.Dict(
|
||||||
kit.MDB_TIME, m.Time(m.Conf(SESS, "meta.expire")),
|
kit.MDB_TIME, m.Time(m.Conf(SESS, "meta.expire")),
|
||||||
USERNAME, username, "from", m.Option(ice.MSG_SESSID),
|
USERNAME, username, "from", m.Option(ice.MSG_SESSID),
|
||||||
|
@ -48,7 +48,7 @@ func _user_create(m *ice.Message, name, word string) {
|
|||||||
}
|
}
|
||||||
func _user_search(m *ice.Message, kind, name, text string, arg ...string) {
|
func _user_search(m *ice.Message, kind, name, text string, arg ...string) {
|
||||||
m.Richs(USER, nil, kit.MDB_FOREACH, func(key string, val map[string]interface{}) {
|
m.Richs(USER, nil, kit.MDB_FOREACH, func(key string, val map[string]interface{}) {
|
||||||
if name != val[USERNAME] {
|
if name != "" && name != val[USERNAME] {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Push("pod", m.Option("pod"))
|
m.Push("pod", m.Option("pod"))
|
||||||
@ -57,8 +57,8 @@ func _user_search(m *ice.Message, kind, name, text string, arg ...string) {
|
|||||||
m.Push(key, val, []string{kit.MDB_TIME})
|
m.Push(key, val, []string{kit.MDB_TIME})
|
||||||
m.Push(kit.MDB_SIZE, kit.Format(""))
|
m.Push(kit.MDB_SIZE, kit.Format(""))
|
||||||
m.Push(kit.MDB_TYPE, kit.Format(UserRole(m, val[USERNAME])))
|
m.Push(kit.MDB_TYPE, kit.Format(UserRole(m, val[USERNAME])))
|
||||||
m.Push(kit.MDB_NAME, kit.Format(val[USERNAME]))
|
m.Push(kit.MDB_NAME, kit.Format(val[USERNICK]))
|
||||||
m.Push(kit.MDB_TEXT, kit.Format(val[USERNODE]))
|
m.Push(kit.MDB_TEXT, kit.Format(val[USERNAME]))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,10 @@ func init() {
|
|||||||
m.Cmdy("/storm", arg[1:])
|
m.Cmdy("/storm", arg[1:])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if m.Option(ice.MSG_SESSID) == "" {
|
||||||
|
m.Render("status", "401")
|
||||||
|
return
|
||||||
|
}
|
||||||
_river_list(m)
|
_river_list(m)
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
1
meta.go
1
meta.go
@ -438,6 +438,7 @@ func (m *Message) Optionv(key string, arg ...interface{}) interface{} {
|
|||||||
m.meta[key] = kit.Simple(arg)
|
m.meta[key] = kit.Simple(arg)
|
||||||
case []string:
|
case []string:
|
||||||
m.meta[key] = str
|
m.meta[key] = str
|
||||||
|
delete(m.data, key)
|
||||||
default:
|
default:
|
||||||
m.data[key] = str
|
m.data[key] = str
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
title "lark"
|
title "飞书机器人"
|
||||||
|
|
||||||
refer "官网" `
|
refer "官网" `
|
||||||
官网 https://www.feishu.cn/
|
官网 https://www.feishu.cn/
|
||||||
|
@ -2,10 +2,13 @@ package mp
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/shylinux/icebergs"
|
"github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
"github.com/shylinux/icebergs/core/chat"
|
"github.com/shylinux/icebergs/core/chat"
|
||||||
"github.com/shylinux/toolkits"
|
"github.com/shylinux/toolkits"
|
||||||
|
|
||||||
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,14 +23,14 @@ var Index = &ice.Context{Name: "mp", Help: "小程序",
|
|||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Load()
|
m.Load()
|
||||||
web.SpideCreate(m, "weixin", m.Conf("login", "meta.weixin"))
|
m.Cmd(web.SPIDE, mdb.CREATE, "weixin", m.Conf("login", "meta.weixin"))
|
||||||
m.Confm("login", "meta.userrole", func(key string, value string) {
|
m.Confm("login", "meta.userrole", func(key string, value string) {
|
||||||
m.Cmd(aaa.ROLE, value, key)
|
m.Cmd(aaa.ROLE, value, key)
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Save("login")
|
m.Save("login")
|
||||||
}},
|
}},
|
||||||
|
|
||||||
@ -56,11 +59,11 @@ var Index = &ice.Context{Name: "mp", Help: "小程序",
|
|||||||
"/login/": {Name: "/login/", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"/login/": {Name: "/login/", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "code":
|
case "code":
|
||||||
msg := m.Cmd(web.SPIDE, "weixin", "GET", m.Conf("login", "meta.auth"), "js_code", m.Option("code"),
|
msg := m.Cmd(web.SPIDE, "weixin", http.MethodGet, m.Conf("login", "meta.auth"), "js_code", m.Option("code"),
|
||||||
"appid", m.Conf("login", "meta.appid"), "secret", m.Conf("login", "meta.appmm"))
|
"appid", m.Conf("login", "meta.appid"), "secret", m.Conf("login", "meta.appmm"))
|
||||||
|
|
||||||
// 用户登录
|
// 用户登录
|
||||||
m.Echo(m.Option(ice.MSG_SESSID, m.Cmdx(aaa.USER, "login", msg.Append("openid"))))
|
m.Echo(aaa.SessCreate(msg, msg.Append("openid"), aaa.UserRole(msg, msg.Append("openid"))))
|
||||||
|
|
||||||
case "info":
|
case "info":
|
||||||
// 用户信息
|
// 用户信息
|
||||||
@ -114,7 +117,7 @@ var Index = &ice.Context{Name: "mp", Help: "小程序",
|
|||||||
|
|
||||||
case "upload":
|
case "upload":
|
||||||
msg := m.Cmd(web.CACHE, "upload")
|
msg := m.Cmd(web.CACHE, "upload")
|
||||||
m.Cmd(web.STORY, ice.STORY_WATCH, msg.Append("data"), path.Join("usr/local/mp/", path.Base(msg.Append("name"))))
|
m.Cmd(web.STORY, web.WATCH, msg.Append("data"), path.Join("usr/local/mp/", path.Base(msg.Append("name"))))
|
||||||
m.Cmd(web.FAVOR, "device", "file", msg.Append("name"), msg.Append("data"))
|
m.Cmd(web.FAVOR, "device", "file", msg.Append("name"), msg.Append("data"))
|
||||||
m.Render(msg.Append("data"))
|
m.Render(msg.Append("data"))
|
||||||
|
|
||||||
|
15
misc/mp/mp.shy
Normal file
15
misc/mp/mp.shy
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
title "微信小程序"
|
||||||
|
refer "" `
|
||||||
|
官网 https://weixin.qq.com/
|
||||||
|
后台 https://mp.weixin.qq.com/
|
||||||
|
文档 https://developers.weixin.qq.com/miniprogram/dev/api/
|
||||||
|
源码 https://github.com/shylinux/icebergs/blob/master/misc/mp/mp.go
|
||||||
|
`
|
||||||
|
|
||||||
|
field "用户" user
|
||||||
|
|
||||||
|
section "icebergs"
|
||||||
|
field "icebergs_统计" web.code.git.trend args `[ icebergs ]` action `{ height 200 speed 20 }`
|
||||||
|
field "icebergs_源码" web.code.inner args `[ usr/icebergs misc/mp/mp.go 1 ]`
|
||||||
|
field "icebergs_项目" web.code.git.spide args `[ icebergs ]`
|
||||||
|
|
@ -2,6 +2,8 @@ package wx
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/shylinux/icebergs"
|
"github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/aaa"
|
||||||
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
"github.com/shylinux/icebergs/core/chat"
|
"github.com/shylinux/icebergs/core/chat"
|
||||||
"github.com/shylinux/toolkits"
|
"github.com/shylinux/toolkits"
|
||||||
@ -94,13 +96,13 @@ var Index = &ice.Context{Name: "wx", Help: "公众号",
|
|||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Load()
|
m.Load()
|
||||||
m.Confm("login", "meta.userrole", func(key string, value string) {
|
m.Confm("login", "meta.userrole", func(key string, value string) {
|
||||||
m.Cmd(aaa.ROLE, value, key)
|
m.Cmd(aaa.ROLE, value, key)
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Save("login")
|
m.Save("login")
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user