custom_bot

package
v0.0.0-...-efd361b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2021 License: LGPL-2.1 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FeishuCustomBotGenSign

func FeishuCustomBotGenSign(secret string, timestamp int64) (string, error)

飞书自定义机器人的签名

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

type FeishuCustomBotPostMsgText

type FeishuCustomBotPostMsgText struct {
	Tag  string `json:"tag"`
	Text string `json:"text"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL