diff --git a/message.go b/message.go index a51729e..b638596 100644 --- a/message.go +++ b/message.go @@ -231,14 +231,16 @@ func (c *WorkwxApp) sendMessage( } req := reqMessage{ - ToUser: recipient.UserIDs, - ToParty: recipient.PartyIDs, - ToTag: recipient.TagIDs, - ChatID: recipient.ChatID, - AgentID: c.AgentID, - MsgType: msgtype, - Content: content, - IsSafe: isSafe, + ToUser: recipient.UserIDs, + ToParty: recipient.PartyIDs, + ToTag: recipient.TagIDs, + ChatID: recipient.ChatID, + AgentID: c.AgentID, + Code: recipient.Code, + OpenKfID: recipient.OpenKfID, + MsgType: msgtype, + Content: content, + IsSafe: isSafe, } resp, err := sendRequestFunc(req) diff --git a/models.go b/models.go index 4bb83ed..1e83e18 100644 --- a/models.go +++ b/models.go @@ -93,14 +93,16 @@ type respJSAPITicket struct { // reqMessage 消息发送请求 type reqMessage struct { - ToUser []string - ToParty []string - ToTag []string - ChatID string - AgentID int64 - MsgType string - Content map[string]interface{} - IsSafe bool + ToUser []string + ToParty []string + ToTag []string + ChatID string + AgentID int64 + OpenKfID string + Code string + MsgType string + Content map[string]interface{} + IsSafe bool } var _ bodyer = reqMessage{} @@ -129,6 +131,12 @@ func (x reqMessage) intoBody() ([]byte, error) { if x.ChatID != "" { obj["chatid"] = x.ChatID } else { + if x.Code != "" { + obj["code"] = x.Code + } else if x.OpenKfID != "" { + obj["open_kfid"] = x.OpenKfID + } + obj["touser"] = strings.Join(x.ToUser, "|") obj["toparty"] = strings.Join(x.ToParty, "|") obj["totag"] = strings.Join(x.ToTag, "|")