pkg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedMessage = errors.New("尚不支持的消息类型")
)

Functions

func ContainsInSlice

func ContainsInSlice(items []string, item string) bool

ContainsInSlice 判断字符串是否在 slice 中

func GreenColor

func GreenColor(s interface{}) string

func JsonToMap

func JsonToMap(str string) map[string]interface{}

func RedColor

func RedColor(s interface{}) string

func YellowColor

func YellowColor(s interface{}) string

Types

type APIError

type APIError struct {
	Code   int         `json:"code"`
	Data   interface{} `json:"data,omitempty"`
	Msg    string      `json:"msg"`
	Errors []struct {
		Resource string `json:"resource"`
		Field    string `json:"field"`
		Code     string `json:"code"`
	} `json:"errors,omitempty"`
}

APIError represents the error message that GitHub API returns. GitHub API doc: https://docs.github.com/en/rest/overview/resources-in-the-rest-api#client-errors

func (*APIError) Error

func (e *APIError) Error() string

Error convert APIError to a human readable error and return.

type CMClient

type CMClient struct {
	*req.Client
	// contains filtered or unexported fields
}

GithubClient is the go client for GitHub API.

func NewReqClient

func NewReqClient() *CMClient

NewGithubClient create a GitHub client.

func (*CMClient) IsLogged

func (c *CMClient) IsLogged() bool

IsLogged return true is user is logged in, otherwise false.

func (*CMClient) LoginWithToken

func (c *CMClient) LoginWithToken(BearerAuthToken string) *CMClient

LoginWithToken login with GitHub personal access token.

func (*CMClient) SendImage

func (c *CMClient) SendImage(webhookurl, base64, md5 string) (*wxWorkResponse, error)

SendImage Send Image

func (*CMClient) SendMarkdown

func (c *CMClient) SendMarkdown(webhookurl, content string) (*wxWorkResponse, error)

SendMarkdown Send Markdown

func (*CMClient) SendNews

func (c *CMClient) SendNews(webhookurl, title, description, url, picurl string) (*wxWorkResponse, error)

SendNews Send News

func (*CMClient) SendText

func (c *CMClient) SendText(webhookurl string, content string, mentioned_list []string, mentioned_mobile_list []string) (*wxWorkResponse, error)

SendText Send Text

func (*CMClient) SetDebug

func (c *CMClient) SetDebug(enable bool) *CMClient

SetDebug enable debug if set to true, disable debug if set to false.

type Image

type Image struct {
	Base64 string `json:"base64"`
	MD5    string `json:"md5"`
}

type Markdown

type Markdown struct {
	Content string `json:"content"`
}

type News

type News struct {
	Articles []NewsArticle `json:"articles"`
}

type NewsArticle

type NewsArticle struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	PicURL      string `json:"picurl"`
}

type Text

type Text struct {
	Content             string   `json:"content"`
	MentionedList       []string `json:"mentioned_list"`
	MentionedMobileList []string `json:"mentioned_mobile_list"`
}

type WxWorkBot

type WxWorkBot struct {
	Key        string
	WebHookUrl string
	Client     *http.Client
}

func New

func New(botKey string) *WxWorkBot

New 创建一个新的机器人实例

func (*WxWorkBot) Send

func (bot *WxWorkBot) Send(msg interface{}) error

发送消息,允许的参数类型:Text、Markdown、Image、News

Jump to

Keyboard shortcuts

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