message

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

message 包定义 AnyBot 的协议中立消息链。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain []Segment

Chain 是按顺序排列的协议中立消息段。

func New

func New(segments ...Segment) Chain

New 根据消息段构造新的消息链。

func (Chain) Append

func (c Chain) Append(segments ...Segment) Chain

Append 返回追加消息段后的新消息链,不修改原链。

func (Chain) Clone

func (c Chain) Clone() Chain

Clone 返回消息链副本,避免异步观察者和处理链共享可变段数据。

func (Chain) IsZero

func (c Chain) IsZero() bool

IsZero 判断消息链是否为空。

func (Chain) MarshalJSON

func (c Chain) MarshalJSON() ([]byte, error)

MarshalJSON 将 nil 消息链编码为空数组,便于适配器直接作为消息参数传递。

func (Chain) Text

func (c Chain) Text() string

Text 返回所有文本消息段按顺序拼接后的内容。

type Segment

type Segment struct {
	Type string         `json:"type"`
	Data map[string]any `json:"data,omitempty"`
}

Segment 表示一个协议中立的消息段。

func Image

func Image(file string) Segment

Image 创建图片消息段,file 通常为 URL、file URI 或协议端可识别的路径。

func Raw

func Raw(kind string, data map[string]any) Segment

Raw 创建带自定义类型和数据的消息段,供适配器或协议扩展使用。

func Text

func Text(text string) Segment

Text 创建纯文本消息段。

func Video

func Video(file string) Segment

Video 创建视频消息段。

Jump to

Keyboard shortcuts

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