dto

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 6 Imported by: 25

README

dto

与 openapi/websocket 通信时所使用的对象。

Documentation

Overview

Package dto 维护了用于与机器人接口通信的数据结构对象。

Index

Constants

View Source
const (
	AudioStatusStart = iota
	AudioStatusPause
	AudioStatusResume
	AudioStatusStop
)

音频状态

View Source
const (
	ChannelTypeText ChannelType = iota

	ChannelTypeVoice

	ChannelTypeCategory
	ChannelTypeLive        = 10000 + iota // 直播子频道
	ChannelTypeApplication                // 应用子频道
	ChannelTypeForum                      // 论坛子频道
)

子频道类型定义

View Source
const (
	// ReactionTargetTypeMsg 消息
	ReactionTargetTypeMsg = iota
	// ReactionTargetTypeFeed 帖子
	ReactionTargetTypeFeed
	// ReactionTargetTypeComment 评论
	ReactionTargetTypeComment
	// ReactionTargetTypeReply 回复
	ReactionTargetTypeReply
)
View Source
const DefaultColor = 4278245297

DefaultColor 用户组默认颜色值

Variables

This section is empty.

Functions

func OPMeans

func OPMeans(op OPCode) string

OPMeans 返回 op 含义

Types

type APIPermission

type APIPermission struct {
	Path       string `json:"path,omitempty"`        // API 接口名,例如 /guilds/{guild_id}/members/{user_id}
	Method     string `json:"method,omitempty"`      // 请求方法,例如 GET
	Desc       string `json:"desc,omitempty"`        // API 接口名称,例如 获取频道信
	AuthStatus int    `json:"auth_status,omitempty"` // 授权状态,auth_stats 为 1 时已授权
}

APIPermission API 权限对象

type APIPermissionDemand

type APIPermissionDemand struct {
	GuildID     string                       `json:"guild_id,omitempty"`     // 频道 ID
	ChannelID   string                       `json:"channel_id,omitempty"`   // 子频道 ID
	APIIdentify *APIPermissionDemandIdentify `json:"api_identify,omitempty"` // 权限接口唯一标识
	Title       string                       `json:"title,omitempty"`        // 接口权限链接中的接口权限描述信息
	Desc        string                       `json:"desc,omitempty"`         // 接口权限链接中的机器人可使用功能的描述信息
}

APIPermissionDemand 接口权限需求对象

type APIPermissionDemandIdentify

type APIPermissionDemandIdentify struct {
	Path   string `json:"path,omitempty"`   // API 接口名,例如 /guilds/{guild_id}/members/{user_id}
	Method string `json:"method,omitempty"` // 请求方法,例如 GET
}

APIPermissionDemandIdentify API 权限需求标识对象

type APIPermissionDemandToCreate

type APIPermissionDemandToCreate struct {
	ChannelID   string                       `json:"channel_id"`             // 子频道 ID
	APIIdentify *APIPermissionDemandIdentify `json:"api_identify,omitempty"` // 接口权限链接中的接口权限描述信息
	Desc        string                       `json:"desc"`                   // 接口权限链接中的机器人可使用功能的描述信息
}

APIPermissionDemandToCreate 创建频道 API 接口权限授权链接结构体定义

type APIPermissions

type APIPermissions struct {
	APIList []*APIPermission `json:"apis,omitempty"` // API 权限列表
}

APIPermissions API 权限列表对象

type ActionType

type ActionType uint32

ActionType 每行数据的点击行为

const (
	// ActionTypeSendARK 发送 ark 消息
	ActionTypeSendARK ActionType = 0
)

type Announces

type Announces struct {
	// 频道 ID
	GuildID string `json:"guild_id"`
	// 子频道 ID
	ChannelID string `json:"channel_id"`
	// 用来创建公告的消息 ID
	MessageID string `json:"message_id"`
	// 公告类别 0:成员公告,1:欢迎公告,默认为成员公告
	AnnouncesType uint32 `json:"announces_type"`
	// 推荐子频道详情数组
	RecommendChannels []RecommendChannel `json:"recommend_channels,omitempty"`
}

Announces 公告对象

type Ark

type Ark struct {
	TemplateID int      `json:"template_id,omitempty"` // ark 模版 ID
	KV         []*ArkKV `json:"kv,omitempty"`          // ArkKV 数组
}

Ark 消息模版

type ArkKV

type ArkKV struct {
	Key   string    `json:"key,omitempty"`
	Value string    `json:"value,omitempty"`
	Obj   []*ArkObj `json:"obj,omitempty"`
}

ArkKV Ark 键值对

type ArkObj

type ArkObj struct {
	ObjKV []*ArkObjKV `json:"obj_kv,omitempty"`
}

ArkObj Ark 对象

type ArkObjKV

type ArkObjKV struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

ArkObjKV Ark 对象键值对

type AudioAction

type AudioAction struct {
	GuildID   string `json:"guild_id"`
	ChannelID string `json:"channel_id"`
	URL       string `json:"audio_url"`
	Text      string `json:"text"`
}

AudioAction 音频动作

type AudioControl

type AudioControl struct {
	URL    string      `json:"audio_url"`
	Text   string      `json:"text"`
	Status AudioStatus `json:"status"`
}

AudioControl 音频控制对象

type AudioStatus

type AudioStatus uint32

AudioStatus 音频状态

type Channel

type Channel struct {
	// 频道ID
	ID string `json:"id"`
	// 群ID
	GuildID string `json:"guild_id"`
	ChannelValueObject
}

Channel 频道结构定义

type ChannelAnnouncesToCreate

type ChannelAnnouncesToCreate struct {
	MessageID string `json:"message_id"` // 用来创建公告的消息ID
}

ChannelAnnouncesToCreate 创建子频道公告结构体定义

type ChannelPermissions

type ChannelPermissions struct {
	ChannelID   string `json:"channel_id,omitempty"`
	UserID      string `json:"user_id,omitempty"`
	Permissions string `json:"permissions,omitempty"`
}

ChannelPermissions 子频道权限

type ChannelPrivateType

type ChannelPrivateType int

ChannelPrivateType 频道可见性类型定义

const (
	ChannelPrivateTypePublic         ChannelPrivateType = iota // 公开频道
	ChannelPrivateTypeOnlyAdmin                                // 群主管理员可见
	ChannelPrivateTypeAdminAndMember                           // 群主管理员+指定成员
)

频道可见性类型定义

type ChannelRolesPermissions

type ChannelRolesPermissions struct {
	ChannelID   string `json:"channel_id,omitempty"`
	RoleID      string `json:"role_id,omitempty"`
	Permissions string `json:"permissions,omitempty"`
}

ChannelRolesPermissions 子频道身份组权限

type ChannelSubType

type ChannelSubType int

ChannelSubType 子频道子类型定义

const (
	ChannelSubTypeChat     ChannelSubType = iota // 闲聊,默认子类型
	ChannelSubTypeNotice                         // 公告
	ChannelSubTypeGuide                          // 攻略
	ChannelSubTypeTeamGame                       // 开黑
)

子频道子类型定义

type ChannelType

type ChannelType int

ChannelType 频道类型定义

type ChannelValueObject

type ChannelValueObject struct {
	// 频道名称
	Name string `json:"name,omitempty"`
	// 频道类型
	Type ChannelType `json:"type,omitempty"`
	// 排序位置
	Position int64 `json:"position,omitempty"`
	// 父频道的ID
	ParentID string `json:"parent_id,omitempty"`
	// 拥有者ID
	OwnerID string `json:"owner_id,omitempty"`
	// 子频道子类型
	SubType ChannelSubType `json:"sub_type,omitempty"`
	// 子频道可见性类型
	PrivateType ChannelPrivateType `json:"private_type,omitempty"`
	// 创建私密子频道的时候,同时带上 userID,能够将这些成员添加为私密子频道的成员
	// 注意:只有创建私密子频道的时候才支持这个参数
	PrivateUserIDs []string `json:"private_user_ids,omitempty"`
	// 发言权限
	SpeakPermission SpeakPermissionType `json:"speak_permission,omitempty"`
	// 应用子频道的应用ID,仅应用子频道有效,定义请参考
	// [文档](https://bot.q.qq.com/wiki/develop/api/openapi/channel/model.html)
	ApplicationID string `json:"application_id,omitempty"`
	// 机器人在此频道上拥有的权限, 定义请参考
	// [文档](https://bot.q.qq.com/wiki/develop/api/openapi/channel_permissions/model.html#permissions)
	Permissions string `json:"permissions,omitempty"`
	// 操作人
	OpUserID string `json:"op_user_id,omitempty"`
}

ChannelValueObject 频道的值对象部分

type DeleteHistoryMsgDay

type DeleteHistoryMsgDay = int

DeleteHistoryMsgDay 消息撤回天数

const (
	NoDelete                              = 0  // 不删除任何消息
	DeleteThreeDays   DeleteHistoryMsgDay = 3  // 3天
	DeleteSevenDays   DeleteHistoryMsgDay = 7  // 7天
	DeleteFifteenDays DeleteHistoryMsgDay = 15 // 15天
	DeleteThirtyDays  DeleteHistoryMsgDay = 30 // 30天
	DeleteAll         DeleteHistoryMsgDay = -1 // 删除所有消息
)

支持的消息撤回天数,除这些天数之外,传递其他值将不会撤回任何消息

type DirectMessage

type DirectMessage struct {
	// 频道ID
	GuildID string `json:"guild_id"`
	// 子频道id
	ChannelID string `json:"channel_id"`
	// 私信频道创建的时间戳
	CreateTime string `json:"create_time"`
}

DirectMessage 私信结构定义,一个 DirectMessage 为两个用户之间的一个私信频道,简写为 DM

type DirectMessageToCreate

type DirectMessageToCreate struct {
	// 频道ID
	SourceGuildID string `json:"source_guild_id"`
	// 用户ID
	RecipientID string `json:"recipient_id"`
}

DirectMessageToCreate 创建私信频道的结构体定义

type Duration

type Duration time.Duration

Duration 支持能够直接配置中解析出来 time.Duration 类型的数据 需要实现对应类型的 Unmarshaler 接口

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(bytes []byte) error

UnmarshalJSON 实现json的解析接口

type Embed

type Embed struct {
	Title       string                `json:"title,omitempty"`
	Description string                `json:"description,omitempty"`
	Prompt      string                `json:"prompt"` // 消息弹窗内容,消息列表摘要
	Thumbnail   MessageEmbedThumbnail `json:"thumbnail,omitempty"`
	Fields      []*EmbedField         `json:"fields,omitempty"`
}

Embed 结构

type EmbedField

type EmbedField struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

EmbedField Embed字段描述

type Emoji

type Emoji struct {
	ID   string `json:"id"`
	Type int    `json:"type"`
}

Emoji 表情

type EventType

type EventType string

EventType 事件类型

const (
	EventGuildCreate           EventType = "GUILD_CREATE"
	EventGuildUpdate           EventType = "GUILD_UPDATE"
	EventGuildDelete           EventType = "GUILD_DELETE"
	EventChannelCreate         EventType = "CHANNEL_CREATE"
	EventChannelUpdate         EventType = "CHANNEL_UPDATE"
	EventChannelDelete         EventType = "CHANNEL_DELETE"
	EventGuildMemberAdd        EventType = "GUILD_MEMBER_ADD"
	EventGuildMemberUpdate     EventType = "GUILD_MEMBER_UPDATE"
	EventGuildMemberRemove     EventType = "GUILD_MEMBER_REMOVE"
	EventMessageCreate         EventType = "MESSAGE_CREATE"
	EventMessageReactionAdd    EventType = "MESSAGE_REACTION_ADD"
	EventMessageReactionRemove EventType = "MESSAGE_REACTION_REMOVE"
	EventAtMessageCreate       EventType = "AT_MESSAGE_CREATE"
	EventPublicMessageDelete   EventType = "PUBLIC_MESSAGE_DELETE"
	EventDirectMessageCreate   EventType = "DIRECT_MESSAGE_CREATE"
	EventDirectMessageDelete   EventType = "DIRECT_MESSAGE_DELETE"
	EventAudioStart            EventType = "AUDIO_START"
	EventAudioFinish           EventType = "AUDIO_FINISH"
	EventAudioOnMic            EventType = "AUDIO_ON_MIC"
	EventAudioOffMic           EventType = "AUDIO_OFF_MIC"
	EventMessageAuditPass      EventType = "MESSAGE_AUDIT_PASS"
	EventMessageAuditReject    EventType = "MESSAGE_AUDIT_REJECT"
	EventMessageDelete         EventType = "MESSAGE_DELETE"
	EventForumThreadCreate     EventType = "FORUM_THREAD_CREATE"
	EventForumThreadUpdate     EventType = "FORUM_THREAD_UPDATE"
	EventForumThreadDelete     EventType = "FORUM_THREAD_DELETE"
	EventForumPostCreate       EventType = "FORUM_POST_CREATE"
	EventForumPostDelete       EventType = "FORUM_POST_DELETE"
	EventForumReplyCreate      EventType = "FORUM_REPLY_CREATE"
	EventForumReplyDelete      EventType = "FORUM_REPLY_DELETE"
	EventForumAuditResult      EventType = "FORUM_PUBLISH_AUDIT_RESULT"
	EventInteractionCreate     EventType = "INTERACTION_CREATE"
)

事件类型

type ForumAuditResult added in v0.1.0

type ForumAuditResult struct {
	TaskID      string `json:"task_id"`
	GuildID     string `json:"guild_id"`
	ChannelID   string `json:"channel_id"`
	AuthorID    string `json:"author_id"`
	ThreadID    string `json:"thread_id"`
	PostID      string `json:"post_id"`
	ReplyID     string `json:"reply_id"`
	PublishType uint32 `json:"type"`
	Result      uint32 `json:"result"`
	ErrMsg      string `json:"err_msg"`
	DateTime    string `json:"date_time"`
}

ForumAuditResult 帖子审核事件主体内容

type Guild

type Guild struct {
	// 频道ID(与客户端上看到的频道ID不同)
	ID string `json:"id"`
	// 频道名称
	Name string `json:"name"`
	// 频道头像
	Icon string `json:"icon"`
	// 拥有者ID
	OwnerID string `json:"owner_id"`
	// 是否为拥有者
	IsOwner bool `json:"owner"`
	// 成员数量
	MemberCount int `json:"member_count"`
	// 最大成员数目
	MaxMembers int64 `json:"max_members"`
	// 频道描述
	Desc string `json:"description"`
	// 当前用户加入群的时间
	// 此字段只在GUILD_CREATE事件中使用
	JoinedAt Timestamp `json:"joined_at"`
	// 频道列表
	Channels []*Channel `json:"channels"`
	// 游戏绑定公会区服ID
	UnionWorldID string `json:"union_world_id"`
	// 游戏绑定公会/战队ID
	UnionOrgID string `json:"union_org_id"`
	// 操作人
	OpUserID string `json:"op_user_id,omitempty"`
}

Guild 频道结构定义

type GuildAnnouncesToCreate

type GuildAnnouncesToCreate struct {
	ChannelID         string             `json:"channel_id"`         // 用来创建公告的子频道 ID
	MessageID         string             `json:"message_id"`         // 用来创建公告的消息 ID
	AnnouncesType     uint32             `json:"announces_type"`     // 公告类别 0:成员公告,1:欢迎公告,默认为成员公告
	RecommendChannels []RecommendChannel `json:"recommend_channels"` // 推荐子频道详情列表
}

GuildAnnouncesToCreate 创建频道全局公告结构体定义

type GuildMembersPager

type GuildMembersPager struct {
	After string `json:"after"` // 读此id之后的数据,如果是第一次请求填0,默认为0
	Limit string `json:"limit"` // 分页大小,1-1000,默认是1
}

GuildMembersPager 分页器

func (*GuildMembersPager) QueryParams

func (g *GuildMembersPager) QueryParams() map[string]string

QueryParams 转换为 query 参数

type GuildPager

type GuildPager struct {
	Before string `json:"before"` // 读此id之前的数据
	After  string `json:"after"`  // 读此id之后的数据
	Limit  string `json:"limit"`  // 分页大小,1-100,默认是 100
}

GuildPager 分页器

func (*GuildPager) QueryParams

func (g *GuildPager) QueryParams() map[string]string

QueryParams 转换为 query 参数

type GuildRoles

type GuildRoles struct {
	GuildID  string  `json:"guild_id"`
	Roles    []*Role `json:"roles"`
	NumLimit string  `json:"role_num_limit"`
}

GuildRoles 频道用户组列表返回

type HTTPIdentity added in v0.1.0

type HTTPIdentity struct {
	Intents  Intent    `json:"intents"`
	Shards   [2]uint32 `json:"shards"` // array of two integers (shard_id, num_shards)
	Callback string    `json:"callback_url"`
}

HTTPIdentity 鉴权数据

type HTTPReady added in v0.1.0

type HTTPReady struct {
	Version   int    `json:"version"`
	SessionID string `json:"session_id"`
	Bot       struct {
		ID       string `json:"id"`
		Username string `json:"username"`
	} `json:"bot"`
	Shard [2]uint32 `json:"shard"`
}

HTTPReady ready,鉴权后返回

type HTTPSession added in v0.1.0

type HTTPSession struct {
	AppID             int64    `json:"app_id"`
	SessionID         string   `json:"session_id"`
	CallbackURL       string   `json:"callback_url"`
	Env               string   `json:"env"`
	Intents           int64    `json:"intents"`
	LastHeartbeatTime string   `json:"last_heartbeat_time"`
	State             string   `json:"state"`
	Shards            [2]int64 `json:"shards"`
}

HTTPSession session 对象

type Intent

type Intent int

Intent 类型

const (
	// IntentGuilds 包含
	// - GUILD_CREATE
	// - GUILD_UPDATE
	// - GUILD_DELETE
	// - GUILD_ROLE_CREATE
	// - GUILD_ROLE_UPDATE
	// - GUILD_ROLE_DELETE
	// - CHANNEL_CREATE
	// - CHANNEL_UPDATE
	// - CHANNEL_DELETE
	// - CHANNEL_PINS_UPDATE
	IntentGuilds Intent = 1 << iota

	// IntentGuildMembers 包含
	// - GUILD_MEMBER_ADD
	// - GUILD_MEMBER_UPDATE
	// - GUILD_MEMBER_REMOVE
	IntentGuildMembers

	IntentGuildBans
	IntentGuildEmojis
	IntentGuildIntegrations
	IntentGuildWebhooks
	IntentGuildInvites
	IntentGuildVoiceStates
	IntentGuildPresences
	IntentGuildMessages

	// IntentGuildMessageReactions 包含
	// - MESSAGE_REACTION_ADD
	// - MESSAGE_REACTION_REMOVE
	IntentGuildMessageReactions

	IntentGuildMessageTyping
	IntentDirectMessages
	IntentDirectMessageReactions
	IntentDirectMessageTyping

	IntentInteraction Intent = 1 << 26 // 互动事件
	IntentAudit       Intent = 1 << 27 // 审核事件
	// IntentForum 论坛事件
	//  - THREAD_CREATE     // 当用户创建主题时
	//  - THREAD_UPDATE     // 当用户更新主题时
	//  - THREAD_DELETE     // 当用户删除主题时
	//  - POST_CREATE       // 当用户创建帖子时
	//  - POST_DELETE       // 当用户删除帖子时
	//  - REPLY_CREATE      // 当用户回复评论时
	//  - REPLY_DELETE      // 当用户回复评论时
	//  - FORUM_PUBLISH_AUDIT_RESULT      // 当用户发表审核通过时
	IntentForum Intent = 1 << 28 // 论坛事件

	// IntentAudio
	//  - AUDIO_START           // 音频开始播放时
	//  - AUDIO_FINISH          // 音频播放结束时
	IntentAudio          Intent = 1 << 29 // 音频机器人事件
	IntentGuildAtMessage Intent = 1 << 30 // 只接收@消息事件

	IntentNone Intent = 0
)

websocket intent 声明

func EventToIntent

func EventToIntent(events ...EventType) Intent

EventToIntent 事件转换对应的Intent

type Interaction

type Interaction struct {
	ID            string           `json:"id,omitempty"`             // 互动行为唯一标识
	ApplicationID string           `json:"application_id,omitempty"` // 应用ID
	Type          InteractionType  `json:"type,omitempty"`           // 互动类型
	Data          *InteractionData `json:"data,omitempty"`           // 互动数据
	GuildID       string           `json:"guild_id,omitempty"`       // 频道 ID
	ChannelID     string           `json:"channel_id,omitempty"`     // 子频道 ID
	Version       uint32           `json:"version,omitempty"`        //	版本,默认为 1
}

Interaction 互动行为对象

type InteractionData

type InteractionData struct {
	Name     string              `json:"name,omitempty"`     // 标题
	Type     InteractionDataType `json:"type,omitempty"`     //	数据类型,不同数据类型对应不同的 resolved 数据
	Resolved json.RawMessage     `json:"resolved,omitempty"` // 跟不同的互动类型和数据类型有关系的数据
}

InteractionData 互动数据

type InteractionDataType

type InteractionDataType uint32

InteractionDataType 互动数据类型

const (
	// InteractionDataTypeChatSearch 聊天框搜索
	InteractionDataTypeChatSearch InteractionDataType = 9
)

type InteractionType

type InteractionType uint32

InteractionType 互动类型

const (
	// InteractionTypePing ping
	InteractionTypePing InteractionType = 1
	// InteractionTypeCommand 命令
	InteractionTypeCommand InteractionType = 2
)

type LayoutType

type LayoutType uint32

LayoutType 布局类型

const (
	// LayoutTypeImageText 左图右文
	LayoutTypeImageText LayoutType = 0
)

type Markdown

type Markdown struct {
	TemplateID int               `json:"template_id"` // 模版 id
	Params     []*MarkdownParams `json:"params"`      // 模版参数
	Content    string            `json:"content"`     // 原生 markdown
}

Markdown markdown 消息

type MarkdownParams

type MarkdownParams struct {
	Key    string   `json:"key"`
	Values []string `json:"values"`
}

MarkdownParams markdown 模版参数 键值对

type Member

type Member struct {
	GuildID  string    `json:"guild_id"`
	JoinedAt Timestamp `json:"joined_at"`
	Nick     string    `json:"nick"`
	User     *User     `json:"user"`
	Roles    []string  `json:"roles"`
	OpUserID string    `json:"op_user_id,omitempty"`
}

Member 群成员

type MemberAddRoleBody

type MemberAddRoleBody struct {
	// 子频道对象
	Channel *Channel `json:"channel"`
}

MemberAddRoleBody 增加子频道管理员身份组时附加内容

type MemberDeleteOption

type MemberDeleteOption func(*MemberDeleteOpts)

MemberDeleteOption 删除成员选项

func WithAddBlackList

func WithAddBlackList(b bool) MemberDeleteOption

WithAddBlackList 将当前成员同时添加到频道黑名单中

func WithDeleteHistoryMsg

func WithDeleteHistoryMsg(days DeleteHistoryMsgDay) MemberDeleteOption

WithDeleteHistoryMsg 删除成员时同时撤回消息

type MemberDeleteOpts

type MemberDeleteOpts struct {
	AddBlackList         bool                `json:"add_blacklist"`
	DeleteHistoryMsgDays DeleteHistoryMsgDay `json:"delete_history_msg_days"`
}

MemberDeleteOpts 删除成员额外参数

type Message

type Message struct {
	// 消息ID
	ID string `json:"id"`
	// 子频道ID
	ChannelID string `json:"channel_id"`
	// 频道ID
	GuildID string `json:"guild_id"`
	// 内容
	Content string `json:"content"`
	// 发送时间
	Timestamp Timestamp `json:"timestamp"`
	// 消息编辑时间
	EditedTimestamp Timestamp `json:"edited_timestamp"`
	// 是否@all
	MentionEveryone bool `json:"mention_everyone"`
	// 消息发送方
	Author *User `json:"author"`
	// 消息发送方Author的member属性,只是部分属性
	Member *Member `json:"member"`
	// 附件
	Attachments []*MessageAttachment `json:"attachments"`
	// 结构化消息-embeds
	Embeds []*Embed `json:"embeds"`
	// 消息中的提醒信息(@)列表
	Mentions []*User `json:"mentions"`
	// ark 消息
	Ark *Ark `json:"ark"`
	// 私信消息
	DirectMessage bool `json:"direct_message"`
	// 子频道 seq,用于消息间的排序,seq 在同一子频道中按从先到后的顺序递增,不同的子频道之前消息无法排序
	SeqInChannel string `json:"seq_in_channel"`
	// 引用的消息
	MessageReference *MessageReference `json:"message_reference,omitempty"`
	// 私信场景下,该字段用来标识从哪个频道发起的私信
	SrcGuildID string `json:"src_guild_id"`
}

Message 消息结构体定义

type MessageArk

type MessageArk struct {
	Ark *Ark `json:"ark,omitempty"`
}

MessageArk ark模板消息

type MessageAttachment

type MessageAttachment struct {
	URL string `json:"url"`
}

MessageAttachment 附件定义

type MessageAudit

type MessageAudit struct {
	// 审核 ID
	AuditID string `json:"audit_id"`
	// 消息 ID
	MessageID string `json:"message_id"`
	// 频道 ID
	GuildID string `json:"guild_id"`
	// 子频道 ID
	ChannelID string `json:"channel_id"`
	// 审核时间
	AuditTime string `json:"audit_time"`
	// 创建时间
	CreateTime string `json:"create_time"`
	// 子频道 seq,用于消息间的排序,seq 在同一子频道中按从先到后的顺序递增,不同的子频道之前消息无法排序
	SeqInChannel string `json:"seq_in_channel"`
}

MessageAudit 消息审核结构体定义

type MessageDelete added in v0.1.1

type MessageDelete struct {
	// 消息
	Message Message `json:"message"`
	// 操作用户
	OpUser User `json:"op_user"`
}

MessageDelete 消息删除结构体定义

type MessageEmbedThumbnail

type MessageEmbedThumbnail struct {
	URL string `json:"url"`
}

MessageEmbedThumbnail embed 消息的缩略图对象

type MessagePagerType

type MessagePagerType string

MessagePagerType 消息翻页拉取方式

const (
	// MPTAround 拉取消息ID上下的消息
	MPTAround MessagePagerType = "around"
	// MPTBefore 拉取消息ID之前的消息
	MPTBefore MessagePagerType = "before"
	// MPTAfter 拉取消息ID之后的消息
	MPTAfter MessagePagerType = "after"
)

type MessageReaction

type MessageReaction struct {
	UserID    string         `json:"user_id"`
	ChannelID string         `json:"channel_id"`
	GuildID   string         `json:"guild_id"`
	Target    ReactionTarget `json:"target"`
	Emoji     Emoji          `json:"emoji"`
}

MessageReaction 表情表态动作

type MessageReactionPager added in v0.1.5

type MessageReactionPager struct {
	Cookie string `json:"cookie"` // 分页游标
	Limit  string `json:"limit"`  // 分页大小,1-1000,默认是20
}

MessageReactionPager 分页器

func (*MessageReactionPager) QueryParams added in v0.1.5

func (g *MessageReactionPager) QueryParams() map[string]string

QueryParams 转换为 query 参数

type MessageReactionUsers added in v0.1.5

type MessageReactionUsers struct {
	Users  []*User `json:"users,omitempty"`
	Cookie string  `json:"cookie,omitempty"`
	IsEnd  bool    `json:"is_end,omitempty"`
}

MessageReactionUsers 消息表情表态用户列表

type MessageReference

type MessageReference struct {
	MessageID             string `json:"message_id"`               // 消息 id
	IgnoreGetMessageError bool   `json:"ignore_get_message_error"` // 是否忽律获取消息失败错误
}

MessageReference 引用消息

type MessageSetting added in v0.1.5

type MessageSetting struct {
	DisableCreateDm   bool     `json:"disable_create_dm,omitempty"`
	DisablePushMsg    bool     `json:"disable_push_msg,omitempty"`
	ChannelIDs        []string `json:"channel_ids,omitempty"`
	ChannelPushMaxNum int      `json:"channel_push_max_num,omitempty"`
}

MessageSetting 消息频率设置信息

type MessageToCreate

type MessageToCreate struct {
	Content string `json:"content,omitempty"`
	Embed   *Embed `json:"embed,omitempty"`
	Ark     *Ark   `json:"ark,omitempty"`
	Image   string `json:"image,omitempty"`
	// 要回复的消息id,为空是主动消息,公域机器人会异步审核,不为空是被动消息,公域机器人会校验语料
	MsgID            string                    `json:"msg_id,omitempty"`
	MessageReference *MessageReference         `json:"message_reference,omitempty"`
	Markdown         *Markdown                 `json:"markdown,omitempty"`
	Keyboard         *keyboard.MessageKeyboard `json:"keyboard,omitempty"` // 消息按钮组件
	EventID          string                    `json:"event_id,omitempty"` // 要回复的事件id, 逻辑同MsgID
}

MessageToCreate 发送消息结构体定义

type MessagesPager

type MessagesPager struct {
	Type  MessagePagerType // 拉取类型
	ID    string           // 消息ID
	Limit string           `json:"limit"` // 最大 20
}

MessagesPager 消息分页

func (*MessagesPager) QueryParams

func (m *MessagesPager) QueryParams() map[string]string

QueryParams 转换为 query 参数

type OPCode

type OPCode int

OPCode websocket op 码

const (
	WSDispatchEvent OPCode = iota
	WSHeartbeat
	WSIdentity

	WSResume
	WSReconnect

	WSInvalidSession
	WSHello
	WSHeartbeatAck
	HTTPCallbackAck
)

WS OPCode

type Pager

type Pager interface {
	// QueryParams 转换为 query 参数
	QueryParams() map[string]string
}

Pager 分页器接口需要实现将对象转换为分页参数的方法

type PinsMessage

type PinsMessage struct {
	// 频道 ID
	GuildID string `json:"guild_id"`
	// 子频道 ID
	ChannelID string `json:"channel_id"`
	// 消息 ID 数组
	MessageIDs []string `json:"message_ids"`
}

PinsMessage 精华消息对象

type Post added in v0.1.0

type Post struct {
	GuildID   string   `json:"guild_id"`
	ChannelID string   `json:"channel_id"`
	AuthorID  string   `json:"author_id"`
	PostInfo  PostInfo `json:"post_info"`
}

Post 帖子事件主体内容

type PostInfo added in v0.1.0

type PostInfo struct {
	ThreadID string `json:"thread_id"`
	PostID   string `json:"post_id"`
	Content  string `json:"content"`
	DateTime string `json:"date_time"`
}

PostInfo 帖子内容

type ReactionTarget

type ReactionTarget struct {
	ID   string             `json:"id"`
	Type ReactionTargetType `json:"type"`
}

ReactionTarget 表态对象类型

type ReactionTargetType

type ReactionTargetType = int32

ReactionTargetType 表情表态对象类型

type RecommendChannel

type RecommendChannel struct {
	ChannelID string `json:"channel_id"` // 子频道 ID
	Introduce string `json:"introduce"`  // 推荐语
}

RecommendChannel 推荐子频道详情

type Reply added in v0.1.0

type Reply struct {
	GuildID   string    `json:"guild_id"`
	ChannelID string    `json:"channel_id"`
	AuthorID  string    `json:"author_id"`
	ReplyInfo ReplyInfo `json:"reply_info"`
}

Reply 回复事件主体内容

type ReplyInfo added in v0.1.0

type ReplyInfo struct {
	ThreadID string `json:"thread_id"`
	PostID   string `json:"post_id"`
	ReplyID  string `json:"reply_id"`
	Content  string `json:"content"`
	DateTime string `json:"date_time"`
}

ReplyInfo 回复内容

type Role

type Role struct {
	ID          RoleID `json:"id,omitempty"`
	Name        string `json:"name"`
	Color       uint32 `json:"color"`
	Hoist       uint32 `json:"hoist"`
	MemberCount uint32 `json:"number,omitempty"`       // 不会被修改,创建接口修改
	MemberLimit uint32 `json:"member_limit,omitempty"` // 不会被修改,创建接口修改
}

Role 频道身份组

type RoleID

type RoleID string

RoleID 用户组ID

type Schedule

type Schedule struct {
	ID             string  `json:"id,omitempty"`
	Name           string  `json:"name,omitempty"`
	Description    string  `json:"description,omitempty"`
	StartTimestamp string  `json:"start_timestamp,omitempty"`
	EndTimestamp   string  `json:"end_timestamp,omitempty"`
	JumpChannelID  string  `json:"jump_channel_id,omitempty"`
	RemindType     string  `json:"remind_type,omitempty"`
	Creator        *Member `json:"creator,omitempty"`
}

Schedule 日程对象

type ScheduleWrapper

type ScheduleWrapper struct {
	Schedule *Schedule `json:"schedule,omitempty"`
}

ScheduleWrapper 创建、修改日程的中间对象

type SearchInputResolved

type SearchInputResolved struct {
	Keyword string `json:"keyword,omitempty"`
}

SearchInputResolved 搜索类型的输入数据

type SearchLayout

type SearchLayout struct {
	LayoutType LayoutType
	ActionType ActionType
	Title      string
	Records    []SearchRecord
}

SearchLayout 搜索结果的布局

type SearchRecord

type SearchRecord struct {
	Cover string `json:"cover"`
	Title string `json:"title"`
	Tips  string `json:"tips"`
	URL   string `json:"url"`
}

SearchRecord 每一条搜索结果

type SearchRsp

type SearchRsp struct {
	Layouts []SearchLayout `json:"layouts"`
}

SearchRsp 搜索返回数据

type Session

type Session struct {
	ID      string
	URL     string
	Token   token.Token
	Intent  Intent
	LastSeq uint32
	Shards  ShardConfig
}

Session 连接的 session 结构,包括链接的所有必要字段

func (*Session) String

func (s *Session) String() string

String 输出session字符串

type SessionStartLimit

type SessionStartLimit struct {
	Total          uint32 `json:"total"`
	Remaining      uint32 `json:"remaining"`
	ResetAfter     uint32 `json:"reset_after"`
	MaxConcurrency uint32 `json:"max_concurrency"`
}

SessionStartLimit 链接频控信息

type SettingGuide added in v0.1.5

type SettingGuide struct {
	// 频道ID, 当通过私信发送设置引导消息时,需要指定guild_id
	GuildID string `json:"guild_id"`
}

SettingGuide 设置引导

type SettingGuideToCreate added in v0.1.5

type SettingGuideToCreate struct {
	Content      string        `json:"content,omitempty"`       // 频道内发引导消息可以带@
	SettingGuide *SettingGuide `json:"setting_guide,omitempty"` // 设置引导
}

SettingGuideToCreate 发送引导消息的结构体

type ShardConfig

type ShardConfig struct {
	ShardID    uint32
	ShardCount uint32
}

ShardConfig 连接的 shard 配置,ShardID 从 0 开始,ShardCount 最小为 1

type SpeakPermissionType

type SpeakPermissionType int

SpeakPermissionType 发言权限类型定义

const (
	SpeakPermissionTypePublic         SpeakPermissionType = iota + 1 // 公开发言权限
	SpeakPermissionTypeAdminAndMember                                // 指定成员可发言
)

发言权限类型定义

type Thread added in v0.1.0

type Thread struct {
	GuildID    string     `json:"guild_id"`
	ChannelID  string     `json:"channel_id"`
	AuthorID   string     `json:"author_id"`
	ThreadInfo ThreadInfo `json:"thread_info"`
}

Thread 主题事件主体内容

type ThreadInfo added in v0.1.0

type ThreadInfo struct {
	ThreadID string `json:"thread_id"`
	Title    string `json:"title"`
	Content  string `json:"content"`
	DateTime string `json:"date_time"`
}

ThreadInfo 主题信息

type Timestamp

type Timestamp string

Timestamp 时间戳

func (Timestamp) Time

func (t Timestamp) Time() (time.Time, error)

Time 时间字符串格式转换

type UpdateChannelPermissions

type UpdateChannelPermissions struct {
	Add    string `json:"add,omitempty"`
	Remove string `json:"remove,omitempty"`
}

UpdateChannelPermissions 修改子频道权限参数

type UpdateGuildMute

type UpdateGuildMute struct {
	// 禁言截止时间戳,单位秒
	MuteEndTimestamp string `json:"mute_end_timestamp,omitempty"`
	// 禁言多少秒(两个字段二选一,默认以mute_end_timstamp为准)
	MuteSeconds string `json:"mute_seconds,omitempty"`
	// 批量禁言的成员列表(全员禁言时不填写该字段)
	UserIDs []string `json:"user_ids,omitempty"`
}

UpdateGuildMute 更新频道相关禁言的Body参数

type UpdateGuildMuteResponse added in v0.1.3

type UpdateGuildMuteResponse struct {
	// 批量禁言成功的成员列表
	UserIDs []string `json:"user_ids,omitempty"`
}

UpdateGuildMuteResponse 批量禁言的回参

type UpdateResult

type UpdateResult struct {
	RoleID  `json:"role_id"`
	GuildID string `json:"guild_id"`
	Role    *Role  `json:"role"`
}

UpdateResult 创建,删除等行为的返回

type UpdateRole

type UpdateRole struct {
	GuildID string            `json:"guild_id"`
	Filter  *UpdateRoleFilter `json:"filter"`
	Update  *Role             `json:"info"`
}

UpdateRole role 更新请求承载

type UpdateRoleFilter

type UpdateRoleFilter struct {
	Name  uint32 `json:"name"`
	Color uint32 `json:"color"`
	Hoist uint32 `json:"hoist"`
}

UpdateRoleFilter 身份组可更改数据,修改的

type UpdateRoleInfo

type UpdateRoleInfo struct {
	Name  string `json:"name"`
	Color uint32 `json:"color"`
	Hoist uint32 `json:"hoist"`
}

UpdateRoleInfo 身份组可更改数据

type User

type User struct {
	ID               string `json:"id"`
	Username         string `json:"username"`
	Avatar           string `json:"avatar"`
	Bot              bool   `json:"bot"`
	UnionOpenID      string `json:"union_openid"`       // 特殊关联应用的 openid
	UnionUserAccount string `json:"union_user_account"` // 机器人关联的用户信息,与union_openid关联的应用是同一个
}

User 用户

type WSATMessageData

type WSATMessageData Message

WSATMessageData only at 机器人的消息 payload

type WSAudioData

type WSAudioData AudioAction

WSAudioData 音频机器人的音频流事件

type WSChannelData

type WSChannelData Channel

WSChannelData 子频道 payload

type WSDirectMessageData

type WSDirectMessageData Message

WSDirectMessageData 私信消息 payload

type WSDirectMessageDeleteData added in v0.1.1

type WSDirectMessageDeleteData MessageDelete

WSDirectMessageDeleteData 私信消息 payload

type WSForumAuditData added in v0.1.0

type WSForumAuditData ForumAuditResult

WSForumAuditData 帖子审核事件

type WSGuildData

type WSGuildData Guild

WSGuildData 频道 payload

type WSGuildMemberData

type WSGuildMemberData Member

WSGuildMemberData 频道成员 payload

type WSHelloData

type WSHelloData struct {
	HeartbeatInterval int `json:"heartbeat_interval"`
}

WSHelloData hello 返回

type WSIdentityData

type WSIdentityData struct {
	Token      string   `json:"token"`
	Intents    Intent   `json:"intents"`
	Shard      []uint32 `json:"shard"` // array of two integers (shard_id, num_shards)
	Properties struct {
		Os      string `json:"$os,omitempty"`
		Browser string `json:"$browser,omitempty"`
		Device  string `json:"$device,omitempty"`
	} `json:"properties,omitempty"`
}

WSIdentityData 鉴权数据

type WSInteractionData added in v0.1.0

type WSInteractionData Interaction

WSInteractionData 互动事件

type WSMessageAuditData

type WSMessageAuditData MessageAudit

WSMessageAuditData 消息审核事件

type WSMessageData

type WSMessageData Message

WSMessageData 消息 payload

type WSMessageDeleteData added in v0.1.1

type WSMessageDeleteData MessageDelete

WSMessageDeleteData 消息 payload

type WSMessageReactionData

type WSMessageReactionData MessageReaction

WSMessageReactionData 表情表态事件

type WSPayload

type WSPayload struct {
	WSPayloadBase
	Data       interface{} `json:"d,omitempty"`
	RawMessage []byte      `json:"-"` // 原始的 message 数据
}

WSPayload websocket 消息结构

type WSPayloadBase

type WSPayloadBase struct {
	OPCode OPCode    `json:"op"`
	Seq    uint32    `json:"s,omitempty"`
	Type   EventType `json:"t,omitempty"`
}

WSPayloadBase 基础消息结构,排除了 data

type WSPostData added in v0.1.0

type WSPostData Post

WSPostData 帖子事件

type WSPublicMessageDeleteData added in v0.1.1

type WSPublicMessageDeleteData MessageDelete

WSPublicMessageDeleteData 公域机器人的消息删除 payload

type WSReadyData

type WSReadyData struct {
	Version   int    `json:"version"`
	SessionID string `json:"session_id"`
	User      struct {
		ID       string `json:"id"`
		Username string `json:"username"`
		Bot      bool   `json:"bot"`
	} `json:"user"`
	Shard []uint32 `json:"shard"`
}

WSReadyData ready,鉴权后返回

type WSReplyData added in v0.1.0

type WSReplyData Reply

WSReplyData 帖子回复事件

type WSResumeData

type WSResumeData struct {
	Token     string `json:"token"`
	SessionID string `json:"session_id"`
	Seq       uint32 `json:"seq"`
}

WSResumeData 重连数据

type WSThreadData added in v0.1.0

type WSThreadData Thread

WSThreadData 主题事件

type WSUser

type WSUser struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Bot      bool   `json:"bot"`
}

WSUser 当前连接的用户信息

type WebsocketAP

type WebsocketAP struct {
	URL               string            `json:"url"`
	Shards            uint32            `json:"shards"`
	SessionStartLimit SessionStartLimit `json:"session_start_limit"`
}

WebsocketAP wss 接入点信息

Directories

Path Synopsis
Package message 内提供了用于支撑处理消息对象的工具和方法。
Package message 内提供了用于支撑处理消息对象的工具和方法。

Jump to

Keyboard shortcuts

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