mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt chat
This commit is contained in:
parent
3e2b607a37
commit
4b4506b16c
@ -64,9 +64,9 @@ const (
|
||||
SPIDE_BODY = "body"
|
||||
|
||||
SPIDE_CLIENT = "client"
|
||||
SPIDE_METHOD = "method"
|
||||
SPIDE_HEADER = "header"
|
||||
SPIDE_COOKIE = "cookie"
|
||||
SPIDE_METHOD = "method"
|
||||
|
||||
ContentType = "Content-Type"
|
||||
ContentLength = "Content-Length"
|
||||
|
@ -50,6 +50,7 @@ var Index = &ice.Context{Name: CHAT, Help: "聊天中心",
|
||||
"scan", []interface{}{
|
||||
"web.chat.scan",
|
||||
"web.chat.paste",
|
||||
"web.chat.files",
|
||||
"web.chat.location",
|
||||
"web.chat.meet.miss",
|
||||
"web.wiki.feel",
|
||||
|
@ -12,21 +12,21 @@ const FILES = "files"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Configs: map[string]*ice.Config{
|
||||
FILES: {Name: FILES, Help: "文件", Value: kit.Data(kit.MDB_SHORT, "data")},
|
||||
FILES: {Name: FILES, Help: "文件", Value: kit.Data(kit.MDB_SHORT, kit.MDB_DATA)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
FILES: {Name: "files hash auto upload", Help: "扫码", Action: map[string]*ice.Action{
|
||||
web.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||
up := kit.Simple(m.Optionv(ice.MSG_UPLOAD))
|
||||
m.Cmdy(mdb.INSERT, FILES, "", mdb.HASH, "data", up[0], kit.MDB_NAME, up[1])
|
||||
m.Cmdy(mdb.INSERT, FILES, "", mdb.HASH, kit.MDB_NAME, up[1], kit.MDB_TYPE, kit.Ext(up[1]), kit.MDB_DATA, up[0])
|
||||
}},
|
||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.DELETE, FILES, "", mdb.HASH, kit.MDB_HASH, m.Option(kit.MDB_HASH))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Option(mdb.FIELDS, kit.Select("time,hash,name,data", mdb.DETAIL, len(arg) > 0))
|
||||
m.Option(mdb.FIELDS, kit.Select("time,hash,type,name,data", mdb.DETAIL, len(arg) > 0))
|
||||
m.Cmd(mdb.SELECT, cmd, "", mdb.HASH, kit.MDB_HASH, arg).Table(func(index int, value map[string]string, head []string) {
|
||||
m.Push("", value, kit.Split(kit.Select("time,hash,name", "time,name", len(arg) > 0)))
|
||||
m.Push("", value, kit.Split(kit.Select("time,hash,type,name", "time,type,name", len(arg) > 0)))
|
||||
|
||||
if m.PushDownload(value[kit.MDB_NAME], "/share/cache/"+value[kit.MDB_DATA]); len(arg) > 0 {
|
||||
switch {
|
||||
|
@ -40,13 +40,11 @@ func init() {
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
LOCATION: {Name: "location hash auto getLocation", Help: "地理位置", Action: map[string]*ice.Action{
|
||||
OPENLOCATION: {Name: "create type=text name address latitude longitude", Help: "地图", Hand: func(m *ice.Message, arg ...string) {}},
|
||||
GETLOCATION: {Name: "getLocation", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
_trans(arg, map[string]string{ADDRESS: "text"})
|
||||
OPENLOCATION: {Name: "openLocation", Help: "地图", Hand: func(m *ice.Message, arg ...string) {}},
|
||||
GETLOCATION: {Name: "getLocation", Help: "打卡", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.INSERT, LOCATION, "", mdb.HASH, arg)
|
||||
}},
|
||||
mdb.CREATE: {Name: "create type=text name address latitude longitude", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
_trans(arg, map[string]string{ADDRESS: "text"})
|
||||
mdb.CREATE: {Name: "create type=text name text latitude longitude", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(mdb.INSERT, LOCATION, "", mdb.HASH, arg)
|
||||
}},
|
||||
mdb.MODIFY: {Name: "modify", Help: "编辑", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -23,7 +23,8 @@ func init() {
|
||||
_wiki_upload(m, FEEL, m.Option(kit.MDB_PATH))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
_wiki_list(m, FEEL, kit.Select("./", arg, 0))
|
||||
if !_wiki_list(m, FEEL, kit.Select("./", arg, 0)) {
|
||||
}
|
||||
}},
|
||||
},
|
||||
})
|
||||
|
3
misc.go
3
misc.go
@ -212,6 +212,9 @@ func (m *Message) EchoButton(arg ...string) *Message {
|
||||
func (m *Message) EchoScript(arg ...string) *Message {
|
||||
return m.Echo(_render(m, RENDER_SCRIPT, arg))
|
||||
}
|
||||
func (m *Message) EchoImages(src string, arg ...string) *Message {
|
||||
return m.Echo(_render(m, RENDER_IMAGES, src, arg))
|
||||
}
|
||||
func (m *Message) EchoQRCode(text string, arg ...string) *Message { // text [size]
|
||||
return m.Echo(_render(m, RENDER_QRCODE, text, arg))
|
||||
}
|
||||
|
@ -26,10 +26,10 @@ func _lark_post(m *ice.Message, bot string, arg ...interface{}) *ice.Message {
|
||||
return m.Cmd(web.SPIDE, LARK, arg)
|
||||
}
|
||||
func _lark_parse(m *ice.Message) {
|
||||
data := m.Optionv("content_data")
|
||||
data := m.Optionv(ice.MSG_USERDATA)
|
||||
if data == nil {
|
||||
json.NewDecoder(m.R.Body).Decode(&data)
|
||||
m.Optionv("content_data", data)
|
||||
m.Optionv(ice.MSG_USERDATA, data)
|
||||
|
||||
switch d := data.(type) {
|
||||
case map[string]interface{}:
|
||||
@ -41,7 +41,7 @@ func _lark_parse(m *ice.Message) {
|
||||
}
|
||||
default:
|
||||
for _, v := range kit.Simple(v) {
|
||||
m.Add(ice.MSG_OPTION, "msg."+k, kit.Format(v))
|
||||
m.Add(ice.MSG_OPTION, kit.Keys("msg", k), kit.Format(v))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -87,18 +87,17 @@ const LARK = "lark"
|
||||
var Index = &ice.Context{Name: LARK, Help: "机器人",
|
||||
Configs: map[string]*ice.Config{
|
||||
APP: {Name: APP, Help: "服务配置", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME,
|
||||
LARK, "https://open.feishu.cn", DUTY, "", "template", kit.Dict(
|
||||
LARK, "https://open.feishu.cn", DUTY, "", kit.MDB_TEMPLATE, kit.Dict(
|
||||
ADD_BOT, "我来也~", P2P_CHAT_CREATE, "让我们做好朋友吧~",
|
||||
),
|
||||
)},
|
||||
COMPANY: {Name: COMPANY, Help: "组织配置", Value: kit.Data(kit.MDB_SHORT, SHIP_ID)},
|
||||
EMPLOYEE: {Name: EMPLOYEE, Help: "用户配置", Value: kit.Data(kit.MDB_SHORT, OPEN_ID)},
|
||||
EMPLOYEE: {Name: EMPLOYEE, Help: "员工配置", Value: kit.Data(kit.MDB_SHORT, OPEN_ID)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Load()
|
||||
m.Cmd(web.SPIDE, mdb.CREATE, LARK, m.Conf(APP, kit.Keys(kit.MDB_META, LARK)))
|
||||
// m.Cmd(DUTY, "boot", m.Conf(cli.RUNTIME, "boot.hostname"), m.Time())
|
||||
}},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Save()
|
||||
@ -149,7 +148,7 @@ var Index = &ice.Context{Name: LARK, Help: "机器人",
|
||||
msg := _lark_get(m, "bot", "/open-apis/contact/v1/scope/get/")
|
||||
kit.Fetch(kit.Value(msg.Optionv("content_data"), "data.authed_departments"), func(index int, value string) {
|
||||
m.Push(SHIP_ID, value)
|
||||
msg := m.Cmd(m.Prefix(COMPANY), "info", value)
|
||||
msg := m.Cmd(COMPANY, "info", value)
|
||||
m.Push(kit.MDB_NAME, msg.Append(kit.MDB_NAME))
|
||||
m.Push(kit.MDB_COUNT, msg.Append("member_count"))
|
||||
m.Push(CHAT_ID, msg.Append(CHAT_ID))
|
||||
@ -157,13 +156,13 @@ var Index = &ice.Context{Name: LARK, Help: "机器人",
|
||||
m.Sort(kit.MDB_NAME)
|
||||
|
||||
} else if len(arg) == 1 { // 员工列表
|
||||
m.Cmdy(m.Prefix(COMPANY), "list", arg[0])
|
||||
m.Cmdy(COMPANY, "list", arg[0])
|
||||
|
||||
} else if len(arg) == 2 { // 员工详情
|
||||
m.Cmdy(EMPLOYEE, arg[1])
|
||||
|
||||
} else { // 员工通知
|
||||
m.Cmdy(m.Prefix(SEND), OPEN_ID, arg[1], arg[2:])
|
||||
m.Cmdy(SEND, OPEN_ID, arg[1], arg[2:])
|
||||
}
|
||||
}},
|
||||
EMPLOYEE: {Name: "employee open_id|mobile|email auto", Help: "员工", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
@ -213,13 +212,13 @@ var Index = &ice.Context{Name: LARK, Help: "机器人",
|
||||
m.Sort(kit.MDB_NAME)
|
||||
|
||||
} else if len(arg) == 1 { // 组员列表
|
||||
m.Cmdy(m.Prefix(GROUP), "list", arg[0])
|
||||
m.Cmdy(GROUP, "list", arg[0])
|
||||
|
||||
} else if len(arg) == 2 { // 组员详情
|
||||
m.Cmdy(EMPLOYEE, arg[1])
|
||||
|
||||
} else { // 组员通知
|
||||
m.Cmdy(m.Prefix(SEND), CHAT_ID, arg[0], arg[2:])
|
||||
m.Cmdy(SEND, CHAT_ID, arg[0], arg[2:])
|
||||
}
|
||||
}},
|
||||
|
||||
@ -261,10 +260,10 @@ var Index = &ice.Context{Name: LARK, Help: "机器人",
|
||||
})
|
||||
}
|
||||
|
||||
_lark_post(m, "bot", "/open-apis/message/v4/send/", web.SPIDE_DATA, kit.Format(form))
|
||||
m.Copy(_lark_post(m, "bot", "/open-apis/message/v4/send/", web.SPIDE_DATA, kit.Format(form)))
|
||||
}},
|
||||
DUTY: {Name: "duty [title] text", Help: "通告", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
m.Cmdy(SEND, m.Conf(APP, "meta.duty"), arg)
|
||||
m.Cmdy(SEND, m.Conf(APP, kit.Keym(DUTY)), arg)
|
||||
}},
|
||||
HOME: {Name: "home river storm title", Help: "首页", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
name := kit.Select(m.Option(ice.MSG_USERNAME), m.Option(ice.MSG_USERNICK))
|
||||
@ -390,8 +389,7 @@ var Index = &ice.Context{Name: LARK, Help: "机器人",
|
||||
m.Echo(list[rand.Intn(len(list))])
|
||||
}},
|
||||
|
||||
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
}},
|
||||
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
||||
"/msg": {Name: "/msg", Help: "聊天消息", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||
data := m.Optionv(ice.MSG_USERDATA)
|
||||
if kit.Value(data, "action") != nil {
|
||||
|
@ -10,11 +10,8 @@ image qrcode `https://www.feishu.cn/`
|
||||
|
||||
chapter "应用"
|
||||
field "app" web.chat.lark.app
|
||||
field "company" web.chat.lark.company
|
||||
field "employee" web.chat.lark.employee
|
||||
field "group" web.chat.lark.group
|
||||
# field "send" web.chat.lark.send
|
||||
# field "duty" web.chat.lark.duty
|
||||
field "company" web.chat.lark.company
|
||||
|
||||
chapter "权限"
|
||||
field user aaa.user
|
||||
|
@ -27,8 +27,8 @@ var Index = &ice.Context{Name: MP, Help: "小程序",
|
||||
},
|
||||
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, WEIXIN, m.Conf(LOGIN, kit.Keys(kit.MDB_META, WEIXIN)))
|
||||
m.Load()
|
||||
m.Cmd(web.SPIDE, mdb.CREATE, WEIXIN, m.Conf(LOGIN, kit.Keys(kit.MDB_META, WEIXIN)))
|
||||
}},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Save()
|
||||
@ -61,11 +61,7 @@ var Index = &ice.Context{Name: MP, Help: "小程序",
|
||||
)
|
||||
}},
|
||||
chat.SCAN: {Name: "scan", Help: "扫码", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(web.SHARE) != "" && m.Option(chat.RIVER) != "" {
|
||||
m.Cmdy(chat.AUTH, mdb.INSERT)
|
||||
} else {
|
||||
m.Cmdy(chat.SCAN)
|
||||
}
|
||||
m.Cmdy(chat.SCAN)
|
||||
}},
|
||||
}},
|
||||
},
|
||||
|
@ -5,11 +5,12 @@ refer "" `
|
||||
文档 https://developers.weixin.qq.com/miniprogram/dev/api/
|
||||
源码 https://github.com/shylinux/icebergs/blob/master/misc/mp/mp.go
|
||||
`
|
||||
image qrcode `https://weixin.qq.com`
|
||||
image `/share/local/usr/image/gh_61ea404535e4_258.jpg`
|
||||
|
||||
chapter "应用"
|
||||
field scan web.chat.scan
|
||||
field paste web.chat.paste
|
||||
field files web.chat.files
|
||||
field location web.chat.location
|
||||
|
||||
chapter "权限"
|
||||
|
@ -28,7 +28,7 @@ func _wx_sign(m *ice.Message, nonce, stamp string) string {
|
||||
return hex.EncodeToString(b[:])
|
||||
}
|
||||
func _wx_config(m *ice.Message, nonce string) {
|
||||
m.Option(APPID, m.Conf(LOGIN, kit.Keys(kit.MDB_META, APPID)))
|
||||
m.Option(APPID, m.Conf(LOGIN, kit.Keym(APPID)))
|
||||
m.Option("signature", _wx_sign(m, m.Option("noncestr", nonce), m.Option("timestamp", kit.Format(time.Now().Unix()))))
|
||||
}
|
||||
|
||||
@ -100,8 +100,8 @@ const (
|
||||
WEIXIN = "weixin"
|
||||
)
|
||||
const (
|
||||
MENU = "menu"
|
||||
ACCESS = "access"
|
||||
MENU = "menu"
|
||||
)
|
||||
const WX = "wx"
|
||||
|
||||
@ -110,16 +110,25 @@ var Index = &ice.Context{Name: WX, Help: "公众号",
|
||||
LOGIN: {Name: LOGIN, Help: "认证", Value: kit.Data(
|
||||
WEIXIN, "https://api.weixin.qq.com", APPID, "", APPMM, "", TOKEN, "",
|
||||
kit.MDB_TEMPLATE, kit.Dict(kit.MDB_TEXT, text), MENU, []interface{}{
|
||||
kit.Dict(wiki.TITLE, "主页", wiki.SPARK, "点击进入", wiki.IMAGE, "https://shylinux.com/static/volcanos/favicon.ico", wiki.REFER, "https://shylinux.com"),
|
||||
kit.Dict(wiki.TITLE, "产品", wiki.SPARK, "工具", wiki.IMAGE, "https://shylinux.com/static/volcanos/favicon.ico", wiki.REFER, "https://shylinux.com?river=product"),
|
||||
kit.Dict(wiki.TITLE, "研发", wiki.SPARK, "工具", wiki.IMAGE, "https://shylinux.com/static/volcanos/favicon.ico", wiki.REFER, "https://shylinux.com?river=project"),
|
||||
kit.Dict(wiki.TITLE, "网站主页", wiki.SPARK, "点击进入", wiki.REFER, "https://shylinux.com",
|
||||
wiki.IMAGE, "https://shylinux.com/share/local/usr/publish/3f265cd2455053b68976bc63bdd432d4.jpeg",
|
||||
),
|
||||
kit.Dict(wiki.TITLE, "产品工具", wiki.SPARK, "点击进入", wiki.REFER, "https://shylinux.com?river=product",
|
||||
wiki.IMAGE, "https://shylinux.com/share/local/usr/publish/3f265cd2455053b68976bc63bdd432d4.jpeg",
|
||||
),
|
||||
kit.Dict(wiki.TITLE, "研发工具", wiki.SPARK, "点击进入", wiki.REFER, "https://shylinux.com?river=project",
|
||||
wiki.IMAGE, "https://shylinux.com/share/local/usr/publish/3f265cd2455053b68976bc63bdd432d4.jpeg",
|
||||
),
|
||||
kit.Dict(wiki.TITLE, "测试工具", wiki.SPARK, "点击进入", wiki.REFER, "https://shylinux.com?river=profile",
|
||||
wiki.IMAGE, "https://shylinux.com/share/local/usr/publish/3f265cd2455053b68976bc63bdd432d4.jpeg",
|
||||
),
|
||||
},
|
||||
)},
|
||||
},
|
||||
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, WEIXIN, m.Conf(LOGIN, kit.Keys(kit.MDB_META, WEIXIN)))
|
||||
m.Load()
|
||||
m.Cmd(web.SPIDE, mdb.CREATE, WEIXIN, m.Conf(LOGIN, kit.Keys(kit.MDB_META, WEIXIN)))
|
||||
}},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Save()
|
||||
@ -160,8 +169,8 @@ var Index = &ice.Context{Name: WX, Help: "公众号",
|
||||
CONFIG: {Name: "config", Help: "配置", Hand: func(m *ice.Message, arg ...string) {
|
||||
_wx_config(m, "some")
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
}},
|
||||
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Echo(m.Conf(LOGIN, kit.Keys(kit.MDB_META, APPID)))
|
||||
}},
|
||||
@ -176,7 +185,7 @@ var Index = &ice.Context{Name: WX, Help: "公众号",
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
kit.Fetch(m.Confv(LOGIN, kit.Keym(MENU)), func(index int, value map[string]interface{}) {
|
||||
m.Push("", value, kit.Split("title,spark,image,refer"))
|
||||
m.Push("", value, kit.Split("title,spark,refer,image"))
|
||||
})
|
||||
}},
|
||||
|
||||
@ -198,7 +207,7 @@ var Index = &ice.Context{Name: WX, Help: "公众号",
|
||||
aaa.UserLogin(m, m.Append("FromUserName"), "")
|
||||
|
||||
switch m.Option("MsgType") {
|
||||
case "event":
|
||||
case kit.MDB_EVENT:
|
||||
switch m.Option("Event") {
|
||||
case "subscribe": // 关注事件
|
||||
_wx_action(m.Cmdy(MENU, mdb.CREATE))
|
||||
|
@ -5,7 +5,7 @@ refer `
|
||||
文档 https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html
|
||||
源码 https://github.com/shylinux/icebergs/blob/master/misc/wx/wx.go
|
||||
`
|
||||
image qrcode `https://weixin.qq.com`
|
||||
image `/share/local/usr/image/qrcode_for_gh_1c21ed4eb46b_258.jpg`
|
||||
|
||||
chapter "应用"
|
||||
field scan web.chat.scan
|
||||
|
Loading…
x
Reference in New Issue
Block a user