napcat

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: 6 Imported by: 0

Documentation

Overview

napcat 包提供 NapCat 专属 OneBot v11 扩展动作的类型化辅助方法。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

API 包装 NapCat 扩展动作,并保留原始调用能力。

func New

func New(client Client) *API

New 创建 NapCat 扩展 API 客户端。

func (*API) Call

func (api *API) Call(ctx context.Context, action string, params any, out any) error

Call 调用 NapCat 动作,并将响应 data 解码到 out。

func (*API) CallRaw

func (api *API) CallRaw(ctx context.Context, action string, params any) (*onebot11.Response, error)

CallRaw 调用 NapCat 动作,并返回 OneBot v11 原始响应封套。

func (*API) DownloadFile

func (api *API) DownloadFile(ctx context.Context, url string, threadCount int, headers []string) (FileInfo, error)

DownloadFile 调用 NapCat download_file 扩展。

func (*API) GetFile

func (api *API) GetFile(ctx context.Context, fileID any) (FileInfo, error)

GetFile 调用 NapCat get_file 扩展。

func (*API) GetFriendMessageHistory

func (api *API) GetFriendMessageHistory(ctx context.Context, userID any, messageSeq any, count int) ([]MessageSummary, error)

GetFriendMessageHistory 调用 NapCat get_friend_msg_history 扩展。

func (*API) GetGroupMessageHistory

func (api *API) GetGroupMessageHistory(ctx context.Context, groupID any, messageSeq any, count int) ([]MessageSummary, error)

GetGroupMessageHistory 调用 NapCat get_group_msg_history 扩展。

func (*API) SetMessageEmojiLike

func (api *API) SetMessageEmojiLike(ctx context.Context, messageID any, emojiID any) error

SetMessageEmojiLike 调用 NapCat set_msg_emoji_like 扩展。

type Client added in v1.0.1

type Client interface {
	Call(context.Context, string, any, any) error
	CallRaw(context.Context, string, any) (*onebot11.Response, error)
}

Client 是 NapCat 扩展动作所需的 OneBot v11 调用能力。

type FileInfo

type FileInfo struct {
	File string `json:"file"`
	URL  string `json:"url,omitempty"`
	Name string `json:"name,omitempty"`
	Size int64  `json:"size,omitempty"`
}

FileInfo 描述 NapCat 文件下载或查询结果。

func (*FileInfo) UnmarshalJSON

func (f *FileInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON 兼容 NapCat 返回的数字或字符串形式文件大小。

type MessageSummary

type MessageSummary struct {
	MessageID  int64  `json:"message_id"`
	RealID     int64  `json:"real_id,omitempty"`
	Time       int64  `json:"time,omitempty"`
	UserID     int64  `json:"user_id,omitempty"`
	GroupID    int64  `json:"group_id,omitempty"`
	RawMessage string `json:"raw_message,omitempty"`
}

MessageSummary 是 NapCat 历史消息接口返回的紧凑消息结构。

func (*MessageSummary) UnmarshalJSON

func (m *MessageSummary) UnmarshalJSON(data []byte) error

UnmarshalJSON 兼容 NapCat 返回的数字或字符串形式 ID。

Jump to

Keyboard shortcuts

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