webhook.go
func (w *Webhook) SendActionCardMsg(title, content string, linkTitles, linkURLs []string, hideAvatar, btnOrientation bool) error {
	if len(linkTitles) == 0 || len(linkURLs) == 0 {
		return errors.New("链接参数不能为空")
	}
	if len(linkTitles) != len(linkURLs) {
		return errors.New("链接数量不匹配")
	}

	var strHideAvatar = "0"
	if hideAvatar {
		strHideAvatar = "1"
	}
	var strBtnOrientation = "0"
	if btnOrientation {
		strBtnOrientation = "1"
	}

	var btns []struct {
		Title     string `json:"title"`
		ActionURL string `json:"actionURL"`
	}

	for i := 0; i < len(linkTitles); i++ {
		btns = append(btns, struct {
			Title     string `json:"title"`
			ActionURL string `json:"actionURL"`
		}{
			Title:     linkTitles[i],
			ActionURL: linkURLs[i],
		})
	}

	return w.SendPayload(&Payload{
		MsgType: "actionCard",
		ActionCard: ActionCard{
			Text:           content,
			Title:          title,
			HideAvatar:     strHideAvatar,
			BtnOrientation: strBtnOrientation,
			Buttons:        btns,
		},
	})
}
func (w *Webhook) SendActionCardMsg(title, content string, linkTitles, linkURLs []string, hideAvatar, btnOrientation bool) error {
	if len(linkTitles) == 0 || len(linkURLs) == 0 {
		return errors.New("链接参数不能为空")
	}
	if len(linkTitles) != len(linkURLs) {
		return errors.New("链接数量不匹配")
	}

	var strHideAvatar = "0"
	if hideAvatar {
		strHideAvatar = "1"
	}
	var strBtnOrientation = "0"
	if btnOrientation {
		strBtnOrientation = "1"
	}

	var btns []struct {
		Title     string `json:"title"`
		ActionURL string `json:"actionURL"`
	}

	for i := 0; i < len(linkTitles); i++ {
		btns = append(btns, struct {
			Title     string `json:"title"`
			ActionURL string `json:"actionURL"`
		}{
			Title:     linkTitles[i],
			ActionURL: linkURLs[i],
		})
	}

	return w.SendPayload(&Payload{
		MsgType: "actionCard",
		ActionCard: ActionCard{
			Text:           content,
			Title:          title,
			HideAvatar:     strHideAvatar,
			BtnOrientation: strBtnOrientation,
			Buttons:        btns,
		},
	})
}
func ( w * Webhook ) SendActionCardMsg ( title , content string , linkTitles , linkURLs [ ] string , hideAvatar , btnOrientation bool ) error { if len ( linkTitles ) == 0 || len ( linkURLs ) == 0 { return errors . New ( " } if len ( linkTitles ) != len ( linkURLs ) { return errors . New ( " } var strHideAvatar = " " if hideAvatar { strHideAvatar = " " } var strBtnOrientation = " " if btnOrientation { strBtnOrientation = " " } var btns [ ] struct { Title string `json:"title"` ActionURL string `json:"actionURL"` } for i := 0 ; i < len ( linkTitles ) ; i ++ { btns = append ( btns , struct { Title string `json:"title"` ActionURL string `json:"actionURL"` } { Title : linkTitles [ i ] , ActionURL : linkURLs [ i ] , } ) } return w . SendPayload ( & Payload { MsgType : " " , ActionCard : ActionCard { Text : content , Title : title , HideAvatar : strHideAvatar , BtnOrientation : strBtnOrientation , Buttons : btns , } , } ) }
// SendActionCardMsg 独立跳转ActionCard类型
SendActionCardMsg 独立跳转ActionCard类型