forked from x/icebergs
opt lark
This commit is contained in:
parent
7b92e41750
commit
2242d218d6
@ -5,6 +5,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -20,17 +21,17 @@ const APP = "app"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: map[string]*ice.Config{
|
||||
APP: {Name: APP, Help: "服务配置", Value: kit.Data(
|
||||
kit.MDB_SHORT, APPID, kit.MDB_FIELD, "time,appid,appmm,duty,token,expire",
|
||||
LARK, "https://open.feishu.cn/",
|
||||
APP: {Name: APP, Help: "应用", Value: kit.Data(
|
||||
kit.MDB_SHORT, APPID, kit.MDB_FIELD, "time,appid,duty,token,expire",
|
||||
tcp.SERVER, "https://open.feishu.cn/",
|
||||
)},
|
||||
}, Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Cmd(web.SPIDE, mdb.CREATE, LARK, m.Conf(APP, kit.Keym(LARK)))
|
||||
}},
|
||||
APP: {Name: "app appid auto token login", Help: "应用", Action: ice.MergeAction(map[string]*ice.Action{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(web.SPIDE, mdb.CREATE, LARK, m.Config(tcp.SERVER))
|
||||
}},
|
||||
LOGIN: {Name: "login appid appmm duty", Help: "登录", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.INSERT, m.Prefix(APP), "", mdb.HASH, arg)
|
||||
m.Cmdy(mdb.INSERT, m.PrefixKey(), "", mdb.HASH, arg)
|
||||
}},
|
||||
TOKEN: {Name: "token appid", Help: "令牌", Hand: func(m *ice.Message, arg ...string) {
|
||||
msg := m.Cmd(APP, m.Option(APPID))
|
||||
@ -38,7 +39,7 @@ func init() {
|
||||
res := m.Cmd(web.SPIDE, LARK, "/open-apis/auth/v3/tenant_access_token/internal/",
|
||||
APP_ID, msg.Append(APPID), "app_secret", msg.Append(APPMM))
|
||||
|
||||
m.Cmd(mdb.MODIFY, m.Prefix(APP), "", mdb.HASH, m.OptionSimple(APPID),
|
||||
m.Cmd(mdb.MODIFY, m.PrefixKey(), "", mdb.HASH, m.OptionSimple(APPID),
|
||||
TOKEN, res.Append("tenant_access_token"), EXPIRE, now+kit.Int64(res.Append(EXPIRE)))
|
||||
m.Echo(res.Append("tenant_access_token"))
|
||||
return
|
||||
@ -48,6 +49,5 @@ func init() {
|
||||
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
mdb.HashSelect(m, arg...)
|
||||
}},
|
||||
},
|
||||
})
|
||||
}})
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ const DUTY = "duty"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||
DUTY: {Name: "duty [title] text auto", Help: "通告", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
duty := m.Cmd(APP, m.Option(APP_ID)).Append(DUTY)
|
||||
m.Cmdy(SEND, arg[0], duty, arg[1:])
|
||||
msg := m.Cmd(APP, m.Option(APP_ID))
|
||||
m.Cmdy(SEND, msg.Append(APPID), msg.Append(DUTY), arg)
|
||||
}},
|
||||
}})
|
||||
}
|
||||
|
@ -1,23 +1,22 @@
|
||||
title "飞书机器人"
|
||||
refer "官网" `
|
||||
官网 https://shylinux.com/chat/lark/sso
|
||||
refer `
|
||||
官网 https://www.feishu.cn/
|
||||
文档 https://open.feishu.cn/document/uQjL04CN/ucDOz4yN4MjL3gzM
|
||||
源码 https://shylinux.com/x/icebergs/blob/master/misc/lark/lark.go
|
||||
后台管理 https://www.feishu.cn/admin
|
||||
应用管理 https://open.feishu.cn/app
|
||||
`
|
||||
qrcode `https://applink.feishu.cn/client/bot/open?appId=cli_9d3b9d146a7cd103`
|
||||
|
||||
chapter "应用"
|
||||
field "app" web.chat.lark.app
|
||||
field "group" web.chat.lark.group
|
||||
field "company" web.chat.lark.company
|
||||
field "duty" web.chat.lark.duty
|
||||
field "应用" web.chat.lark.app
|
||||
field "群组" web.chat.lark.group
|
||||
field "组织" web.chat.lark.company
|
||||
field "值班" web.chat.lark.duty
|
||||
|
||||
chapter "权限"
|
||||
field sess aaa.sess
|
||||
field user aaa.user
|
||||
field "共享" web.share
|
||||
field "会话" aaa.sess
|
||||
field "用户" aaa.user
|
||||
|
||||
chapter "项目"
|
||||
field "icebergs" web.code.git.trend args `icebergs`
|
||||
|
@ -60,7 +60,7 @@ func init() {
|
||||
|
||||
if _send_text(m, form, arg...) {
|
||||
msg := _lark_post(m, appid, "/open-apis/message/v4/send/", web.SPIDE_DATA, kit.Format(form))
|
||||
m.Push("time", m.Time())
|
||||
m.Push(kit.MDB_TIME, m.Time())
|
||||
m.Push("message_id", msg.Append("data.message_id"))
|
||||
}
|
||||
}},
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -24,7 +25,13 @@ func init() {
|
||||
}
|
||||
|
||||
// 执行命令
|
||||
if m.Cmdy(cmds); len(m.Resultv()) > 0 {
|
||||
if m.Cmdy(cmds); m.Result() != "" && m.Result(1) != ice.ErrNotFound {
|
||||
m.Cmd(SEND, m.Option(APP_ID), m.Option(OPEN_CHAT_ID), m.Result())
|
||||
return
|
||||
}
|
||||
if m.Length() == 0 {
|
||||
m.Set(ice.MSG_RESULT)
|
||||
m.Cmdy(cli.SYSTEM, cmds)
|
||||
m.Cmd(SEND, m.Option(APP_ID), m.Option(OPEN_CHAT_ID), m.Result())
|
||||
return
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user