Documentation
¶
Overview ¶
testkit 包提供插件单元测试用的轻量 AnyBot 运行时。
Index ¶
- Variables
- func InstallConfig[T any](app *App, definition sdk.DefinitionOf[T], config T) error
- func Message(text string, opts ...EventOption) *sdk.Event
- type App
- func (app *App) Client() *Client
- func (app *App) Dispatch(ctx context.Context, event *sdk.Event) error
- func (app *App) DispatchText(text string, opts ...EventOption) error
- func (app *App) Install(plugins ...sdk.Plugin) error
- func (app *App) InstallDefault(definitions ...sdk.Definition) error
- func (app *App) LastReplyText() string
- func (app *App) Runtime() *sdk.App
- type Client
- type EventOption
- func FromUser(id string) EventOption
- func InGroup(id string) EventOption
- func Mention(id string) EventOption
- func MentionSelf() EventOption
- func WithGroupRole(role string) EventOption
- func WithMessage(chain message.Chain) EventOption
- func WithProtocol(protocol sdk.Protocol) EventOption
- func WithSelfID(id string) EventOption
- type Option
- type SentMessage
Constants ¶
This section is empty.
Variables ¶
ErrAppUnavailable 表示测试运行时不可用。
Functions ¶
func InstallConfig ¶
func InstallConfig[T any](app *App, definition sdk.DefinitionOf[T], config T) error
InstallConfig 使用给定 typed config 安装插件定义。
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App 是插件测试用运行时,记录插件通过 Reply 或 Send 发出的消息。
func (*App) DispatchText ¶
func (app *App) DispatchText(text string, opts ...EventOption) error
DispatchText 投递一条消息事件。
func (*App) InstallDefault ¶
func (app *App) InstallDefault(definitions ...sdk.Definition) error
InstallDefault 用插件默认配置安装插件定义。
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 是记录发送消息的测试动作客户端。
type EventOption ¶
EventOption 调整测试事件。
func WithGroupRole ¶ added in v1.2.0
func WithGroupRole(role string) EventOption
WithGroupRole 设置群消息发送者的标准群角色。
func WithMessage ¶
func WithMessage(chain message.Chain) EventOption
WithMessage 设置完整消息链,并同步 Text 为消息链中的纯文本内容。
type Option ¶
type Option func(*options)
Option 调整测试运行时。
func WithConfigStore ¶
func WithConfigStore(store sdk.ConfigStore) Option
WithConfigStore 配置测试插件配置写回存储。
type SentMessage ¶
type SentMessage struct {
Target sdk.ReplyTarget
Chain message.Chain
}
SentMessage 是测试客户端记录到的一条发送消息。
Click to show internal directories.
Click to hide internal directories.