Documentation
¶
Index ¶
- func FeishuCustomBotGenSign(secret string, timestamp int64) (string, error)
- func FeishuSendCommMsg(alert *dropbox.AlertPostCommApi, feishuTag string) error
- func FeishuSendCommMsgV1(alert *dropbox.CommonAlert, groups []interface{}) []error
- type FeishuCustomBotComm
- type FeishuCustomBotCommV1
- type FeishuCustomBotPostMsg
- type FeishuCustomBotPostMsgContent
- type FeishuCustomBotPostMsgTemplate
- type FeishuCustomBotPostMsgText
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FeishuCustomBotGenSign ¶
飞书自定义机器人的签名
func FeishuSendCommMsg ¶
func FeishuSendCommMsg(alert *dropbox.AlertPostCommApi, feishuTag string) error
func FeishuSendCommMsgV1 ¶
func FeishuSendCommMsgV1(alert *dropbox.CommonAlert, groups []interface{}) []error
Types ¶
type FeishuCustomBotComm ¶
type FeishuCustomBotComm struct {
Timestamp string `json:"timestamp,omitempty"`
Sign string `json:"sign,omitempty"`
MsgType string `json:"msg_type"`
Content *FeishuCustomBotPostMsg `json:"content"`
}
{
"msg_type": "post",
"content": {
"post": {
"zh_cn": {
"title": "项目更新通知",
"content": [
[
{
"tag": "text",
"text": "项目有更新: "
}
]
]
}
}
}
}
func CommAlertToFeishuPostTemplate ¶
func CommAlertToFeishuPostTemplate(alertComm *dropbox.AlertPostCommApi) *FeishuCustomBotComm
func (*FeishuCustomBotComm) CommSendPostMsg ¶
func (feishu *FeishuCustomBotComm) CommSendPostMsg(url string) (string, error)
func (*FeishuCustomBotComm) FeishuCustomBotSignature ¶
func (feishu *FeishuCustomBotComm) FeishuCustomBotSignature(secret string) error
type FeishuCustomBotCommV1 ¶
type FeishuCustomBotCommV1 struct {
Timestamp string `json:"timestamp,omitempty"`
Sign string `json:"sign,omitempty"`
MsgType string `json:"msg_type"`
Content string `json:"content"`
}
{
"msg_type": "post",
"content": {
"post": {
"zh_cn": {
"title": "项目更新通知",
"content": [
[
{
"tag": "text",
"text": "项目有更新: "
}
]
]
}
}
}
}
func (*FeishuCustomBotCommV1) CommSendPostMsg ¶
func (feishu *FeishuCustomBotCommV1) CommSendPostMsg(url string) (string, error)
func (*FeishuCustomBotCommV1) FeishuCustomBotSignature ¶
func (feishu *FeishuCustomBotCommV1) FeishuCustomBotSignature(secret string) error
// 飞书自定义机器人的签名
func FeishuCustomBotGenSign(secret string, timestamp int64) (string, error) {
//timestamp + key 做sha256, 再进行base64 encode
stringToSign := fmt.Sprintf("%v", timestamp) + "\n" + secret
var data []byte
h := hmac.New(sha256.New, []byte(stringToSign))
_, err := h.Write(data)
if err != nil {
return "", err
}
signature := base64.StdEncoding.EncodeToString(h.Sum(nil))
return signature, nil
}
type FeishuCustomBotPostMsg ¶
type FeishuCustomBotPostMsg struct {
Post map[string]*FeishuCustomBotPostMsgContent `json:"post"`
}
type FeishuCustomBotPostMsgContent ¶
type FeishuCustomBotPostMsgContent struct {
Title string `json:"title"`
Content []*FeishuCustomBotPostMsgTemplate `json:"content"`
}
type FeishuCustomBotPostMsgTemplate ¶
type FeishuCustomBotPostMsgTemplate []*FeishuCustomBotPostMsgText
Click to show internal directories.
Click to hide internal directories.