protocol

package
v0.0.0-...-7a6c0c8 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventTypeMeta 元事件
	EventTypeMeta = "meta"
	// EventTypeMessage 消息事件
	EventTypeMessage = "message"
	// EventTypeNotice 通知事件
	EventTypeNotice = "notice"
	// EventTypeRequest 请求事件
	EventTypeRequest = "request"
)
View Source
const (
	// StatusOk 正常
	StatusOk = "ok"
	// StatusFailed 失败
	StatusFailed = "failed"
)
View Source
const (
	// ResponseCodeBadRequest 无效的动作请求
	// 格式错误(包括实现不支持 MessagePack 的情况)、必要字段缺失或字段类型错误
	ResponseCodeBadRequest = 10001
	// ResponseCodeUnsupportedAction 不支持的动作请求
	// OneBot 实现没有实现该动作
	ResponseCodeUnsupportedAction = 10002
	// ResponseCodeBadParam 无效的动作请求参数
	// 参数缺失或参数类型错误
	ResponseCodeBadParam = 10003
	// ResponseCodeUnsupportedParam 不支持的动作请求参数
	// OneBot 实现没有实现该参数的语义
	ResponseCodeUnsupportedParam = 10004
	// ResponseCodeUnsupportedSegment 不支持的消息段类型
	//  OneBot 实现没有实现该消息段类型
	ResponseCodeUnsupportedSegment = 10005
	// ResponseCodeBadSegmentData 无效的消息段参数
	// 参数缺失或参数类型错误
	ResponseCodeBadSegmentData = 10006
	// ResponseCodeUnsupportedSegmentData 不支持的消息段参数
	// OneBot 实现没有实现该参数的语义
	ResponseCodeUnsupportedSegmentData = 10007
	// ResponseCodeWhoAmI 未指定机器人账号
	// OneBot 实现在单个 OneBot Connect 连接上支持多个机器人账号,但动作请求未指定要使用的账号
	ResponseCodeWhoAmI = 10101
	// ResponseCodeUnknownSelf 未知的机器人账号
	// 动作请求指定的机器人账号不存在
	ResponseCodeUnknownSelf = 10102
)

Reference: https://12.onebot.dev/connect/data-protocol/action-response/#1xxxx-request-error

View Source
const (
	// ResponseCodeBadHandler 	动作处理器实现错误
	// 没有正确设置响应状态等
	ResponseCodeBadHandler = 20001
	// ResponseCodeInternalHandlerError 动作处理器运行时抛出异常
	// OneBot 实现内部发生了未捕获的意料之外的异常
	ResponseCodeInternalHandlerError = 20002
)

Reference: https://12.onebot.dev/connect/data-protocol/action-response/#2xxxx-handler-error

View Source
const (
	// ResponseCodeOk 请求成功
	// 当动作请求有效、动作执行成功时,返回码应为 0。
	ResponseCodeOk = 0
)

Reference: https://12.onebot.dev/connect/data-protocol/action-response/#0-ok

Variables

View Source
var (
	// ErrorInvalidEvent 该结构体不是一个OneBot事件
	ErrorInvalidEvent = errors.New("arg not a onebot event strcut")
	// ErrorInValidEventType 事件类型无效
	ErrorInValidEventType = errors.New("event type is invalid")
)
View Source
var (
	// ErrorInvalidRequest 该结构体不是一个OneBot事件
	ErrorInvalidRequest = errors.New("arg not a onebot request struct")
	// ErrorRequestIsNil 请求为空
	ErrorRequestIsNil = errors.New("request is nil")
	// ErrorRequestNotMatch 请求不匹配
	ErrorRequestNotMatch = errors.New("request not match")
	// ErrorActionEmpty 动作为空
	ErrorActionEmpty = errors.New("action is empty")
)
View Source
var (
	// ErrorInvalidResponse 该结构体不是一个OneBot动作相应
	ErrorInvalidResponse = errors.New("arg not a onebot response struct")
	// ErrorInvalidResponseRetCode 返回码无效
	ErrorInvalidResponseRetCode = errors.New("invalid response retcode")
)
View Source
var (
	// EventType 事件类型
	EventType = reflect.TypeOf(&Event{})
)
View Source
var (
	// RequestType 事件类型
	RequestType = reflect.TypeOf(&Request{})
)
View Source
var (
	// ResponseType 事件类型
	ResponseType = reflect.TypeOf(&Response{})
)

Functions

func EventCheck

func EventCheck(s Self, e any) (string, string, error)

EventCheck 检查事件是否合法

s: Self 自身标识 e: Event 事件 需要满足条件

func RequestAdapter

func RequestAdapter(e any, r RawRequestType) error

RequestAdapter 将RawRequestType转换为Request

func ResponseCheck

func ResponseCheck(r *Request, e any) error

ResponseCheck 检查响应是否合法

Types

type EmptyResponse

type EmptyResponse struct {
	*Response
}

EmptyResponse 空响应

func NewEmptyResponse

func NewEmptyResponse(retCode int) *EmptyResponse

NewEmptyResponse 构造函数

type Event

type Event struct {
	// ID 事件ID
	ID string `json:"id"`
	// Time 事件发生的时间戳 Unix时间戳 单位为秒
	Time float64 `json:"time"`
	// Type 事件类型 meta/message/notice/request
	// 对应ActionTypeXXX
	Type string `json:"type"`
	// DetailType 事件详细类型
	DetailType string `json:"detail_type"`
	// SubType 事件子类型 详细类型的子类型
	SubType string `json:"sub_type"`
	// Self 事件发起Bot
	Self Self `json:"self"`
}

Event 事件

Reference: https://12.onebot.dev/connect/data-protocol/event/

type MessageEventChannel

type MessageEventChannel struct {
	*Event
	// MessageID 消息ID
	MessageId string `json:"message_id"`
	// Message 消息内容 消息段列表
	Message []Segment `json:"message"`
	// AltMessage 消息内容的替代表示, 可以为空
	AltMessage string `json:"alt_message"`
	// GuildId   群组ID
	GuildId string `json:"guild_id"`
	// ChannelId 频道ID
	ChannelId string `json:"channel_id"`
	// UserId    用户ID
	UserId string `json:"user_id"`
}

MessageEventChannel 频道消息事件

Reference: https://12.onebot.dev/interface/guild/message-events/#messagechannel

func NewMessageEventChannel

func NewMessageEventChannel() (e *MessageEventChannel)

NewMessageEventChannel 创建一个频道消息事件

type MessageEventGroup

type MessageEventGroup struct {
	*Event
	// MessageID 消息ID
	MessageId string `json:"message_id"`
	// Message 消息内容 消息段列表
	Message []Segment `json:"message"`
	// AltMessage 消息内容的替代表示, 可以为空
	AltMessage string `json:"alt_message"`
	// GroupId 群组ID
	GroupId string `json:"group_id"`
	// UserId 用户 ID
	UserId string `json:"user_id"`
}

MessageEventGroup 群消息事件

Reference: https://12.onebot.dev/interface/group/message-events/#messagegroup

func NewMessageEventGroup

func NewMessageEventGroup() (e *MessageEventGroup)

NewMessageEventGroup 创建一个群消息事件

type MessageEventPrivate

type MessageEventPrivate struct {
	*Event
	// MessageID 消息ID
	MessageId string `json:"message_id"`
	// Message 消息内容 消息段列表
	Message []Segment `json:"message"`
	// AltMessage 消息内容的替代表示, 可以为空
	AltMessage string `json:"alt_message"`
	// UserId 用户 ID
	UserId string `json:"user_id"`
}

MessageEventPrivate 私聊消息事件

Reference: https://12.onebot.dev/interface/user/message-events/#messageprivate

func NewMessageEventPrivate

func NewMessageEventPrivate() (e *MessageEventPrivate)

NewMessageEventPrivate 创建一个私聊消息事件

type MetaEventConnect

type MetaEventConnect struct {
	*Event
	// Version 机器人版本信息
	//
	// resp[get_version] OneBot实现端版本信息, 与get_version动作响应数据一致
	Version struct {
		// Impl OneBot实现端名称
		Impl string `json:"impl"`
		// Version OneBot实现端版本
		Version string `json:"version"`
		// OnebotVersion OneBot协议版本
		OnebotVersion string `json:"onebot_version"`
	} `json:"version"`
}

MetaEventConnect 连接事件

Reference: https://12.onebot.dev/interface/meta/events/#metaconnect

func NewMetaEventConnect

func NewMetaEventConnect() (e *MetaEventConnect)

NewMetaEventConnect 创建一个连接事件

type MetaEventHeartbeat

type MetaEventHeartbeat struct {
	*Event
	// Interval 心跳间隔
	Interval int `json:"interval"`
}

MetaEventHeartbeat 心跳事件

func NewMetaEventHeartbeat

func NewMetaEventHeartbeat() (e *MetaEventHeartbeat)

NewMetaEventHeartbeat 创建一个心跳事件

type MetaEventStatusUpdate

type MetaEventStatusUpdate struct {
	*Event
	// Status 机器人状态
	Status struct {
		// Good
		Good bool `json:"good"`
		// Bots
		Bots []struct {
			// Self
			Self Self `json:"self"`
			// Online
			Online bool `json:"online"`
		} `json:"bots"`
	} `json:"status"`
}

MetaEventStatusUpdate 机器人状态更新事件

Reference: https://12.onebot.dev/interface/meta/events/#metastatus_update

func NewMetaEventStatusUpdate

func NewMetaEventStatusUpdate() (e *MetaEventStatusUpdate)

NewMetaEventStatusUpdate 创建一个机器人状态更新事件

type NoticeEventChannelCreate

type NoticeEventChannelCreate struct {
	*Event
	// GuildId 群组ID
	GuildId string `json:"guild_id"`
	// ChannelId 频道ID
	ChannelId string `json:"channel_id"`
	// OperatorId 操作者ID
	OperatorId string `json:"operator_id"`
}

NoticeEventChannelCreate 频道创建事件

Reference: https://12.onebot.dev/interface/guild/notice-events/#noticechannel_create

func NewNoticeEventChannelCreate

func NewNoticeEventChannelCreate() (e *NoticeEventChannelCreate)

NewNoticeEventChannelCreate 创建一个频道创建事件

type NoticeEventChannelDelete

type NoticeEventChannelDelete struct {
	*Event
	// GuildId 群组ID
	GuildId string `json:"guild_id"`
	// ChannelId 频道ID
	ChannelId string `json:"channel_id"`
	// OperatorId 操作者ID
	OperatorId string `json:"operator_id"`
}

NoticeEventChannelDelete 频道删除事件

Reference: https://12.onebot.dev/interface/guild/notice-events/#noticechannel_delete

func NewNoticeEventChannelDelete

func NewNoticeEventChannelDelete() (e *NoticeEventChannelDelete)

NewNoticeEventChannelDelete 创建一个频道删除事件

type NoticeEventChannelMemberDecrease

type NoticeEventChannelMemberDecrease struct {
	*Event
	// UserId 用户ID
	UserId string `json:"user_id"`
	// GuildId 群组ID
	GuildId string `json:"guild_id"`
	// ChannelId  频道ID
	ChannelId string `json:"channel_id"`
	// OperatorId 操作者ID
	OperatorId string `json:"operator_id"`
}

NoticeEventChannelMemberDecrease 频道成员减少事件

Reference: https://12.onebot.dev/interface/guild/notice-events/#noticechannel_member_decrease

func NewNoticeEventChannelMemberDecrease

func NewNoticeEventChannelMemberDecrease(subType string) (e *NoticeEventChannelMemberDecrease)

NewNoticeEventChannelMemberDecrease 创建一个频道成员减少事件

subType: leave / kick / 自定义 / 空

type NoticeEventChannelMemberIncrease

type NoticeEventChannelMemberIncrease struct {
	*Event
	// UserId 用户ID
	UserId string `json:"user_id"`
	// GuildId 群组ID
	GuildId string `json:"guild_id"`
	// ChannelId  频道ID
	ChannelId string `json:"channel_id"`
	// OperatorId 操作者ID
	OperatorId string `json:"operator_id"`
}

NoticeEventChannelMemberIncrease 频道成员增加事件

Reference: https://12.onebot.dev/interface/guild/notice-events/#noticechannel_member_increase

func NewNoticeEventChannelMemberIncrease

func NewNoticeEventChannelMemberIncrease(subType string) (e *NoticeEventChannelMemberIncrease)

NewNoticeEventChannelMemberIncrease 创建一个频道成员增加事件

subType: join / invite / 自定义 / 空

type NoticeEventChannelMessageDelete

type NoticeEventChannelMessageDelete struct {
	*Event
	// GuildId 群组ID
	GuildId string `json:"guild_id"`
	// ChannelId  频道ID
	ChannelId string `json:"channel_id"`
	// MessageId 消息ID
	MessageId string `json:"message_id"`
	// UserId 用户ID
	UserId string `json:"user_id"`
	// OperatorId 操作者ID
	OperatorId string `json:"operator_id"`
}

NoticeEventChannelMessageDelete 消息删除事件

Reference: https://12.onebot.dev/interface/guild/notice-events/#noticechannel_message_delete

func NewNoticeEventChannelMessageDelete

func NewNoticeEventChannelMessageDelete(subType string) (e *NoticeEventChannelMessageDelete)

NewNoticeEventChannelMessageDelete 创建一个消息删除事件

subType: recall / delete / 自定义 / 空

type NoticeEventFriendDecrease

type NoticeEventFriendDecrease struct {
	*Event
	// UserId 用户ID
	UserId string `json:"user_id"`
}

NoticeEventFriendDecrease 好友减少事件

Reference: https://12.onebot.dev/interface/user/notice-events/#noticefriend_decrease

func NewNoticeEventFriendDecrease

func NewNoticeEventFriendDecrease() (e *NoticeEventFriendDecrease)

NewNoticeEventFriendDecrease 创建一个好友减少事件

type NoticeEventFriendIncrease

type NoticeEventFriendIncrease struct {
	*Event
	// UserId 用户ID
	UserId string `json:"user_id"`
}

NoticeEventFriendIncrease 好友增加事件

Reference: https://12.onebot.dev/interface/user/notice-events/#noticefriend_increase

func NewNoticeEventFriendIncrease

func NewNoticeEventFriendIncrease() (e *NoticeEventFriendIncrease)

NewNoticeEventFriendIncrease 创建一个好友增加事件

type NoticeEventGroupMemberDecrease

type NoticeEventGroupMemberDecrease struct {
	*Event
	// UserId 用户ID
	UserId string `json:"user_id"`
	// GroupId 群组ID
	GroupId string `json:"group_id"`
	// OperatorId 操作者ID
	OperatorId string `json:"operator_id"`
}

NoticeEventGroupMemberDecrease 群成员减少事件

Reference: https://12.onebot.dev/interface/group/notice-events/#noticegroup_member_decrease

func NewNoticeEventGroupMemberDecrease

func NewNoticeEventGroupMemberDecrease(subType string) (e *NoticeEventGroupMemberDecrease)

NewNoticeEventGroupMemberDecrease 创建一个群成员减少事件

subType: leave / kick / 自定义 / 空

type NoticeEventGroupMemberIncrease

type NoticeEventGroupMemberIncrease struct {
	*Event
	// UserId 用户ID
	UserId string `json:"user_id"`
	// GroupId 群组ID
	GroupId string `json:"group_id"`
	// OperatorId 操作者ID
	OperatorId string `json:"operator_id"`
}

NoticeEventGroupMemberIncrease 群成员增加事件

Reference: https://12.onebot.dev/interface/group/notice-events/#noticegroup_member_increase

func NewNoticeEventGroupMemberIncrease

func NewNoticeEventGroupMemberIncrease(subType string) (e *NoticeEventGroupMemberIncrease)

NewNoticeEventGroupMemberIncrease 创建一个群成员增加事件

subType: join / invite / 自定义 / 空

type NoticeEventGroupMessageDelete

type NoticeEventGroupMessageDelete struct {
	*Event
	// MessageId 消息ID
	MessageId string `json:"message_id"`
	// UserId 用户ID
	UserId string `json:"user_id"`
	// OperatorId 群组ID
	OperatorId string `json:"operator_id"`
}

NoticeEventGroupMessageDelete 消息删除事件

Reference: https://12.onebot.dev/interface/group/notice-events/#noticegroup_message_delete

func NewNoticeEventGroupMessageDelete

func NewNoticeEventGroupMessageDelete(subType string) (e *NoticeEventGroupMessageDelete)

NewNoticeEventGroupMessageDelete 创建一个群消息删除事件

subType: recall / delete / 自定义 / 空

type NoticeEventGuildMemberDecrease

type NoticeEventGuildMemberDecrease struct {
	*Event
	// UserId 用户ID
	UserId string `json:"user_id"`
	// GuildId 群组ID
	GuildId string `json:"guild_id"`
	// OperatorId 操作者ID
	OperatorId string `json:"operator_id"`
}

NoticeEventGuildMemberDecrease 群组成员减少事件

Reference: https://12.onebot.dev/interface/guild/notice-events/#noticeguild_member_decrease

func NewNoticeEventGuildMemberDecrease

func NewNoticeEventGuildMemberDecrease(subType string) (e *NoticeEventGuildMemberDecrease)

NewNoticeEventGuildMemberDecrease 创建一个群组成员减少事件

subType: leave / kick / 自定义 / 空

type NoticeEventGuildMemberIncrease

type NoticeEventGuildMemberIncrease struct {
	*Event
	// UserId 用户ID
	UserId string `json:"user_id"`
	// GuildId 群组ID
	GuildId string `json:"guild_id"`
	// OperatorId 操作者ID
	OperatorId string `json:"operator_id"`
}

NoticeEventGuildMemberIncrease 群组成员增加事件

Reference: https://12.onebot.dev/interface/guild/notice-events/#noticeguild_member_increase

func NewNoticeEventGuildMemberIncrease

func NewNoticeEventGuildMemberIncrease(subType string) (e *NoticeEventGuildMemberIncrease)

NewNoticeEventGuildMemberIncrease 创建一个群组成员增加事件

subType: join / invite / 自定义 / 空

type NoticeEventMessageDelete

type NoticeEventMessageDelete struct {
	*Event
	// MessageID 消息ID
	MessageId string `json:"message_id"`
	// UserId 用户ID
	UserId string `json:"user_id"`
}

NoticeEventMessageDelete 消息删除事件

Reference: https://12.onebot.dev/interface/user/notice-events/#noticeprivate_message_delete

func NewNoticeEventMessageDelete

func NewNoticeEventMessageDelete() (e *NoticeEventMessageDelete)

NewNoticeEventMessageDelete 创建一个消息删除事件

type OneBotConfig

type OneBotConfig struct {
	// PlatForm 平台
	PlatForm string `json:"platform"`
	// Implementation 实现
	Implementation string `json:"implementation"`
	// Version 版本
	Version string `json:"version"`
	// HeartBeat 心跳
	HeartBeat struct {
		// Enable 是否启用
		Enable bool `json:"enable"`
		// Interval 心跳间隔
		Interval int `json:"interval"`
	}
}

OneBotConfig OneBot协议配置

type RawRequestType

type RawRequestType struct {
	// *Request 请求头
	*Request
	// Param 各种参数
	Param map[string]any `json:"params"`
}

RawRequestType 最原始的动作请求, 用于兼容和各种连接交互

type Request

type Request struct {
	// Action 动作名称
	Action string `json:"action"`
	// Echo 原样返回
	Echo string `json:"echo"`
	// Self 事件发起Bot
	Self Self `json:"self"`
	// ConnectionUUID 内部使用: 判断发出请求的连接UUID 用于返回时寻找连接
	ConnectionUUID string
	// contains filtered or unexported fields
}

Request 动作请求

func (*Request) GetID

func (r *Request) GetID() string

func (*Request) NewID

func (r *Request) NewID()

func (*Request) SetID

func (r *Request) SetID(s string)

type RequestDeleteMessage

type RequestDeleteMessage struct {
	*Request
	// MessageId 唯一的消息 ID
	MessageId string `json:"message_id"`
	// contains filtered or unexported fields
}

RequestDeleteMessage 撤回消息

Reference: https://12.onebot.dev/interface/message/actions/#delete_message

func (*RequestDeleteMessage) Do

func (r *RequestDeleteMessage) Do() any

Do 执行

执行用户自定义函数

func (*RequestDeleteMessage) New

func (*RequestDeleteMessage) New() any

New 构造函数

type RequestGetChannelInfo

type RequestGetChannelInfo struct {
	*Request
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// ChannelId 频道 ID
	ChannelId string `json:"channel_id"`
	// contains filtered or unexported fields
}

RequestGetChannelInfo 获取频道信息

Reference: https://12.onebot.dev/interface/guild/actions/#get_channel_info

func (*RequestGetChannelInfo) Do

func (r *RequestGetChannelInfo) Do() any

Do 执行

func (*RequestGetChannelInfo) New

func (*RequestGetChannelInfo) New() any

New 构造函数

type RequestGetChannelList

type RequestGetChannelList struct {
	*Request
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// JoinedOnly 只获取机器人账号已加入的频道列表
	JoinedOnly bool `json:"joined_only"`
	// contains filtered or unexported fields
}

RequestGetChannelList 获取频道列表

Reference: https://12.onebot.dev/interface/guild/actions/#get_channel_list

func (*RequestGetChannelList) Do

func (r *RequestGetChannelList) Do() any

Do 执行

func (*RequestGetChannelList) New

func (*RequestGetChannelList) New() any

New 构造函数

type RequestGetChannelMemberInfo

type RequestGetChannelMemberInfo struct {
	*Request
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// ChannelId 频道 ID
	ChannelId string `json:"channel_id"`
	// UserId 用户 ID
	UserId string `json:"user_id"`
	// contains filtered or unexported fields
}

RequestGetChannelMemberInfo 获取频道成员信息

Reference: https://12.onebot.dev/interface/guild/actions/#get_channel_member_info

func (*RequestGetChannelMemberInfo) Do

Do 执行

func (*RequestGetChannelMemberInfo) New

New 构造函数

type RequestGetChannelMemberList

type RequestGetChannelMemberList struct {
	*Request
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// ChannelId 频道 ID
	ChannelId string `json:"channel_id"`
	// contains filtered or unexported fields
}

RequestGetChannelMemberList 获取频道成员列表

Reference: https://12.onebot.dev/interface/guild/actions/#get_channel_member_list

func (*RequestGetChannelMemberList) Do

Do 执行

func (*RequestGetChannelMemberList) New

New 构造函数

type RequestGetFile

type RequestGetFile struct {
	*Request
	// FileId 文件 ID
	FileId string `json:"file_id"`
	// Type 获取文件的方式,可以为 url、path、data 或扩展的方式
	Type string `json:"type"`
	// contains filtered or unexported fields
}

RequestGetFile 获取文件

Reference: https://12.onebot.dev/interface/file/actions/#get_file

func (*RequestGetFile) Do

func (r *RequestGetFile) Do() any

Do 执行

func (*RequestGetFile) New

func (*RequestGetFile) New() any

New 构造函数

type RequestGetFileFragmented

type RequestGetFileFragmented struct {
	*Request
	// Stage 上传阶段,必须为 prepare 传输阶段,必须为 transfer
	Stage string `json:"stage"`
	// FileID 文件 ID
	FileID string `json:"file_id"`
	// Offset 本次传输的文件偏移,单位:字节
	Offset int64 `json:"offset"`
	// Size 本次传输的文件大小,单位:字节
	Size int64 `json:"size"`
	// contains filtered or unexported fields
}

RequestGetFileFragmented 获取文件分片

Reference: https://12.onebot.dev/interface/file/actions/#get_file_fragmented

func (*RequestGetFileFragmented) Do

func (r *RequestGetFileFragmented) Do() any

Do 执行

func (*RequestGetFileFragmented) New

New 构造函数

type RequestGetFriendList

type RequestGetFriendList struct {
	*Request
	// contains filtered or unexported fields
}

RequestGetFriendList 获取好友列表

获取机器人的关注者或好友列表。

Reference: https://12.onebot.dev/interface/user/actions/#get_friend_list

func (*RequestGetFriendList) Do

func (r *RequestGetFriendList) Do() any

Do 执行

func (*RequestGetFriendList) New

func (*RequestGetFriendList) New() any

New 构造函数

type RequestGetGroupInfo

type RequestGetGroupInfo struct {
	*Request
	// GroupId 	群 ID
	GroupId string `json:"group_id"`
	// contains filtered or unexported fields
}

RequestGetGroupInfo 获取群信息

Reference: https://12.onebot.dev/interface/group/actions/#get_group_info

func (*RequestGetGroupInfo) Do

func (r *RequestGetGroupInfo) Do() any

Do 执行

func (*RequestGetGroupInfo) New

func (*RequestGetGroupInfo) New() any

New 构造函数

type RequestGetGroupList

type RequestGetGroupList struct {
	*Request
	// contains filtered or unexported fields
}

RequestGetGroupList 获取群列表

Reference: https://12.onebot.dev/interface/group/actions/#get_group_list

func (*RequestGetGroupList) Do

func (r *RequestGetGroupList) Do() any

Do 执行

func (*RequestGetGroupList) New

func (*RequestGetGroupList) New() any

New 构造函数

type RequestGetGroupMemberInfo

type RequestGetGroupMemberInfo struct {
	*Request
	// GroupId 	群 ID
	GroupId string `json:"group_id"`
	// UserId 	用户 ID
	UserId string `json:"user_id"`
	// contains filtered or unexported fields
}

RequestGetGroupMemberInfo 获取群成员信息

Reference: https://12.onebot.dev/interface/group/actions/#get_group_member_info

func (*RequestGetGroupMemberInfo) Do

Do 执行

func (*RequestGetGroupMemberInfo) New

New 构造函数

type RequestGetGroupMemberList

type RequestGetGroupMemberList struct {
	*Request
	// GroupId 	群 ID
	GroupId string `json:"group_id"`
	// contains filtered or unexported fields
}

RequestGetGroupMemberList 获取群成员列表

Reference: https://12.onebot.dev/interface/group/actions/#get_group_member_list

func (*RequestGetGroupMemberList) Do

Do 执行

func (*RequestGetGroupMemberList) New

New 构造函数

type RequestGetGuildInfo

type RequestGetGuildInfo struct {
	*Request
	// GuildIf 群组 ID
	GuildId string `json:"guild_id"`
	// contains filtered or unexported fields
}

RequestGetGuildInfo 获取群组信息

Reference: https://12.onebot.dev/interface/guild/actions/#get_guild_info

func (*RequestGetGuildInfo) Do

func (r *RequestGetGuildInfo) Do() (e any)

Do 执行

func (*RequestGetGuildInfo) New

func (r *RequestGetGuildInfo) New() any

New 构造函数

type RequestGetGuildList

type RequestGetGuildList struct {
	*Request
	// contains filtered or unexported fields
}

RequestGetGuildList 获取群组列表

Reference: https://12.onebot.dev/interface/guild/actions/#get_guild_list

func (*RequestGetGuildList) Do

func (r *RequestGetGuildList) Do() any

Do 执行

func (*RequestGetGuildList) New

func (*RequestGetGuildList) New() any

New 构造函数

type RequestGetGuildMemberInfo

type RequestGetGuildMemberInfo struct {
	*Request
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// UserId 用户 ID
	UserId string `json:"user_id"`
	// contains filtered or unexported fields
}

RequestGetGuildMemberInfo 获取群组成员信息

Reference: https://12.onebot.dev/interface/guild/actions/#get_guild_member_info

func (*RequestGetGuildMemberInfo) Do

Do 执行

func (*RequestGetGuildMemberInfo) New

New 构造函数

type RequestGetGuildMemberList

type RequestGetGuildMemberList struct {
	*Request
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// contains filtered or unexported fields
}

RequestGetGuildMemberList 获取群组成员列表

Reference: https://12.onebot.dev/interface/guild/actions/#get_guild_member_list

func (*RequestGetGuildMemberList) Do

Do 执行

func (*RequestGetGuildMemberList) New

New 构造函数

type RequestGetLatestEvents

type RequestGetLatestEvents struct {
	*Request
	// Limit 获取的事件数量上限,0 表示不限制
	Limit int64 `json:"limit"`
	// Timeout 没有事件时最多等待的秒数,0 表示使用短轮询,不等待
	Timeout int64 `json:"timeout"`
	// contains filtered or unexported fields
}

RequestGetLatestEvents 获取最新事件列表

仅 HTTP 通信方式必须支持,用于轮询获取事件。

Reference: https://12.onebot.dev/interface/meta/actions/#get_latest_events

func (*RequestGetLatestEvents) Do

func (r *RequestGetLatestEvents) Do() any

Do 执行

执行用户自定义函数

func (*RequestGetLatestEvents) New

func (*RequestGetLatestEvents) New() any

New 构造函数

type RequestGetSelfInfo

type RequestGetSelfInfo struct {
	*Request
	// contains filtered or unexported fields
}

RequestGetSelfInfo 获取机器人自身信息

Reference: https://12.onebot.dev/interface/user/actions/#get_self_info

func (*RequestGetSelfInfo) Do

func (r *RequestGetSelfInfo) Do() (e any)

Do 执行

func (*RequestGetSelfInfo) New

func (*RequestGetSelfInfo) New() any

New 构造函数

type RequestGetStatus

type RequestGetStatus struct {
	*Request
	// contains filtered or unexported fields
}

RequestGetStatus 获取运行状态

Reference: https://12.onebot.dev/interface/meta/actions/#get_status

func (*RequestGetStatus) Do

func (r *RequestGetStatus) Do() any

Do 执行

执行用户自定义函数

func (*RequestGetStatus) New

func (*RequestGetStatus) New() any

New 构造函数

type RequestGetSupportedActions

type RequestGetSupportedActions struct {
	*Request
	// contains filtered or unexported fields
}

RequestGetSupportedActions 获取支持的动作列表

Reference: https://12.onebot.dev/interface/meta/actions/#get_supported_actions

func (*RequestGetSupportedActions) Do

Do 执行

执行用户自定义函数

func (*RequestGetSupportedActions) New

New 构造函数

type RequestGetUserInfo

type RequestGetUserInfo struct {
	*Request
	// UserId 用户 ID,可以是好友,也可以是陌生人
	UserId string `json:"user_id"`
	// contains filtered or unexported fields
}

RequestGetUserInfo 获取用户信息

Reference: https://12.onebot.dev/interface/user/actions/#get_user_info

func (*RequestGetUserInfo) Do

func (r *RequestGetUserInfo) Do() (e any)

Do 执行

func (*RequestGetUserInfo) New

func (*RequestGetUserInfo) New() any

New 构造函数

type RequestGetVersion

type RequestGetVersion struct {
	*Request
	// contains filtered or unexported fields
}

RequestGetVersion 获取版本信息

Reference: https://12.onebot.dev/interface/meta/actions/#get_version

func (*RequestGetVersion) Do

func (r *RequestGetVersion) Do() any

Do 执行

执行用户自定义函数

func (*RequestGetVersion) New

func (*RequestGetVersion) New() any

New 构造函数

type RequestInterface

type RequestInterface interface {
	// Do 执行动作
	// e 返回的Response 需要符合Response的类型
	Do() (e any)
	// New 返回一个新的RequestInterface
	New() any
}

RequestInterface 动作请求接口

func HandleActionDeleteMessage

func HandleActionDeleteMessage(f func(events *RequestDeleteMessage) *ResponseDeleteMessage) (string, RequestInterface)

HandleActionDeleteMessage 处理DeleteMessage请求

func HandleActionGetChannelInfo

func HandleActionGetChannelInfo(f func(events *RequestGetChannelInfo) *ResponseGetChannelInfo) RequestInterface

HandleActionGetChannelInfo 处理GetChannelInfo请求

func HandleActionGetChannelList

func HandleActionGetChannelList(f func(events *RequestGetChannelList) *ResponseGetChannelList) RequestInterface

HandleActionGetChannelList 处理GetChannelList请求

func HandleActionGetChannelMemberInfo

func HandleActionGetChannelMemberInfo(f func(events *RequestGetChannelMemberInfo) *ResponseGetChannelMemberInfo) RequestInterface

HandleActionGetChannelMemberInfo 处理GetChannelMemberInfo请求

func HandleActionGetChannelMemberList

func HandleActionGetChannelMemberList(f func(events *RequestGetChannelMemberList) *ResponseGetChannelMemberList) RequestInterface

HandleActionGetChannelMemberList 处理GetChannelMemberList请求

func HandleActionGetFile

func HandleActionGetFile(f func(events *RequestGetFile) *ResponseGetFile) RequestInterface

HandleActionGetFile 处理GetFile请求

func HandleActionGetFileFragmented

func HandleActionGetFileFragmented(f func(events *RequestGetFileFragmented) *ResponseGetFileFragmented) RequestInterface

HandleActionGetFileFragmented 处理GetFileFragmented请求

func HandleActionGetFriendList

func HandleActionGetFriendList(f func(events *RequestGetFriendList) *ResponseGetFriendList) RequestInterface

HandleActionGetFriendList 处理GetFriendList请求

func HandleActionGetGroupInfo

func HandleActionGetGroupInfo(f func(events *RequestGetGroupInfo) *ResponseGetGroupInfo) RequestInterface

HandleActionGetGroupInfo 处理GetGroupInfo请求

func HandleActionGetGroupList

func HandleActionGetGroupList(f func(events *RequestGetGroupList) *ResponseGetGroupList) RequestInterface

HandleActionGetGroupList 处理GetGroupList请求

func HandleActionGetGroupMemberInfo

func HandleActionGetGroupMemberInfo(f func(events *RequestGetGroupMemberInfo) *ResponseGetGroupMemberInfo) RequestInterface

HandleActionGetGroupMemberInfo 处理GetGroupMemberInfo请求

func HandleActionGetGroupMemberList

func HandleActionGetGroupMemberList(f func(events *RequestGetGroupMemberList) *ResponseGetGroupMemberList) RequestInterface

HandleActionGetGroupMemberList 处理GetGroupMemberList请求

func HandleActionGetGuildInfo

func HandleActionGetGuildInfo(f func(events *RequestGetGuildInfo) *ResponseGetGuildInfo) RequestInterface

HandleActionGetGuildInfo 处理GetGuildInfo请求

func HandleActionGetGuildList

func HandleActionGetGuildList(f func(events *RequestGetGuildList) *ResponseGetGuildList) RequestInterface

HandleActionGetGuildList 处理GetGuildList请求

func HandleActionGetGuildMemberInfo

func HandleActionGetGuildMemberInfo(f func(events *RequestGetGuildMemberInfo) *ResponseGetGuildMemberInfo) RequestInterface

HandleActionGetGuildMemberInfo 处理GetGuildMemberInfo请求

func HandleActionGetGuildMemberList

func HandleActionGetGuildMemberList(f func(events *RequestGetGuildMemberList) *ResponseGetGuildMemberList) RequestInterface

HandleActionGetGuildMemberList 处理GetGuildMemberList请求

func HandleActionGetLatestEvents

func HandleActionGetLatestEvents(f func(events *RequestGetLatestEvents) *ResponseGetLatestEvents) RequestInterface

HandleActionGetLatestEvents 处理GetLatestEvents请求

func HandleActionGetSelfInfo

func HandleActionGetSelfInfo(f func(events *RequestGetSelfInfo) *ResponseGetSelfInfo) RequestInterface

HandleActionGetSelfInfo 处理GetSelfInfo请求

func HandleActionGetStatus

func HandleActionGetStatus(f func(events *RequestGetStatus) *ResponseGetStatus) RequestInterface

HandleActionGetStatus 处理GetStatus请求

func HandleActionGetSupportedActions

func HandleActionGetSupportedActions(f func(events *RequestGetSupportedActions) *ResponseGetSupportedActions) RequestInterface

HandleActionGetSupportedActions 处理GetSupportedActions请求

func HandleActionGetUserInfo

func HandleActionGetUserInfo(f func(events *RequestGetUserInfo) *ResponseGetUserInfo) RequestInterface

HandleActionGetUserInfo 处理GetUserInfo请求

func HandleActionGetVersion

func HandleActionGetVersion(f func(events *RequestGetVersion) *ResponseGetVersion) RequestInterface

HandleActionGetVersion 处理GetVersion请求

func HandleActionLeaveChannel

func HandleActionLeaveChannel(f func(events *RequestLeaveChannel) *ResponseLeaveChannel) RequestInterface

HandleActionLeaveChannel 处理LeaveChannel请求

func HandleActionLeaveGroup

func HandleActionLeaveGroup(f func(events *RequestLeaveGroup) *ResponseLeaveGroup) RequestInterface

HandleActionLeaveGroup 处理LeaveGroup请求

func HandleActionLeaveGuild

func HandleActionLeaveGuild(f func(events *RequestLeaveGuild) *ResponseLeaveGuild) RequestInterface

HandleActionLeaveGuild 处理LeaveGuild请求

func HandleActionSendMessage

func HandleActionSendMessage(f func(events *RequestSendMessage) *ResponseSendMessage) RequestInterface

HandleActionSendMessage 处理SendMessage请求

func HandleActionSetChannelName

func HandleActionSetChannelName(f func(events *RequestSetChannelName) *ResponseSetChannelName) RequestInterface

HandleActionSetChannelName 处理SetChannelName请求

func HandleActionSetGroupName

func HandleActionSetGroupName(f func(events *RequestSetGroupName) *ResponseSetGroupName) RequestInterface

HandleActionSetGroupName 处理SetGroupName请求

func HandleActionSetGuildName

func HandleActionSetGuildName(f func(events *RequestSetGuildName) *ResponseSetGuildName) RequestInterface

HandleActionSetGuildName 处理SetGuildName请求

func HandleActionUploadFile

func HandleActionUploadFile(f func(events *RequestUploadFile) *ResponseUploadFile) RequestInterface

HandleActionUploadFile 处理UploadFile请求

func HandleActionUploadFileFragmented

func HandleActionUploadFileFragmented(f func(events *RequestUploadFileFragmented) *ResponseUploadFileFragmented) RequestInterface

HandleActionUploadFileFragmented 处理UploadFileFragmented请求

type RequestLeaveChannel

type RequestLeaveChannel struct {
	*Request
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// ChannelId 频道 ID
	ChannelId string `json:"channel_id"`
	// contains filtered or unexported fields
}

RequestLeaveChannel 离开频道

Reference: https://12.onebot.dev/interface/guild/actions/#leave_channel

func (*RequestLeaveChannel) Do

func (r *RequestLeaveChannel) Do() any

Do 执行

func (*RequestLeaveChannel) New

func (*RequestLeaveChannel) New() any

New 构造函数

type RequestLeaveGroup

type RequestLeaveGroup struct {
	*Request
	// GroupId 群 ID
	GroupId string `json:"group_id"`
	// contains filtered or unexported fields
}

RequestLeaveGroup 退出群

Reference: https://12.onebot.dev/interface/group/actions/#leave_group

func (*RequestLeaveGroup) Do

func (r *RequestLeaveGroup) Do() any

Do 执行

func (*RequestLeaveGroup) New

func (*RequestLeaveGroup) New() any

New 构造函数

type RequestLeaveGuild

type RequestLeaveGuild struct {
	*Request
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// contains filtered or unexported fields
}

RequestLeaveGuild 退出群组

Reference: https://12.onebot.dev/interface/guild/actions/#leave_guild

func (*RequestLeaveGuild) Do

func (r *RequestLeaveGuild) Do() any

Do 执行

func (*RequestLeaveGuild) New

func (*RequestLeaveGuild) New() any

New 构造函数

type RequestSendMessage

type RequestSendMessage struct {
	*Request
	// DetailType 发送的类型,可以为 private、group、channel 或扩展的类型,和消息事件的 detail_type 字段对应
	DetailType string `json:"detail_type"`
	// UserId 用户 ID,当 detail_type 为 private 时必须传入
	UserId string `json:"user_id"`
	// GroupId	群 ID,当 detail_type 为 group 时必须传入
	GroupId string `json:"group_id"`
	// GuildId Guild 群组 ID,当 detail_type 为 channel 时必须传入
	GuildId string `json:"guild_id"`
	// ChannelId 频道 ID,当 detail_type 为 channel 时必须传入
	ChannelId string `json:"channel_id"`
	// Message 消息段列表 消息内容
	Message []Segment `json:"message"`
	// contains filtered or unexported fields
}

RequestSendMessage 发送消息

对于不同平台的 detail_type,如果符合标准所定义的类型,如私聊对应 private、群组对应 group,则建议使用标准定义的 detail_type 和 xxx_id。

对于其它具体类型,例如过去 QQ 还存在讨论组的情况,可以指定 detail_type 为 qq.discuss,然后参数使用 qq.discuss_id 指示讨论组 ID。

更多详细扩展规则请参考 扩展规则 https://12.onebot.dev/interface/rules/

Reference: https://12.onebot.dev/interface/message/actions/#send_message

func (*RequestSendMessage) Do

func (r *RequestSendMessage) Do() any

Do 执行

执行用户自定义函数

func (*RequestSendMessage) New

func (*RequestSendMessage) New() any

New 构造函数

type RequestSetChannelName

type RequestSetChannelName struct {
	*Request
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// ChannelId 频道 ID
	ChannelId string `json:"channel_id"`
	// ChannelName 新频道名称
	ChannelName string `json:"channel_name"`
	// contains filtered or unexported fields
}

RequestSetChannelName 设置频道名称

Reference: https://12.onebot.dev/interface/guild/actions/#set_channel_name

func (*RequestSetChannelName) Do

func (r *RequestSetChannelName) Do() any

Do 执行

func (*RequestSetChannelName) New

func (*RequestSetChannelName) New() any

New 构造函数

type RequestSetGroupName

type RequestSetGroupName struct {
	*Request
	// GroupId 群 ID
	GroupId string `json:"group_id"`
	// GroupName 新群名称
	GroupName string `json:"group_name"`
	// contains filtered or unexported fields
}

RequestSetGroupName 设置群名称

Reference: https://12.onebot.dev/interface/group/actions/#set_group_name

func (*RequestSetGroupName) Do

func (r *RequestSetGroupName) Do() any

Do 执行

func (*RequestSetGroupName) New

func (*RequestSetGroupName) New() any

New 构造函数

type RequestSetGuildName

type RequestSetGuildName struct {
	*Request
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// GuildName 新群组名称
	GuildName string `json:"guild_name"`
	// contains filtered or unexported fields
}

RequestSetGuildName 设置群组名称

Reference: https://12.onebot.dev/interface/guild/actions/#set_guild_name

func (*RequestSetGuildName) Do

func (r *RequestSetGuildName) Do() any

Do 执行

func (*RequestSetGuildName) New

func (*RequestSetGuildName) New() any

New 构造函数

type RequestUploadFile

type RequestUploadFile struct {
	*Request
	// Name 文件名,如 foo.jpg
	Name string `json:"name"`
	// Url 文件 URL,当 type 为 url 时必须返回,应用端必须能以 HTTP(S) 协议从此 URL 下载文件
	Url string `json:"url"`
	// Headers	下载 URL 时需要添加的 HTTP 请求头,可选返回
	Headers map[string]string `json:"headers"`
	// Path 文件路径,当 type 为 path 时必须返回,应用端必须能从此路径访问文件
	Path string `json:"path"`
	// Data 文件数据,当 type 为 data 时必须返回
	Data []byte `json:"data"`
	// Sha256 文件数据(原始二进制)的 SHA256 校验和,全小写,可选返回
	Sha256 string `json:"sha256"`
	// Type 	上传文件的方式,可以为 url、path、data 或扩展的方式
	Type string `json:"type"`
	// contains filtered or unexported fields
}

RequestUploadFile 上传文件

Reference: https://12.onebot.dev/interface/file/actions/#upload_file

func (*RequestUploadFile) Do

func (r *RequestUploadFile) Do() any

Do 执行

func (*RequestUploadFile) New

func (*RequestUploadFile) New() any

New 构造函数

type RequestUploadFileFragmented

type RequestUploadFileFragmented struct {
	*Request
	// Stage 上传阶段,必须为 prepare 传输阶段,必须为 transfer
	Stage string `json:"stage"`
	// Name 文件名,如 foo.jpg
	Name string `json:"name"`
	// TotalSize 文件总大小,单位为字节
	TotalSize int64 `json:"total_size"`
	// FileID 准备阶段返回的文件 ID
	FileID string `json:"file_id"`
	// Offset 	本次传输的文件偏移,单位:字节
	Offset int64 `json:"offset"`
	// Data 本次传输的文件数据
	Data []byte `json:"data"`
	// Sha256 本次传输的文件数据(原始二进制)的 SHA256 校验和,全小写
	Sha256 string `json:"sha256"`
	// contains filtered or unexported fields
}

RequestUploadFileFragmented 上传文件分片

Reference: https://12.onebot.dev/interface/file/actions/#upload_file_fragmented

func (*RequestUploadFileFragmented) Do

Do 执行

func (*RequestUploadFileFragmented) New

New 构造函数

type Response

type Response struct {
	// Status 响应状态
	// 必须为 StatusOk 或 StatusFailed
	Status string `json:"status"`
	// RetCode 返回码 对应上文的 ResponseCodeXXX
	Retcode int `json:"retcode"`
	// Message 错误信息,当动作执行失败时,建议在此填写人类可读的错误信息,当执行成功时,应为空字符串
	Message string `json:"message"`
	// Echo 应原样返回动作请求中的 echo 字段值
	Echo string `json:"echo"`
	// contains filtered or unexported fields
}

Response 动作响应 Reference: https://12.onebot.dev/connect/data-protocol/action-response/

func (*Response) GetID

func (r *Response) GetID() string

GetID 获取请求ID

func (*Response) SetID

func (r *Response) SetID(s string)

SetID 设置请求ID

type ResponseDeleteMessage

type ResponseDeleteMessage struct {
	*Response
}

ResponseDeleteMessage 撤回消息

Reference: https://12.onebot.dev/interface/message/actions/#delete_message

空的

func NewResponseDeleteMessage

func NewResponseDeleteMessage(retCode int) *ResponseDeleteMessage

NewResponseDeleteMessage 撤回消息 构造函数

type ResponseGetChannelInfo

type ResponseGetChannelInfo struct {
	*Response
	// ChannelId 频道 ID
	ChannelId string `json:"channel_id"`
	// ChannelName 频道名称
	ChannelName string `json:"channel_name"`
}

ResponseGetChannelInfo 获取频道信息

Reference: https://12.onebot.dev/interface/guild/actions/#get_channel_info

func NewResponseGetChannelInfo

func NewResponseGetChannelInfo(retCode int) *ResponseGetChannelInfo

NewResponseGetChannelInfo 获取频道信息 构造函数

type ResponseGetChannelList

type ResponseGetChannelList struct {
	*Response
	// Channels 频道列表
	Channels []struct {
		// ChannelId 频道 ID
		ChannelId string `json:"channel_id"`
		// ChannelName 频道名称
		ChannelName string `json:"channel_name"`
	}
}

ResponseGetChannelList 获取频道列表

Reference: https://12.onebot.dev/interface/guild/actions/#get_channel_list

func NewResponseGetChannelList

func NewResponseGetChannelList(retCode int) *ResponseGetChannelList

NewResponseGetChannelList 获取频道列表 构造函数

type ResponseGetChannelMemberInfo

type ResponseGetChannelMemberInfo struct {
	*Response
	// UserId 用户 ID
	UserId string `json:"user_id"`
	// UserName 用户名称/姓名/昵称
	UserName string `json:"user_name"`
	// UserDisplayName 	用户设置的群组内显示名称或账号显示名称,若无则为空字符串
	UserDisplayName string `json:"user_displayname"`
}

ResponseGetChannelMemberInfo 获取频道成员信息

Reference: https://12.onebot.dev/interface/guild/actions/#get_channel_member_info

func NewResponseGetChannelMemberInfo

func NewResponseGetChannelMemberInfo(retCode int) *ResponseGetChannelMemberInfo

NewResponseGetChannelMemberInfo 获取频道成员信息 构造函数

type ResponseGetChannelMemberList

type ResponseGetChannelMemberList struct {
	*Response
	// Members 频道成员列表
	Members []struct {
		// UserId 用户 ID
		UserId string `json:"user_id"`
		// UserName 用户名称/姓名/昵称
		UserName string `json:"user_name"`
		// UserDisplayName 	用户设置的群组内显示名称或账号显示名称,若无则为空字符串
		UserDisplayName string `json:"user_displayname"`
	}
}

ResponseGetChannelMemberList 获取频道成员列表

Reference: https://12.onebot.dev/interface/guild/actions/#get_channel_member_list

func NewResponseGetChannelMemberList

func NewResponseGetChannelMemberList(retCode int) *ResponseGetChannelMemberList

NewResponseGetChannelMemberList 获取频道成员列表 构造函数

type ResponseGetFile

type ResponseGetFile struct {
	*Response
	// Name 文件名,如 foo.jpg
	Name string `json:"name"`
	// Url 文件 URL,当 type 为 url 时必须返回,应用端必须能以 HTTP(S) 协议从此 URL 下载文件
	Url string `json:"url"`
	// Headers	下载 URL 时需要添加的 HTTP 请求头,可选返回
	Headers map[string]string `json:"headers"`
	// Path 文件路径,当 type 为 path 时必须返回,应用端必须能从此路径访问文件
	Path string `json:"path"`
	// Data 文件数据,当 type 为 data 时必须返回
	Data []byte `json:"data"`
	// Sha256 文件数据(原始二进制)的 SHA256 校验和,全小写,可选返回
	Sha256 string `json:"sha256"`
}

ResponseGetFile 获取文件

Reference: https://12.onebot.dev/interface/file/actions/#get_file

这里虽然说“必须返回”,但如果平台真的无法获得 URL,当用户请求 type 为 url 时,可以返回 10004 Unsupported Param。具体见 接口定义 - 概述 中对 OneBot 实现的要求。

func NewResponseGetFile

func NewResponseGetFile(retCode int) *ResponseGetFile

NewResponseGetFile 获取文件 构造函数

type ResponseGetFileFragmented

type ResponseGetFileFragmented struct {
	*Response
	// Name 文件名,如 foo.jpg
	Name string `json:"name"`
	// TotalSize 文件完整大小,单位:字节
	TotalSize int `json:"total_size"`
	// Sha256 文件数据(原始二进制)的 SHA256 校验和,全小写
	Sha256 string `json:"sha256"`
	// Data 本次传输的文件数据
	Data []byte `json:"data"`
}

ResponseGetFileFragmented 获取分片文件

Reference: https://12.onebot.dev/interface/file/actions/#get_file_fragmented

func NewResponseGetFileFragmentedStart

func NewResponseGetFileFragmentedStart(retCode int) *ResponseGetFileFragmented

NewResponseGetFileFragmentedStart 获取分片文件 构造函数

type ResponseGetFriendList

type ResponseGetFriendList struct {
	*Response
	// Friends 好友列表
	Friends []struct {
		// UserId 用户 ID
		UserId string `json:"user_id"`
		// UserName 用户名称/姓名/昵称
		UserName string `json:"user_name"`
		// UserDisplayName 用户设置的显示名称,若无则为空字符串
		UserDisplayName string `json:"user_displayname"`
		// UserRemark 机器人账号对该用户的备注名称,若无则为空字符串
		UserRemark string `json:"user_remark"`
	}
}

ResponseGetFriendList 获取好友列表

Reference: https://12.onebot.dev/interface/user/actions/#get_friend_list

func NewResponseGetFriendList

func NewResponseGetFriendList(retCode int) *ResponseGetFriendList

NewResponseGetFriendList 获取好友列表 构造函数

type ResponseGetGroupInfo

type ResponseGetGroupInfo struct {
	*Response
	// GroupId 群号
	GroupId string `json:"group_id"`
	// GroupName 群名称
	GroupName string `json:"group_name"`
}

ResponseGetGroupInfo 获取群信息

Reference: https://12.onebot.dev/interface/group/actions/#get_group_info

func NewResponseGetGroupInfo

func NewResponseGetGroupInfo(retCode int) *ResponseGetGroupInfo

NewResponseGetGroupInfo 获取群信息 构造函数

type ResponseGetGroupList

type ResponseGetGroupList struct {
	*Response
	Groups []struct {
		// GroupId 群号
		GroupId string `json:"group_id"`
		// GroupName 群名称
		GroupName string `json:"group_name"`
	}
}

ResponseGetGroupList 获取群列表

Reference: https://12.onebot.dev/interface/group/actions/#get_group_list

func NewResponseGetGroupList

func NewResponseGetGroupList(retCode int) *ResponseGetGroupList

NewResponseGetGroupList 获取群列表 构造函数

type ResponseGetGroupMemberInfo

type ResponseGetGroupMemberInfo struct {
	*Response
	// UserId 用户 ID
	UserId string `json:"user_id"`
	// UserName 用户名称/姓名/昵称
	UserName string `json:"user_name"`
	// UserDisplayName 用户设置的群内显示名称或账号显示名称,若无则为空字符串
	UserDisplayName string `json:"user_displayname"`
}

ResponseGetGroupMemberInfo 获取群成员信息

Reference: https://12.onebot.dev/interface/group/actions/#get_group_member_info

func NewResponseGetGroupMemberInfo

func NewResponseGetGroupMemberInfo(retCode int) *ResponseGetGroupMemberInfo

NewResponseGetGroupMemberInfo 获取群成员信息 构造函数

type ResponseGetGroupMemberList

type ResponseGetGroupMemberList struct {
	*Response
	// Members 群成员列表
	Members []struct {
		// UserId 用户 ID
		UserId string `json:"user_id"`
		// UserName 用户名称/姓名/昵称
		UserName string `json:"user_name"`
		// UserDisplayName 用户设置的群内显示名称或账号显示名称,若无则为空字符串
		UserDisplayName string `json:"user_displayname"`
	}
}

ResponseGetGroupMemberList 获取群成员列表

Reference: https://12.onebot.dev/interface/group/actions/#get_group_member_list

func NewResponseGetGroupMemberList

func NewResponseGetGroupMemberList(retCode int) *ResponseGetGroupMemberList

NewResponseGetGroupMemberList 获取群成员列表 构造函数

type ResponseGetGuildInfo

type ResponseGetGuildInfo struct {
	*Response
	// GuildId 群组 ID
	GuildId string `json:"guild_id"`
	// GuildName 群组名称
	GuildName string `json:"guild_name"`
}

ResponseGetGuildInfo 获取群组信

Reference: https://12.onebot.dev/interface/guild/actions/#get_guild_info

func NewResponseGetGuildInfo

func NewResponseGetGuildInfo(retCode int) *ResponseGetGuildInfo

NewResponseGetGuildInfo 获取群组信 构造函数

type ResponseGetGuildList

type ResponseGetGuildList struct {
	*Response
	// Guilds 群组列表
	Guilds []struct {
		// GuildId 群组 ID
		GuildId string `json:"guild_id"`
		// GuildName 群组名称
		GuildName string `json:"guild_name"`
	}
}

ResponseGetGuildList 获取群组列表

获取机器人加入的群组列表。

Reference: https://12.onebot.dev/interface/guild/actions/#get_guild_list

func NewResponseGetGuildList

func NewResponseGetGuildList(retCode int) *ResponseGetGuildList

NewResponseGetGuildList 获取群组列表 构造函数

type ResponseGetGuildMemberInfo

type ResponseGetGuildMemberInfo struct {
	*Response
	// UserId 用户 ID
	UserId string `json:"user_id"`
	// UserName 用户名称/姓名/昵称
	UserName string `json:"user_name"`
	// UserDisplayName 	用户设置的群组内显示名称或账号显示名称,若无则为空字符串
	UserDisplayName string `json:"user_displayname"`
}

ResponseGetGuildMemberInfo 获取群组成员信息

Reference: https://12.onebot.dev/interface/guild/actions/#get_guild_member_info

func NewResponseGetGuildMemberInfo

func NewResponseGetGuildMemberInfo(retCode int) *ResponseGetGuildMemberInfo

NewResponseGetGuildMemberInfo 获取群组成员信息 构造函数

type ResponseGetGuildMemberList

type ResponseGetGuildMemberList struct {
	*Response
	// Members 群组成员列表
	Members []struct {
		// UserId 用户 ID
		UserId string `json:"user_id"`
		// UserName 用户名称/姓名/昵称
		UserName string `json:"user_name"`
		// UserDisplayName 	用户设置的群组内显示名称或账号显示名称,若无则为空字符串
		UserDisplayName string `json:"user_displayname"`
	}
}

ResponseGetGuildMemberList 获取群组成员列表

Reference: https://12.onebot.dev/interface/guild/actions/#get_guild_member_list

func NewResponseGetGuildMemberList

func NewResponseGetGuildMemberList(retCode int) *ResponseGetGuildMemberList

NewResponseGetGuildMemberList 获取群组成员列表 构造函数

type ResponseGetLatestEvents

type ResponseGetLatestEvents struct {
	*Response
	// Events 事件列表
	Events []any
}

ResponseGetLatestEvents 获取最近的事件

func NewResponseGetLatestEvents

func NewResponseGetLatestEvents(retCode int) *ResponseGetLatestEvents

NewResponseGetLatestEvents 获取最近的事件 构造函数

type ResponseGetSelfInfo

type ResponseGetSelfInfo struct {
	*Response
	// UserId 机器人用户 ID
	UserId string `json:"user_id"`
	// Nickname 机器人名称/姓名/昵称
	UserName string `json:"user_name"`
	// UserDisPlayName 机器人账号设置的显示名称,若无则为空字符串
	UserDisplayName string `json:"user_displayname"`
}

ResponseGetSelfInfo 获取机器人自身信息

Reference: https://12.onebot.dev/interface/user/actions/#get_self_info

func NewResponseGetSelfInfo

func NewResponseGetSelfInfo(retCode int) *ResponseGetSelfInfo

NewResponseGetSelfInfo 获取机器人自身信息

type ResponseGetStatus

type ResponseGetStatus struct {
	*Response

	Good bool `json:"good"`
	Bots []struct {
		Self   Self `json:"self"`
		Online bool `json:"online"`
		Extra  map[string]any
	} `json:"bots"`
}

ResponseGetStatus 获取运行状态

Reference: https://12.onebot.dev/interface/meta/actions/#get_status

func NewResponseGetStatus

func NewResponseGetStatus(retCode int) *ResponseGetStatus

NewResponseGetStatus 获取运行状态 构造函数

type ResponseGetSupportedActions

type ResponseGetSupportedActions struct {
	*Response
	// Actions 动作列表
	Actions []string
}

ResponseGetSupportedActions 获取支持的动作列表

Reference: https://12.onebot.dev/interface/meta/actions/#get_supported_actions

func NewResponseGetSupportedActions

func NewResponseGetSupportedActions(retCode int) *ResponseGetSupportedActions

NewResponseGetSupportedActions 获取支持的动作列表 构造函数

type ResponseGetUserInfo

type ResponseGetUserInfo struct {
	*Response
	// UserId 用户 ID
	UserId string `json:"user_id"`
	// UserName 用户名称/姓名/昵称
	UserName string `json:"user_name"`
	// UserDisplayName 用户设置的显示名称,若无则为空字符串
	UserDisplayName string `json:"user_displayname"`
	// UserRemark 机器人账号对该用户的备注名称,若无则为空字符串
	UserRemark string `json:"user_remark"`
}

ResponseGetUserInfo 获取用户信息

Reference: https://12.onebot.dev/interface/user/actions/#get_user_info

func NewResponseGetUserInfo

func NewResponseGetUserInfo(retCode int) *ResponseGetUserInfo

NewResponseGetUserInfo 获取用户信息 构造函数

type ResponseGetVersion

type ResponseGetVersion struct {
	*Response
	// Impl OneBot 实现名称,格式见 术语表
	Impl string `json:"impl"`
	// Version OneBot 实现的版本号
	Version string `json:"version"`
	// OneBotVersion OneBot 实现的 OneBot 标准版本号
	OnebotVersion string `json:"onebot_version"`
}

ResponseGetVersion 获取版本信息

Reference: https://12.onebot.dev/interface/meta/actions/#get_version

func NewResponseGetVersion

func NewResponseGetVersion(retCode int) *ResponseGetVersion

NewResponseGetVersion 获取版本信息 构造函数

type ResponseLeaveChannel

type ResponseLeaveChannel struct {
	*Response
}

ResponseLeaveChannel 退出频道

Reference: https://12.onebot.dev/interface/guild/actions/#leave_channel

func NewResponseLeaveChannel

func NewResponseLeaveChannel(retCode int) *ResponseLeaveChannel

NewResponseLeaveChannel 退出频道 构造函数

type ResponseLeaveGroup

type ResponseLeaveGroup struct {
	*Response
}

ResponseLeaveGroup 退群

Reference: https://12.onebot.dev/interface/group/actions/#leave_group

空的

func NewResponseLeaveGroup

func NewResponseLeaveGroup(retCode int) *ResponseLeaveGroup

NewResponseLeaveGroup 退群 构造函数

type ResponseLeaveGuild

type ResponseLeaveGuild struct {
	*Response
}

ResponseLeaveGuild 退群组

Reference: https://12.onebot.dev/interface/guild/actions/#leave_guild

func NewResponseLeaveGuild

func NewResponseLeaveGuild(retCode int) *ResponseLeaveGuild

NewResponseLeaveGuild 退群组 构造函数

type ResponseSendMessage

type ResponseSendMessage struct {
	*Response
	// MessageId 消息 ID
	MessageId string `json:"message_id"`
	// Time 消息成功发出的时间(Unix 时间戳),单位:秒
	Time float64 `json:"time"`
}

ResponseSendMessage 发送消息

Reference: https://12.onebot.dev/interface/message/actions/#send_message

func NewResponseSendMessage

func NewResponseSendMessage(retCode int) *ResponseSendMessage

NewResponseSendMessage 发送消息 构造函数

已经帮你生成好了MessageID和Time 直接返回就行

type ResponseSetChannelName

type ResponseSetChannelName struct {
	*Response
}

ResponseSetChannelName 设置频道名称

Reference: https://12.onebot.dev/interface/guild/actions/#set_channel_name

func NewResponseSetChannelName

func NewResponseSetChannelName(retCode int) *ResponseSetChannelName

NewResponseSetChannelName 设置频道名称 构造函数

type ResponseSetGroupName

type ResponseSetGroupName struct {
	*Response
}

ResponseSetGroupName 设置群名称

Reference: https://12.onebot.dev/interface/group/actions/#set_group_name

空的

func NewResponseSetGroupName

func NewResponseSetGroupName(retCode int) *ResponseSetGroupName

NewResponseSetGroupName 设置群名称 构造函数

type ResponseSetGuildName

type ResponseSetGuildName struct {
	*Response
}

ResponseSetGuildName 设置群组名称

Reference: https://12.onebot.dev/interface/guild/actions/#set_guild_name

func NewResponseSetGuildName

func NewResponseSetGuildName(retCode int) *ResponseSetGuildName

NewResponseSetGuildName 设置群组名称 构造函数

type ResponseUploadFile

type ResponseUploadFile struct {
	*Response
	// FileId 文件 ID
	FileId string `json:"file_id"`
}

ResponseUploadFile 上传文件

Reference: https://12.onebot.dev/interface/file/actions/#upload_file

func NewResponseUploadFile

func NewResponseUploadFile(retCode int) *ResponseUploadFile

NewResponseUploadFile 上传文件 构造函数

type ResponseUploadFileFragmented

type ResponseUploadFileFragmented struct {
	*Response
	// FileId 文件 ID,仅传输阶段使用
	FileId string `json:"file_id"`
}

ResponseUploadFileFragmented 上传分片文件

Reference: https://12.onebot.dev/interface/file/actions/#upload_file_fragmented

func NewResponseUploadFileFragmentedStart

func NewResponseUploadFileFragmentedStart(retCode int) *ResponseUploadFileFragmented

NewResponseUploadFileFragmentedStart 上传分片文件 构造函数

type Segment

type Segment struct {
	// Type 消息段类型
	Type string `json:"type"`
	// Data 消息段数据
	Data map[string]interface{} `json:"data"`
}

Segment 消息段

Reference: https://12.onebot.dev/glossary/#message-segment-segment

func GetSegment

func GetSegment(t string, data map[string]interface{}) Segment

GetSegment 返回消息段

Reference: https://12.onebot.dev/glossary/#message-segment-segment

func GetSegmentAudio

func GetSegmentAudio(fileId string) Segment

GetSegmentAudio 返回音频消息段

Reference: https://12.onebot.dev/interface/message/segments/#audio

func GetSegmentFile

func GetSegmentFile(fileId string) Segment

GetSegmentFile 返回文件消息段

Reference: https://12.onebot.dev/interface/message/segments/#file

func GetSegmentImage

func GetSegmentImage(fileId string) Segment

GetSegmentImage 返回图片消息段

Reference: https://12.onebot.dev/interface/message/segments/#image

func GetSegmentLocation

func GetSegmentLocation(latitude float64, longitude float64, title string, content string) Segment

GetSegmentLocation 返回位置消息段

Reference: https://12.onebot.dev/interface/message/segments/#location

func GetSegmentMention

func GetSegmentMention(userId string) Segment

GetSegmentMention 返回@消息段

Reference: https://12.onebot.dev/interface/message/segments/#mention

func GetSegmentMentionAll

func GetSegmentMentionAll() Segment

GetSegmentMentionAll 返回@全体成员消息段

Reference: https://12.onebot.dev/interface/message/segments/#mention_all

func GetSegmentReply

func GetSegmentReply(messageId string, UserId string) Segment

GetSegmentReply 返回回复消息段

Reference: https://12.onebot.dev/interface/message/segments/#reply

func GetSegmentText

func GetSegmentText(text string) Segment

GetSegmentText 返回文本消息段

Reference: https://12.onebot.dev/interface/message/segments/#text

func GetSegmentVideo

func GetSegmentVideo(fileId string) Segment

GetSegmentVideo 返回视频消息段

Reference: https://12.onebot.dev/interface/message/segments/#video

func GetSegmentVoice

func GetSegmentVoice(fileId string) Segment

GetSegmentVoice 返回语音消息段

Reference: https://12.onebot.dev/interface/message/segments/#voice

type Self

type Self struct {
	// PlatForm 平台
	PlatForm string `json:"platform"`
	// UserId 用户ID
	UserId string `json:"user_id"`
}

Self 字段 用于区分不同机器人

Jump to

Keyboard shortcuts

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