wx

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNeedToken = errors.New("wx: need token") // 需要提供令牌
)

预定义错误

Functions

This section is empty.

Types

type BotClient

type BotClient struct {
	Client  *http.Client // 底层 http client。不填则使用默认值。
	Logger  *slog.Logger // 日志 logger。不填则使用默认值。
	BaseURL string       // 接口基础地址。不填则使用默认值。
	Key     string       // 机器人令牌。
}

企业微信机器人客户端

func (BotClient) Send

func (c BotClient) Send(ctx context.Context, msg Message) error

方法发送信息。 目前只支持文本信息。

func (BotClient) SendMarkdown

func (c BotClient) SendMarkdown(ctx context.Context, msg string) error

发送 Markdown 信息。

func (BotClient) SendText

func (c BotClient) SendText(ctx context.Context, msg string) error

方法发送文本信息。 目前只支持文本信息。

type MarkdownMessage

type MarkdownMessage struct {
	Content string `json:"content"` // 是	markdown内容,最长不超过4096个字节,必须是utf8编码
}

markdown 信息

type Message

type Message struct {
	MsgType  MessageType      `json:"msgtype"`            // 信息类型
	Text     *TextMessage     `json:"text,omitempty"`     // 文本信息
	Markdown *MarkdownMessage `json:"markdown,omitempty"` // markdown 信息
}

信息

type MessageType

type MessageType = string

信息类型

const (
	MessageTypeText     MessageType = "text"     // 文本信息类型
	MessageTypeMarkdown MessageType = "markdown" // markdown 信息类型
)

type SendResponse

type SendResponse struct {
	ErrCode int    `json:"errcode"` // 错误码
	ErrMsg  string `json:"errmsg"`  // 错误说明
}

发送响应

type TextMessage

type TextMessage struct {
	Content             string   `json:"content"`                         // 是	文本内容,最长不超过2048个字节,必须是utf8编码
	MentionedList       []string `json:"mentioned_list,omitempty"`        // 否	user id 的列表,提醒群中的指定成员(@某个成员),@all 表示提醒所有人,如果开发者获取不到 user id,可以使用 mentioned_mobile_list
	MentionedMobileList []string `json:"mentioned_mobile_list,omitempty"` // 否	手机号列表,提醒手机号对应的群成员(@某个成员),@all 表示提醒所有人
}

文本信息

Jump to

Keyboard shortcuts

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