提交 c4ad9f1e 编写于 作者: U Ulric Qin

refactor wechat sender

上级 84559941
......@@ -12,8 +12,8 @@ import (
"github.com/didi/nightingale/src/common/dataobj"
"github.com/didi/nightingale/src/modules/rdb/config"
"github.com/didi/nightingale/src/modules/rdb/corp"
"github.com/didi/nightingale/src/modules/rdb/redisc"
"github.com/didi/nightingale/src/modules/rdb/wechat"
)
func ConsumeIm() {
......@@ -83,13 +83,17 @@ func sendImByWeChat(message *dataobj.Message) {
return
}
client := corp.New(corpID, agentID, secret)
client := wechat.New(corpID, agentID, secret)
var err error
for i := 0; i < cnt; i++ {
err = client.Send(corp.Message{
ToUser: message.Tos[i],
toUser := strings.TrimSpace(message.Tos[i])
if toUser == "" {
continue
}
err = client.Send(wechat.Message{
ToUser: toUser,
MsgType: "text",
Text: corp.Content{Content: message.Content},
Text: wechat.Content{Content: message.Content},
})
if err != nil {
......
package corp
package wechat
import (
"bytes"
......@@ -56,11 +56,11 @@ type Message struct {
}
// New 实例化微信企业号应用
func New(corpID string, agentID int, AgentSecret string) *Client {
func New(corpID string, agentID int, agentSecret string) *Client {
c := new(Client)
c.CorpID = corpID
c.AgentID = agentID
c.AgentSecret = AgentSecret
c.AgentSecret = agentSecret
return c
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册