Documentation
¶
Overview ¶
onebot11 包提供 AnyBot 的 OneBot v11 适配器、消息段构造器和类型化动作客户端。
插件只需要回复消息时应优先使用 sdk 的协议无关消息能力;需要群管、文件、 好友列表等 OneBot v11 专属动作时,可以在 SDK 事件处理函数中调用 ClientFrom(c) 或 EventFrom(c) 提取类型化对象。
Index ¶
- Constants
- func At(qq any) message.Segment
- func CQString(chain message.Chain) string
- func Custom(kind string, data map[string]any) message.Segment
- func CustomMusic(url, audio, title, content, image string) message.Segment
- func CustomNode(userID any, nickname string, content message.Chain) message.Segment
- func Face(id any) message.Segment
- func Image(file string) message.Segment
- func JSON(data string) message.Segment
- func Music(kind string, id any) message.Segment
- func Node(id any) message.Segment
- func ParseCQ(input string) message.Chain
- func Record(file string) message.Segment
- func Reply(id any) message.Segment
- func Share(url, title, content, image string) message.Segment
- func Text(text string) message.Segment
- func Video(file string) message.Segment
- func XML(data string) message.Segment
- type ActionError
- type Adapter
- func AdapterFromConfig(cfg Config, extra ...Option) (*Adapter, error)
- func HTTP(apiURL, listenAddr string, opts ...Option) *Adapter
- func LoadAdapter(path string, extra ...Option) (*Adapter, error)
- func New(transport Transport) *Adapter
- func ReverseWS(addr string, opts ...Option) *Adapter
- func WebSocket(url string, opts ...Option) *Adapter
- type Client
- func (c *Client) Call(ctx context.Context, action string, params any, out any) error
- func (c *Client) CallRaw(ctx context.Context, action string, params any) (*Response, error)
- func (c *Client) CanSendImage(ctx context.Context) (bool, error)
- func (c *Client) CanSendRecord(ctx context.Context) (bool, error)
- func (c *Client) CleanCache(ctx context.Context) error
- func (c *Client) CreateGroupFileFolder(ctx context.Context, groupID any, name string, parentID any) error
- func (c *Client) DeleteGroupFile(ctx context.Context, groupID any, fileID, busid any) error
- func (c *Client) DeleteGroupFolder(ctx context.Context, groupID, folderID any) error
- func (c *Client) DeleteMessage(ctx context.Context, messageID any) error
- func (c *Client) GetCSRFToken(ctx context.Context) (int64, error)
- func (c *Client) GetCookies(ctx context.Context, domain string) (string, error)
- func (c *Client) GetCredentials(ctx context.Context, domain string) (Credentials, error)
- func (c *Client) GetForwardMessage(ctx context.Context, id any) (message.Chain, error)
- func (c *Client) GetFriendList(ctx context.Context) ([]FriendInfo, error)
- func (c *Client) GetGroupFileSystemInfo(ctx context.Context, groupID any) (GroupFileSystemInfo, error)
- func (c *Client) GetGroupFileURL(ctx context.Context, groupID any, fileID, busid any) (string, error)
- func (c *Client) GetGroupFilesByFolder(ctx context.Context, groupID, folderID any) (GroupFiles, error)
- func (c *Client) GetGroupHonorInfo(ctx context.Context, groupID any, kind string) (GroupHonorInfo, error)
- func (c *Client) GetGroupInfo(ctx context.Context, groupID any, noCache bool) (GroupInfo, error)
- func (c *Client) GetGroupList(ctx context.Context) ([]GroupInfo, error)
- func (c *Client) GetGroupMemberInfo(ctx context.Context, groupID, userID any, noCache bool) (GroupMemberInfo, error)
- func (c *Client) GetGroupMemberList(ctx context.Context, groupID any, noCache bool) ([]GroupMemberInfo, error)
- func (c *Client) GetGroupRootFiles(ctx context.Context, groupID any) (GroupFiles, error)
- func (c *Client) GetImage(ctx context.Context, file string) (FileInfo, error)
- func (c *Client) GetLoginInfo(ctx context.Context) (LoginInfo, error)
- func (c *Client) GetMessage(ctx context.Context, messageID any) (MessageInfo, error)
- func (c *Client) GetRecord(ctx context.Context, file, outFormat string) (FileInfo, error)
- func (c *Client) GetStatus(ctx context.Context) (StatusInfo, error)
- func (c *Client) GetStrangerInfo(ctx context.Context, userID any, noCache bool) (StrangerInfo, error)
- func (c *Client) GetVersionInfo(ctx context.Context) (VersionInfo, error)
- func (c *Client) Send(ctx context.Context, target core.ReplyTarget, chain message.Chain) (core.MessageReceipt, error)
- func (c *Client) SendGroupMessage(ctx context.Context, groupID any, chain message.Chain) (string, error)
- func (c *Client) SendLike(ctx context.Context, userID any, times int) error
- func (c *Client) SendMessage(ctx context.Context, messageType string, userID, groupID any, ...) (string, error)
- func (c *Client) SendPrivateMessage(ctx context.Context, userID any, chain message.Chain) (string, error)
- func (c *Client) SetFriendAddRequest(ctx context.Context, flag string, approve bool, remark string) error
- func (c *Client) SetGroupAddRequest(ctx context.Context, flag, subType string, approve bool, reason string) error
- func (c *Client) SetGroupAdmin(ctx context.Context, groupID, userID any, enable bool) error
- func (c *Client) SetGroupAnonymous(ctx context.Context, groupID any, enable bool) error
- func (c *Client) SetGroupAnonymousBan(ctx context.Context, groupID any, anonymous any, anonymousFlag string, ...) error
- func (c *Client) SetGroupBan(ctx context.Context, groupID, userID any, duration time.Duration) error
- func (c *Client) SetGroupCard(ctx context.Context, groupID, userID any, card string) error
- func (c *Client) SetGroupKick(ctx context.Context, groupID, userID any, rejectAddRequest bool) error
- func (c *Client) SetGroupLeave(ctx context.Context, groupID any, dismiss bool) error
- func (c *Client) SetGroupName(ctx context.Context, groupID any, name string) error
- func (c *Client) SetGroupSpecialTitle(ctx context.Context, groupID, userID any, title string, duration time.Duration) error
- func (c *Client) SetGroupWholeBan(ctx context.Context, groupID any, enable bool) error
- func (c *Client) SetRestart(ctx context.Context, delay time.Duration) error
- func (c *Client) UploadGroupFile(ctx context.Context, groupID any, file, name, folder string) error
- func (c *Client) UploadPrivateFile(ctx context.Context, userID any, file, name string) error
- type Config
- type ConnectionEvent
- type ConnectionHook
- type ConnectionState
- type Credentials
- type Event
- type FileInfo
- type FriendInfo
- type GroupFile
- type GroupFileSystemInfo
- type GroupFiles
- type GroupFolder
- type GroupHonorInfo
- type GroupInfo
- type GroupMemberInfo
- type HonorItem
- type LoginInfo
- type Message
- type MessageInfo
- type Option
- func WithAccessToken(token string) Option
- func WithActionTimeout(timeout time.Duration) Option
- func WithConnectionHook(hook ConnectionHook) Option
- func WithDialTimeout(timeout time.Duration) Option
- func WithHeader(key, value string) Option
- func WithLogger(logger *slog.Logger) Option
- func WithMaxEventBytes(n int64) Option
- func WithPath(path string) Option
- func WithReconnectInterval(interval time.Duration) Option
- func WithReconnectMaxInterval(interval time.Duration) Option
- type Response
- type Sender
- type StatusInfo
- type StrangerInfo
- type Transport
- type TransportConfig
- type VersionInfo
Constants ¶
const Protocol core.Protocol = "onebot11"
Protocol 表示 OneBot v11 协议标识。
Variables ¶
This section is empty.
Functions ¶
func CustomMusic ¶
CustomMusic 创建 OneBot v11 自定义音乐消息段。
func CustomNode ¶
CustomNode 创建合并转发自定义节点。
Types ¶
type ActionError ¶ added in v1.0.1
ActionError 描述一次被 OneBot v11 协议端拒绝或返回失败状态的动作调用。
func (*ActionError) Error ¶ added in v1.0.1
func (e *ActionError) Error() string
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter 将 OneBot v11 传输接入 AnyBot 运行时。
func AdapterFromConfig ¶
AdapterFromConfig 根据配置创建 OneBot v11 适配器,并追加额外选项。
func LoadAdapter ¶
LoadAdapter 从 YAML 文件读取配置并创建 OneBot v11 适配器。
func (*Adapter) Client ¶
func (a *Adapter) Client() core.ActionClient
Client 返回 OneBot v11 类型化动作客户端。
func (*Adapter) SetStateSink ¶ added in v1.0.1
func (a *Adapter) SetStateSink(sink core.AdapterStateSink)
SetStateSink 设置协议无关的状态上报函数。
func (*Adapter) State ¶ added in v1.0.1
func (a *Adapter) State() core.AdapterState
State 返回最近一次已知的 OneBot v11 动作通道状态。
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 是 OneBot v11 的类型化动作客户端。
func ClientFrom ¶
ClientFrom 从 AnyBot 上下文提取 OneBot v11 客户端。
c 可以是 *core.Context,也可以是 SDK 的 *sdk.EventContext 这类暴露 UnsafeCoreContext() *core.Context 的上下文。
func MustClient ¶
MustClient 从 AnyBot 上下文提取 OneBot v11 客户端;类型不匹配时 panic。
func (*Client) CanSendImage ¶
CanSendImage 检查当前协议端是否可以发送图片。
func (*Client) CanSendRecord ¶
CanSendRecord 检查当前协议端是否可以发送语音。
func (*Client) CleanCache ¶
CleanCache 请求协议端清理缓存。
func (*Client) CreateGroupFileFolder ¶
func (c *Client) CreateGroupFileFolder(ctx context.Context, groupID any, name string, parentID any) error
CreateGroupFileFolder 创建群文件夹。
func (*Client) DeleteGroupFile ¶
DeleteGroupFile 删除群文件。
func (*Client) DeleteGroupFolder ¶
DeleteGroupFolder 删除群文件夹。
func (*Client) DeleteMessage ¶
DeleteMessage 撤回指定消息。
func (*Client) GetCSRFToken ¶
GetCSRFToken 获取 CSRF token。
func (*Client) GetCookies ¶
GetCookies 获取指定域名的 Cookies。
func (*Client) GetCredentials ¶
GetCredentials 获取指定域名的 Cookies 与 CSRF token。
func (*Client) GetForwardMessage ¶
GetForwardMessage 获取合并转发消息内容。
func (*Client) GetFriendList ¶
func (c *Client) GetFriendList(ctx context.Context) ([]FriendInfo, error)
GetFriendList 获取好友列表。
func (*Client) GetGroupFileSystemInfo ¶
func (c *Client) GetGroupFileSystemInfo(ctx context.Context, groupID any) (GroupFileSystemInfo, error)
GetGroupFileSystemInfo 获取群文件系统容量与数量信息。
func (*Client) GetGroupFileURL ¶
func (c *Client) GetGroupFileURL(ctx context.Context, groupID any, fileID, busid any) (string, error)
GetGroupFileURL 获取群文件下载链接。
func (*Client) GetGroupFilesByFolder ¶
func (c *Client) GetGroupFilesByFolder(ctx context.Context, groupID, folderID any) (GroupFiles, error)
GetGroupFilesByFolder 获取指定群文件夹内容。
func (*Client) GetGroupHonorInfo ¶
func (c *Client) GetGroupHonorInfo(ctx context.Context, groupID any, kind string) (GroupHonorInfo, error)
GetGroupHonorInfo 获取群荣誉信息,kind 对应 OneBot v11 的 type 参数。
func (*Client) GetGroupInfo ¶
GetGroupInfo 获取群信息。
func (*Client) GetGroupList ¶
GetGroupList 获取群列表。
func (*Client) GetGroupMemberInfo ¶
func (c *Client) GetGroupMemberInfo(ctx context.Context, groupID, userID any, noCache bool) (GroupMemberInfo, error)
GetGroupMemberInfo 获取指定群成员信息。
func (*Client) GetGroupMemberList ¶
func (c *Client) GetGroupMemberList(ctx context.Context, groupID any, noCache bool) ([]GroupMemberInfo, error)
GetGroupMemberList 获取指定群的成员列表。
func (*Client) GetGroupRootFiles ¶
GetGroupRootFiles 获取群文件根目录内容。
func (*Client) GetLoginInfo ¶
GetLoginInfo 获取当前登录账号信息。
func (*Client) GetMessage ¶
GetMessage 获取指定消息详情。
func (*Client) GetStatus ¶
func (c *Client) GetStatus(ctx context.Context) (StatusInfo, error)
GetStatus 获取协议端运行状态。
func (*Client) GetStrangerInfo ¶
func (c *Client) GetStrangerInfo(ctx context.Context, userID any, noCache bool) (StrangerInfo, error)
GetStrangerInfo 获取陌生人信息。
func (*Client) GetVersionInfo ¶
func (c *Client) GetVersionInfo(ctx context.Context) (VersionInfo, error)
GetVersionInfo 获取协议端版本信息。
func (*Client) Send ¶
func (c *Client) Send(ctx context.Context, target core.ReplyTarget, chain message.Chain) (core.MessageReceipt, error)
Send 根据 ReplyTarget 选择私聊或群聊动作发送消息。
func (*Client) SendGroupMessage ¶
func (c *Client) SendGroupMessage(ctx context.Context, groupID any, chain message.Chain) (string, error)
SendGroupMessage 发送群消息,并返回消息 ID。
func (*Client) SendMessage ¶
func (c *Client) SendMessage(ctx context.Context, messageType string, userID, groupID any, chain message.Chain) (string, error)
SendMessage 调用 send_msg 发送消息,适合需要显式指定 message_type 的场景。
func (*Client) SendPrivateMessage ¶
func (c *Client) SendPrivateMessage(ctx context.Context, userID any, chain message.Chain) (string, error)
SendPrivateMessage 发送私聊消息,并返回消息 ID。
func (*Client) SetFriendAddRequest ¶
func (c *Client) SetFriendAddRequest(ctx context.Context, flag string, approve bool, remark string) error
SetFriendAddRequest 处理好友添加请求。
func (*Client) SetGroupAddRequest ¶
func (c *Client) SetGroupAddRequest(ctx context.Context, flag, subType string, approve bool, reason string) error
SetGroupAddRequest 处理加群请求或邀请。
func (*Client) SetGroupAdmin ¶
SetGroupAdmin 设置或取消群管理员。
func (*Client) SetGroupAnonymous ¶
SetGroupAnonymous 开启或关闭群匿名聊天。
func (*Client) SetGroupAnonymousBan ¶
func (c *Client) SetGroupAnonymousBan(ctx context.Context, groupID any, anonymous any, anonymousFlag string, duration time.Duration) error
SetGroupAnonymousBan 设置匿名用户禁言。
func (*Client) SetGroupBan ¶
func (c *Client) SetGroupBan(ctx context.Context, groupID, userID any, duration time.Duration) error
SetGroupBan 设置群成员禁言时长。
func (*Client) SetGroupCard ¶
SetGroupCard 设置群成员名片。
func (*Client) SetGroupKick ¶
func (c *Client) SetGroupKick(ctx context.Context, groupID, userID any, rejectAddRequest bool) error
SetGroupKick 踢出群成员,并可拒绝其后续加群请求。
func (*Client) SetGroupLeave ¶
SetGroupLeave 退出群;dismiss 为 true 时尝试解散群。
func (*Client) SetGroupName ¶
SetGroupName 设置群名称。
func (*Client) SetGroupSpecialTitle ¶
func (c *Client) SetGroupSpecialTitle(ctx context.Context, groupID, userID any, title string, duration time.Duration) error
SetGroupSpecialTitle 设置群成员专属头衔。
func (*Client) SetGroupWholeBan ¶
SetGroupWholeBan 开启或关闭全群禁言。
func (*Client) SetRestart ¶
SetRestart 请求协议端延迟重启。
func (*Client) UploadGroupFile ¶
UploadGroupFile 上传群文件。
type Config ¶
type Config struct {
Protocol string `yaml:"protocol"`
Transport TransportConfig `yaml:"transport"`
}
Config 描述可从 YAML 读取的 OneBot v11 适配器配置。
func LoadConfig ¶
LoadConfig 从 YAML 文件读取 OneBot v11 配置;path 为空时读取 core.yaml。
type ConnectionEvent ¶
type ConnectionEvent struct {
State ConnectionState
Transport string
URL string
Addr string
Path string
Remote string
}
ConnectionEvent 描述一次 WebSocket 连接状态变化及其传输端信息。
type ConnectionHook ¶
type ConnectionHook func(context.Context, ConnectionEvent)
ConnectionHook 接收 WebSocket 连接状态变化通知。
type ConnectionState ¶
type ConnectionState string
ConnectionState 表示 WebSocket 传输的连接状态。
const ( // ConnectionConnected 表示 WebSocket 已建立连接。 ConnectionConnected ConnectionState = "connected" // ConnectionDisconnected 表示 WebSocket 已断开连接。 ConnectionDisconnected ConnectionState = "disconnected" )
type Credentials ¶
Credentials 描述 Cookies 与 CSRF token。
func (*Credentials) UnmarshalJSON ¶
func (i *Credentials) UnmarshalJSON(data []byte) error
type Event ¶
type Event struct {
Time int64 `json:"time,omitempty"`
SelfID int64 `json:"self_id,omitempty"`
PostType string `json:"post_type,omitempty"`
SubType string `json:"sub_type,omitempty"`
RawMessage string `json:"raw_message,omitempty"`
MessageType string `json:"message_type,omitempty"`
MessageID int64 `json:"message_id,omitempty"`
UserID int64 `json:"user_id,omitempty"`
GroupID int64 `json:"group_id,omitempty"`
Message message.Chain `json:"message,omitempty"`
Sender Sender `json:"sender,omitempty"`
NoticeType string `json:"notice_type,omitempty"`
RequestType string `json:"request_type,omitempty"`
MetaEventType string `json:"meta_event_type,omitempty"`
OperatorID int64 `json:"operator_id,omitempty"`
TargetID int64 `json:"target_id,omitempty"`
Comment string `json:"comment,omitempty"`
Flag string `json:"flag,omitempty"`
Extra map[string]json.RawMessage `json:"-"`
Raw json.RawMessage `json:"-"`
}
Event 是宽松的 OneBot v11 事件模型,已知字段会被标准化,未知字段保留在 Extra。
func EventFrom ¶
EventFrom 从 AnyBot 上下文提取 OneBot v11 原始事件。
c 可以是 *core.Context,也可以是 SDK 的 *sdk.EventContext 这类暴露 UnsafeCoreContext() *core.Context 的上下文。
func (*Event) UnmarshalJSON ¶
UnmarshalJSON 保留未知字段,并同时接受数组消息与 CQ 字符串消息。
type FriendInfo ¶
type FriendInfo struct {
UserID int64 `json:"user_id"`
Nickname string `json:"nickname"`
Remark string `json:"remark"`
}
FriendInfo 描述好友资料。
func (*FriendInfo) UnmarshalJSON ¶
func (i *FriendInfo) UnmarshalJSON(data []byte) error
type GroupFile ¶
type GroupFile struct {
GroupID int64 `json:"group_id"`
FileID string `json:"file_id"`
FileName string `json:"file_name"`
BusID int64 `json:"busid"`
FileSize int64 `json:"file_size"`
UploadTime int64 `json:"upload_time"`
DeadTime int64 `json:"dead_time"`
ModifyTime int64 `json:"modify_time"`
DownloadTimes int64 `json:"download_times"`
Uploader int64 `json:"uploader"`
UploaderName string `json:"uploader_name"`
}
GroupFile 描述群文件条目。
func (*GroupFile) UnmarshalJSON ¶
type GroupFileSystemInfo ¶
type GroupFileSystemInfo struct {
FileCount int64 `json:"file_count"`
LimitCount int64 `json:"limit_count"`
UsedSpace int64 `json:"used_space"`
TotalSpace int64 `json:"total_space"`
}
GroupFileSystemInfo 描述群文件系统容量和文件数量。
func (*GroupFileSystemInfo) UnmarshalJSON ¶
func (i *GroupFileSystemInfo) UnmarshalJSON(data []byte) error
type GroupFiles ¶
type GroupFiles struct {
Files []GroupFile `json:"files"`
Folders []GroupFolder `json:"folders"`
}
GroupFiles 描述群文件目录内容。
type GroupFolder ¶
type GroupFolder struct {
GroupID int64 `json:"group_id"`
FolderID string `json:"folder_id"`
FolderName string `json:"folder_name"`
CreateTime int64 `json:"create_time"`
Creator int64 `json:"creator"`
CreatorName string `json:"creator_name"`
TotalFileCount int64 `json:"total_file_count"`
}
GroupFolder 描述群文件夹条目。
func (*GroupFolder) UnmarshalJSON ¶
func (i *GroupFolder) UnmarshalJSON(data []byte) error
type GroupHonorInfo ¶
type GroupHonorInfo struct {
GroupID int64 `json:"group_id"`
CurrentTalkative HonorItem `json:"current_talkative"`
TalkativeList []HonorItem `json:"talkative_list"`
PerformerList []HonorItem `json:"performer_list"`
LegendList []HonorItem `json:"legend_list"`
StrongNewbieList []HonorItem `json:"strong_newbie_list"`
EmotionList []HonorItem `json:"emotion_list"`
}
GroupHonorInfo 描述群荣誉信息。
func (*GroupHonorInfo) UnmarshalJSON ¶
func (i *GroupHonorInfo) UnmarshalJSON(data []byte) error
type GroupInfo ¶
type GroupInfo struct {
GroupID int64 `json:"group_id"`
GroupName string `json:"group_name"`
MemberCount int `json:"member_count"`
MaxMemberCount int `json:"max_member_count"`
}
GroupInfo 描述群资料。
func (*GroupInfo) UnmarshalJSON ¶
type GroupMemberInfo ¶
type GroupMemberInfo struct {
GroupID int64 `json:"group_id"`
UserID int64 `json:"user_id"`
Nickname string `json:"nickname"`
Card string `json:"card"`
Sex string `json:"sex,omitempty"`
Age int `json:"age,omitempty"`
Area string `json:"area,omitempty"`
JoinTime int64 `json:"join_time,omitempty"`
LastSentTime int64 `json:"last_sent_time,omitempty"`
Role string `json:"role"`
Unfriendly bool `json:"unfriendly,omitempty"`
Title string `json:"title"`
TitleExpireTime int64 `json:"title_expire_time,omitempty"`
CardChangeable bool `json:"card_changeable,omitempty"`
}
GroupMemberInfo 描述群成员资料。
func (*GroupMemberInfo) UnmarshalJSON ¶
func (i *GroupMemberInfo) UnmarshalJSON(data []byte) error
type HonorItem ¶
type HonorItem struct {
UserID int64 `json:"user_id"`
Nickname string `json:"nickname"`
Avatar string `json:"avatar"`
Description string `json:"description"`
}
HonorItem 描述群荣誉列表中的成员条目。
func (*HonorItem) UnmarshalJSON ¶
type MessageInfo ¶
type MessageInfo struct {
Time int64 `json:"time"`
MessageType string `json:"message_type"`
MessageID int64 `json:"message_id"`
RealID int64 `json:"real_id,omitempty"`
Sender Sender `json:"sender"`
Message message.Chain `json:"message"`
RawMessage string `json:"raw_message"`
}
MessageInfo 描述 get_msg 返回的消息详情。
func (*MessageInfo) UnmarshalJSON ¶
func (m *MessageInfo) UnmarshalJSON(data []byte) error
UnmarshalJSON 同时接受数组消息和 CQ 字符串消息。
type Option ¶
type Option func(*options)
Option 调整 OneBot v11 传输配置。
func WithAccessToken ¶
WithAccessToken 配置访问令牌,用于 Bearer token 鉴权和反向连接校验。
func WithActionTimeout ¶
WithActionTimeout 配置动作调用默认超时;调用上下文已有 deadline 时不会覆盖。
func WithConnectionHook ¶
func WithConnectionHook(hook ConnectionHook) Option
WithConnectionHook 注册 WebSocket 连接状态钩子。
func WithDialTimeout ¶
WithDialTimeout 配置正向 WebSocket 拨号超时。
func WithMaxEventBytes ¶ added in v1.0.1
WithMaxEventBytes 配置入站事件或响应帧的最大字节数。
func WithReconnectInterval ¶
WithReconnectInterval 配置正向 WebSocket 初始重连间隔。
func WithReconnectMaxInterval ¶
WithReconnectMaxInterval 配置正向 WebSocket 最大重连间隔。
type Response ¶
type Response struct {
Status string `json:"status"`
RetCode int `json:"retcode"`
Data json.RawMessage `json:"data,omitempty"`
Message string `json:"message,omitempty"`
Wording string `json:"wording,omitempty"`
Echo string `json:"echo,omitempty"`
Raw json.RawMessage `json:"-"`
}
Response 表示 OneBot v11 动作响应,并保留原始 JSON。
func (*Response) UnmarshalJSON ¶
UnmarshalJSON 兼容数字或字符串形式的 retcode。
type Sender ¶
type Sender struct {
UserID int64 `json:"user_id,omitempty"`
Nickname string `json:"nickname,omitempty"`
Card string `json:"card,omitempty"`
Sex string `json:"sex,omitempty"`
Age int `json:"age,omitempty"`
Area string `json:"area,omitempty"`
Level string `json:"level,omitempty"`
Role string `json:"role,omitempty"`
Title string `json:"title,omitempty"`
}
Sender 描述 OneBot v11 消息发送者信息。
func (*Sender) UnmarshalJSON ¶
UnmarshalJSON 兼容数字或字符串形式的 user_id。
type StatusInfo ¶
type StatusInfo struct {
Online bool `json:"online"`
Good bool `json:"good"`
Extra map[string]any `json:"-"`
}
StatusInfo 描述协议端运行状态。
type StrangerInfo ¶
type StrangerInfo struct {
UserID int64 `json:"user_id"`
Nickname string `json:"nickname"`
Sex string `json:"sex"`
Age int `json:"age"`
QID string `json:"qid,omitempty"`
Level int `json:"level,omitempty"`
LoginDays int `json:"login_days,omitempty"`
}
StrangerInfo 描述陌生人资料。
func (*StrangerInfo) UnmarshalJSON ¶
func (i *StrangerInfo) UnmarshalJSON(data []byte) error
type Transport ¶
type Transport interface {
Start(context.Context, func(context.Context, *Event) error) error
CallRaw(context.Context, string, any) (*Response, error)
}
Transport 定义 OneBot v11 事件接收与动作调用所需的底层传输能力。
type TransportConfig ¶
type TransportConfig struct {
Type string `yaml:"type"`
Listen string `yaml:"listen"`
Path string `yaml:"path"`
URL string `yaml:"url"`
AccessToken string `yaml:"access_token"`
Headers map[string]string `yaml:"headers"`
MaxEventBytes int64 `yaml:"max_event_bytes"`
DialTimeout string `yaml:"dial_timeout"`
ActionTimeout string `yaml:"action_timeout"`
ReconnectInterval string `yaml:"reconnect_interval"`
ReconnectMaxInterval string `yaml:"reconnect_max_interval"`
}
TransportConfig 描述 OneBot v11 传输层配置。
type VersionInfo ¶
type VersionInfo struct {
AppName string `json:"app_name"`
AppVersion string `json:"app_version"`
ProtocolVersion string `json:"protocol_version"`
}
VersionInfo 描述协议端版本信息。