+ CorpAsyncSendMarkdown
This commit is contained in:
@@ -7,6 +7,17 @@ const (
|
|||||||
MaxWorkContentLen = MaxWorkMsgLen - 96
|
MaxWorkContentLen = MaxWorkMsgLen - 96
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
MsgTyeText = "txt"
|
||||||
|
MsgTypeImage = "image"
|
||||||
|
MsgTypeVoice = "voice"
|
||||||
|
MsgTypeFile = "file"
|
||||||
|
MsgTypeLink = "link"
|
||||||
|
MsgTypeOA = "oa"
|
||||||
|
MsgTypeMarkdown = "markdown"
|
||||||
|
MsgTypeActionCard = "action_card"
|
||||||
|
)
|
||||||
|
|
||||||
func (a *API) CorpAsyncSend(userIDList, deptIDList []string, isToAllUser bool, msg map[string]interface{}) (err error) {
|
func (a *API) CorpAsyncSend(userIDList, deptIDList []string, isToAllUser bool, msg map[string]interface{}) (err error) {
|
||||||
params := map[string]interface{}{
|
params := map[string]interface{}{
|
||||||
"agent_id": a.agentID,
|
"agent_id": a.agentID,
|
||||||
@@ -33,3 +44,13 @@ func (a *API) CorpAsyncSendSimple(userID, content string) (err error) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *API) CorpAsyncSendMarkdown(userIDList, deptIDList []string, isToAllUser bool, title, content string) (err error) {
|
||||||
|
return a.CorpAsyncSend(userIDList, deptIDList, isToAllUser, map[string]interface{}{
|
||||||
|
"msgtype": "markdown",
|
||||||
|
"markdown": map[string]interface{}{
|
||||||
|
"title": title,
|
||||||
|
"text": content,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
package dingdingapi
|
package dingdingapi
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func TestCorpAsyncSend(t *testing.T) {
|
func TestCorpAsyncText(t *testing.T) {
|
||||||
err := api.CorpAsyncSend([]string{
|
err := api.CorpAsyncSend([]string{
|
||||||
"051063452224284964",
|
"142239066635627505", // 老赵
|
||||||
|
// "051063452224284964", // 我
|
||||||
}, nil, false, map[string]interface{}{
|
}, nil, false, map[string]interface{}{
|
||||||
"msgtype": "text",
|
"msgtype": "text",
|
||||||
"text": map[string]interface{}{
|
"text": map[string]interface{}{
|
||||||
"content": `
|
"content": fmt.Sprintf("http://www.jxc4.com/billshow/?path=%s", "http://image.jxc4.com/export/store_status_15984166050_20190716T180128.xlsx"),
|
||||||
管理用户列表或角色列表。 Casbin 认为由项目自身来管理用户、角色列表更为合适, 用户通常有他们的密码,但是 Casbin 的设计思想并不是把它作为一个存储密码的容器。 而是存储RBAC方案中用户和角色之间的映射关系。
|
|
||||||
`,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -18,6 +21,68 @@ func TestCorpAsyncSend(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCorpAsyncLink(t *testing.T) {
|
||||||
|
|
||||||
|
err := api.CorpAsyncSend([]string{
|
||||||
|
"051063452224284964",
|
||||||
|
}, nil, false, map[string]interface{}{
|
||||||
|
"msgtype": "link",
|
||||||
|
"link": map[string]interface{}{
|
||||||
|
"title": "门店状态报警",
|
||||||
|
"text": `
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
|
||||||
|
2019-07-16T18:34:28.225+0800 DEBUG
|
||||||
|
platformapi/platformapi.go:102 begin AccessPlatfor
|
||||||
|
mAPIWithRetry:49E6357AA7B511E9B6B2186590E02977 do:GE
|
||||||
|
T url:https://oapi.dingtalk.com/gettoken?appsecret=1zooB4bmEX
|
||||||
|
Pesdwb1ElWASVQ1vinOSZM-1XCUFrrSjHsNAId1UuVCT5tmHSmg5_V&appkey=dingpx4hcf55zb4ubewg
|
||||||
|
2019-07-16T18:34:28.721+0800 DEBUG platfor
|
||||||
|
mapi/platformapi.go:104 end AccessPlatformAPIWithRetry:49E63
|
||||||
|
57AA7B511E9B6B2186590E02977 do url:https://oapi.dingtalk.com/gettoken?
|
||||||
|
`,
|
||||||
|
"messageUrl": fmt.Sprintf("dingtalk://dingtalkclient/page/link?url=%s&pc_slide=true", url.QueryEscape("http://image.jxc4.com/export/store_status_15984166050_20190716T180128.xlsx")),
|
||||||
|
"picUrl": "http://cms-bucket.ws.126.net/2019/07/16/2d5a5498da2e45b28acc8c185015e6e6.jpeg?imageView&thumbnail=453y225&quality=85",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCorpAsyncSendMarkdown(t *testing.T) {
|
||||||
|
err := api.CorpAsyncSendMarkdown([]string{
|
||||||
|
"051063452224284964",
|
||||||
|
}, nil, false, "首屏会话透出的展示内容", `
|
||||||
|
## 门店: 邻里店(101949)
|
||||||
|
- 城市: 南宁市
|
||||||
|
- 平台: 京东到家
|
||||||
|
- 平台ID: 11765547
|
||||||
|
- 之前状态: 营业中
|
||||||
|
- 当前状态: 长期休息
|
||||||
|
- 之前营业时间: 09:30-23:30
|
||||||
|
- 当前营业时间: 09:30-23:30
|
||||||
|
|
||||||
|
## 门店: 平西店(101677)
|
||||||
|
- 城市: 南宁市
|
||||||
|
- 平台: 京东到家
|
||||||
|
- 平台ID: 11765538
|
||||||
|
- 之前状态: 营业中
|
||||||
|
- 当前状态: 长期休息
|
||||||
|
- 之前营业时间: 08:00-19:30
|
||||||
|
- 当前营业时间: 08:00-19:30
|
||||||
|
[详情点我](http://www.jxc4.com/billshow/?normal=true&path=http://image.jxc4.com/export/store_status_13206278888_20190717T091545.xlsx)..
|
||||||
|
`)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCorpAsyncSendSimple(t *testing.T) {
|
func TestCorpAsyncSendSimple(t *testing.T) {
|
||||||
err := api.CorpAsyncSendSimple("051063452224284964", `
|
err := api.CorpAsyncSendSimple("051063452224284964", `
|
||||||
管理用户列表或角色列表。 Casbinadfs 认为由项目自身来管理用户、角色列表更为合适, 用户通常有他们的密码,但是 Casbin 的设计思想并不是把它作为一个存储密码的容器。 而是存储RBAC方案中用户和角色之间的映射关系。
|
管理用户列表或角色列表。 Casbinadfs 认为由项目自身来管理用户、角色列表更为合适, 用户通常有他们的密码,但是 Casbin 的设计思想并不是把它作为一个存储密码的容器。 而是存储RBAC方案中用户和角色之间的映射关系。
|
||||||
|
|||||||
Reference in New Issue
Block a user