feishu

package
v0.0.0-...-c7c2aa6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

预定义错误

Functions

This section is empty.

Types

type BotClient

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

飞书机器人客户端

func (BotClient) Send

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

Send 方法发送信息。 目前只支持文本信息。信息内容需要包含指定关键字。

func (BotClient) SendText

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

SendText 方法发送文本信息。 目前只支持文本信息。信息内容需要包含指定关键字。

type Message

type Message struct {
	MsgType MessageType `json:"msg_type"` // 信息类型
	Content any         `json:"content"`  // 信息内容
}

信息

type MessageType

type MessageType = string

信息类型

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

type SendResponse

type SendResponse[T any] struct {
	Code int    `json:"code"` // 响应码。非 0 为异常。
	Data T      `json:"data"` // 返回数据
	Msg  string `json:"msg"`  // 异常信息
}

发送响应

type TextMessage

type TextMessage struct {
	Text string `json:"text"` // 文本内容
}

文本信息

Jump to

Keyboard shortcuts

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