MCPcopy Create free account
hub / github.com/YouChenJun/Keydd / sendMsg

Function sendMsg

notify/feishu.go:19–45  ·  view source on GitHub ↗
(cardtext string)

Source from the content-addressed store, hash-verified

17 fmt.Println("webhook", webhookUrl)
18}
19func sendMsg(cardtext string) {
20 // json
21 contentType := "application/json"
22 //这里是需要构造发送的数据
23 data := `{
24 "msg_type": "interactive",
25 "card": %s
26 }
27 `
28 sendData := fmt.Sprintf(data, cardtext)
29 // request
30 if webhookUrl == "" {
31 return
32 }
33 result, err := http.Post(webhookUrl, contentType, strings.NewReader(sendData))
34 if err != nil {
35 fmt.Printf("post failed, err:%v\n", err)
36 return
37 }
38 defer result.Body.Close()
39 rspBody, err := ioutil.ReadAll(result.Body)
40 if err != nil {
41 logger.Error.Fatalf("ReadAll failed, reqBody: %s, err: %v\n", rspBody, err)
42 return
43 }
44 time.Sleep(1 * time.Second)
45}
46
47func TaskBeginSendmsg(info *consts.Keyinfo) {
48 cardtext := `

Callers 1

TaskBeginSendmsgFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected