kook

package module
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: ISC Imports: 23 Imported by: 4

README

Kook

A low level library for interacting with Kook bot API. Currently, it is WIP.

Go Reference Go Report Card Server Badger FOSSA Status

Get Started

It is not recommended to use it in production until it releases v1.0.0.

Installing

This assumes that you already have a working Go environment.

go get github.com/lonelyevil/kook

Other than the library itself, you need to install a logger and an adapter for logger. Personally, I only implement the adapter for phuslu/log. So, in order to use the library, the following installation is necessary.

go get github.com/lonelyevil/kook/log_adapter/plog

Usage

See the examples in examples folder.

Features and Roadmap

See features.md.

Documentation

WIP.

For code that are not well commented, users could refer to bwmarrin/discordgo as this library is heavily influenced by it.

Versioning

I could not guarantee a stable API until the release of 1.0.0. Before that, any break change would happen. After that, It would follow semantic versioning.

Contributing

Currently, this repo does not accept any large PRs, as the API may be broken at any time when I want. Bug reports and code suggestions are greatly welcomed.

LICENSE

kook is a free and open source software library distributed under the terms of ISC License.

FOSSA Status

Special Thanks To:

GoLand logo

Built using IntelliJ IDEA

Documentation

Index

Constants

View Source
const (
	GameTypeGame = iota
	GameTypeVup
	GameTypeProcess
)

These are all GameType values.

Variables

View Source
var (
	APIVersion = "v3"

	EndpointBase          = "https://www.kookapp.cn/api"
	EndpointAPI           = urlJoin(EndpointBase, APIVersion)
	EndpointGuild         = urlJoin(EndpointAPI, "guild")
	EndpointGuildMute     = urlJoin(EndpointAPI, "guild-mute")
	EndpointGuildBoost    = urlJoin(EndpointAPI, "guild-boost")
	EndpointChannel       = urlJoin(EndpointAPI, "channel")
	EndpointChannelRole   = urlJoin(EndpointAPI, "channel-role")
	EndpointChannelUser   = urlJoin(EndpointAPI, "channel-user")
	EndpointMessage       = urlJoin(EndpointAPI, "message")
	EndpointUserChat      = urlJoin(EndpointAPI, "user-chat")
	EndpointDirectMessage = urlJoin(EndpointAPI, "direct-message")
	EndpointGateway       = urlJoin(EndpointAPI, "gateway")
	EndpointUser          = urlJoin(EndpointAPI, "user")
	EndpointAsset         = urlJoin(EndpointAPI, "asset")
	EndpointGuildRole     = urlJoin(EndpointAPI, "guild-role")
	EndpointIntimacy      = urlJoin(EndpointAPI, "intimacy")
	EndpointGuildEmoji    = urlJoin(EndpointAPI, "guild-emoji")
	EndpointInvite        = urlJoin(EndpointAPI, "invite")
	EndpointBlacklist     = urlJoin(EndpointAPI, "blacklist")
	EndpointBadge         = urlJoin(EndpointAPI, "badge")
	EndpointGame          = urlJoin(EndpointAPI, "game")

	EndpointGuildList         = urlJoin(EndpointGuild, "list")
	EndpointGuildView         = urlJoin(EndpointGuild, "view")
	EndpointGuildUserList     = urlJoin(EndpointGuild, "user-list")
	EndpointGuildNickName     = urlJoin(EndpointGuild, "nickname")
	EndpointGuildLeave        = urlJoin(EndpointGuild, "leave")
	EndpointGuildKickout      = urlJoin(EndpointGuild, "kickout")
	EndpointGuildMuteList     = urlJoin(EndpointGuildMute, "list")
	EndpointGuildMuteCreate   = urlJoin(EndpointGuildMute, "create")
	EndpointGuildMuteDelete   = urlJoin(EndpointGuildMute, "delete")
	EndpointGuildBoostHistory = urlJoin(EndpointGuildBoost, "history")

	// EndpointChannelMessage is Deprecated.
	EndpointChannelMessage              = urlJoin(EndpointChannel, "message")
	EndpointChannelList                 = urlJoin(EndpointChannel, "list")
	EndpointChannelView                 = urlJoin(EndpointChannel, "view")
	EndpointChannelCreate               = urlJoin(EndpointChannel, "create")
	EndpointChannelMoveUser             = urlJoin(EndpointChannel, "move-user")
	EndpointChannelUpdate               = urlJoin(EndpointChannel, "update")
	EndpointChannelDelete               = urlJoin(EndpointChannel, "delete")
	EndpointChannelRoleIndex            = urlJoin(EndpointChannelRole, "index")
	EndpointChannelRoleCreate           = urlJoin(EndpointChannelRole, "create")
	EndpointChannelRoleUpdate           = urlJoin(EndpointChannelRole, "update")
	EndpointChannelRoleDelete           = urlJoin(EndpointChannelRole, "delete")
	EndpointChannelRoleSync             = urlJoin(EndpointChannelRole, "sync")
	EndpointChannelUserGetJoinedChannel = urlJoin(EndpointChannelUser, "get-joined-channel")
	EndpointChannelUserList             = urlJoin(EndpointChannel, "user-list")

	EndpointMessageList           = urlJoin(EndpointMessage, "list")
	EndpointMessageView           = urlJoin(EndpointMessage, "view")
	EndpointMessageCreate         = urlJoin(EndpointMessage, "create")
	EndpointMessageUpdate         = urlJoin(EndpointMessage, "update")
	EndpointMessageDelete         = urlJoin(EndpointMessage, "delete")
	EndpointMessageReactionList   = urlJoin(EndpointMessage, "reaction-list")
	EndpointMessageAddReaction    = urlJoin(EndpointMessage, "add-reaction")
	EndpointMessageDeleteReaction = urlJoin(EndpointMessage, "delete-reaction")

	EndpointUserChatList   = urlJoin(EndpointUserChat, "list")
	EndpointUserChatView   = urlJoin(EndpointUserChat, "view")
	EndpointUserChatCreate = urlJoin(EndpointUserChat, "create")
	EndpointUserChatDelete = urlJoin(EndpointUserChat, "delete")

	EndpointDirectMessageList           = urlJoin(EndpointDirectMessage, "list")
	EndpointDirectMessageView           = urlJoin(EndpointDirectMessage, "view")
	EndpointDirectMessageCreate         = urlJoin(EndpointDirectMessage, "create")
	EndpointDirectMessageUpdate         = urlJoin(EndpointDirectMessage, "update")
	EndpointDirectMessageDelete         = urlJoin(EndpointDirectMessage, "delete")
	EndpointDirectMessageReactionList   = urlJoin(EndpointDirectMessage, "reaction-list")
	EndpointDirectMessageAddReaction    = urlJoin(EndpointDirectMessage, "add-reaction")
	EndpointDirectMessageDeleteReaction = urlJoin(EndpointDirectMessage, "delete-reaction")

	EndpointGatewayIndex = urlJoin(EndpointGateway, "index")

	EndpointUserMe      = urlJoin(EndpointUser, "me")
	EndpointUserView    = urlJoin(EndpointUser, "view")
	EndpointUserOffline = urlJoin(EndpointUser, "offline")

	EndpointAssetCreate = urlJoin(EndpointAsset, "create")

	EndpointGuildRoleList   = urlJoin(EndpointGuildRole, "list")
	EndpointGuildRoleCreate = urlJoin(EndpointGuildRole, "create")
	EndpointGuildRoleUpdate = urlJoin(EndpointGuildRole, "update")
	EndpointGuildRoleDelete = urlJoin(EndpointGuildRole, "delete")
	EndpointGuildRoleGrant  = urlJoin(EndpointGuildRole, "grant")
	EndpointGuildRoleRevoke = urlJoin(EndpointGuildRole, "revoke")

	EndpointIntimacyIndex  = urlJoin(EndpointIntimacy, "index")
	EndpointIntimacyUpdate = urlJoin(EndpointIntimacy, "update")

	EndpointGuildEmojiList   = urlJoin(EndpointGuildEmoji, "list")
	EndpointGuildEmojiCreate = urlJoin(EndpointGuildEmoji, "create")
	EndpointGuildEmojiUpdate = urlJoin(EndpointGuildEmoji, "update")
	EndpointGuildEmojiDelete = urlJoin(EndpointGuildEmoji, "delete")

	EndpointInviteList   = urlJoin(EndpointInvite, "list")
	EndpointInviteCreate = urlJoin(EndpointInvite, "create")
	EndpointInviteDelete = urlJoin(EndpointInvite, "delete")

	EndpointBlacklistList   = urlJoin(EndpointBlacklist, "list")
	EndpointBlacklistCreate = urlJoin(EndpointBlacklist, "create")
	EndpointBlacklistDelete = urlJoin(EndpointBlacklist, "delete")

	EndpointBadgeGuild = urlJoin(EndpointBadge, "guild")

	EndpointGameCreate         = urlJoin(EndpointGame, "create")
	EndpointGameUpdate         = urlJoin(EndpointGame, "update")
	EndpointGameDelete         = urlJoin(EndpointGame, "delete")
	EndpointGameActivity       = urlJoin(EndpointGame, "activity")
	EndpointGameDeleteActivity = urlJoin(EndpointGame, "delete-activity")
)

All endpoints for http request

View Source
var ErrWSAlreadyOpen = errors.New("websocket is already opened")

ErrWSAlreadyOpen is the error when connecting with connected websocket.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Type     string  `json:"type"`
	URL      string  `json:"url"`
	Name     string  `json:"name"`
	FileType string  `json:"file_type"`
	Size     int64   `json:"size"`
	Duration float64 `json:"duration"`
	Width    int     `json:"width"`
	Height   int     `json:"height"`
}

Attachment is the struct for various attachments, so that according to type, some fields may be empty.

type AudioMessageContext

type AudioMessageContext struct {
	*EventHandlerCommonContext
	Extra EventRichMessage
}

func (*AudioMessageContext) GetCommon

func (*AudioMessageContext) GetExtra

func (ctx *AudioMessageContext) GetExtra() interface{}

type AudioMessageEventHandler

type AudioMessageEventHandler func(*AudioMessageContext)

func (AudioMessageEventHandler) Handle

func (AudioMessageEventHandler) New

func (AudioMessageEventHandler) Type

func (eh AudioMessageEventHandler) Type() string

type BlacklistCreate

type BlacklistCreate struct {
	GuildID    string `json:"guild_id"`
	TargetID   string `json:"target_id"`
	Remark     string `json:"remark,omitempty"`
	DelMsgDays int    `json:"del_msg_days,omitempty"`
}

BlacklistCreate is the type for arguments of BlacklistCreate request.

type BlacklistItem

type BlacklistItem struct {
	UserID      string         `json:"user_id"`
	CreatedTime MilliTimeStamp `json:"created_time"`
	Remark      string         `json:"remark"`
	User        *User          `json:"user"`
}

BlacklistItem is one user in blacklist.

type BlockListAddContext

type BlockListAddContext struct {
	*EventHandlerCommonContext
	Extra struct {
		Remark     string   `json:"remark"`
		UserID     []string `json:"user_id"`
		OperatorID string   `json:"operator_id"`
	}
}

func (*BlockListAddContext) GetCommon

func (*BlockListAddContext) GetExtra

func (ctx *BlockListAddContext) GetExtra() interface{}

type BlockListAddEventHandler

type BlockListAddEventHandler func(*BlockListAddContext)

func (BlockListAddEventHandler) Handle

func (BlockListAddEventHandler) New

func (BlockListAddEventHandler) Type

func (eh BlockListAddEventHandler) Type() string

type BlockListDeleteContext

type BlockListDeleteContext struct {
	*EventHandlerCommonContext
	Extra struct {
		UserID     []string `json:"user_id"`
		OperatorID string   `json:"operator_id"`
	}
}

func (*BlockListDeleteContext) GetCommon

func (*BlockListDeleteContext) GetExtra

func (ctx *BlockListDeleteContext) GetExtra() interface{}

type BlockListDeleteEventHandler

type BlockListDeleteEventHandler func(*BlockListDeleteContext)

func (BlockListDeleteEventHandler) Handle

func (BlockListDeleteEventHandler) New

func (BlockListDeleteEventHandler) Type

type BotExitContext

type BotExitContext struct {
	*EventHandlerCommonContext
	Extra struct {
		GuildID string `json:"guild_id"`
	}
}

func (*BotExitContext) GetCommon

func (ctx *BotExitContext) GetCommon() *EventHandlerCommonContext

func (*BotExitContext) GetExtra

func (ctx *BotExitContext) GetExtra() interface{}

type BotExitEventHandler

type BotExitEventHandler func(*BotExitContext)

func (BotExitEventHandler) Handle

func (eh BotExitEventHandler) Handle(i EventContext)

func (BotExitEventHandler) New

func (BotExitEventHandler) Type

func (eh BotExitEventHandler) Type() string

type BotJoinContext

type BotJoinContext struct {
	*EventHandlerCommonContext
	Extra struct {
		GuildID string `json:"guild_id"`
	}
}

func (*BotJoinContext) GetCommon

func (ctx *BotJoinContext) GetCommon() *EventHandlerCommonContext

func (*BotJoinContext) GetExtra

func (ctx *BotJoinContext) GetExtra() interface{}

type BotJoinEventHandler

type BotJoinEventHandler func(*BotJoinContext)

func (BotJoinEventHandler) Handle

func (eh BotJoinEventHandler) Handle(i EventContext)

func (BotJoinEventHandler) New

func (BotJoinEventHandler) Type

func (eh BotJoinEventHandler) Type() string

type CardMessage

type CardMessage []*CardMessageCard

CardMessage is the type for a message of cards called 卡片消息.

func (CardMessage) BuildMessage

func (c CardMessage) BuildMessage() (s string, err error)

BuildMessage is a helper function to marshal card message for sending.

func (CardMessage) MustBuildMessage

func (c CardMessage) MustBuildMessage() string

MustBuildMessage is a helper function to marshal card message for sending.

type CardMessageActionGroup

type CardMessageActionGroup []CardMessageElementButton

CardMessageActionGroup is the type for 模块-交互模块.

func (CardMessageActionGroup) MarshalJSON

func (c CardMessageActionGroup) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageCard

type CardMessageCard struct {
	Theme   CardTheme     `json:"theme,omitempty"`
	Color   string        `json:"color,omitempty"`
	Size    CardSize      `json:"size,omitempty"`
	Modules []interface{} `json:"modules"`
}

CardMessageCard is the type for 卡片.

func (*CardMessageCard) AddModule

func (c *CardMessageCard) AddModule(i ...interface{}) *CardMessageCard

AddModule adds Modules to a card and provides a runtime type check for CardMessageCard Modules.

Allowed Modules: *CardMessageHeader, *CardMessageSection, *CardMessageImageGroup, *CardMessageContainer, *CardMessageActionGroup, *CardMessageContext, *CardMessageDivider, *CardMessageFile, *CardMessageCountdown.

func (CardMessageCard) MarshalJSON

func (c CardMessageCard) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageContainer

type CardMessageContainer []CardMessageElementImage

CardMessageContainer is the type for 可拓展图片模块.

func (*CardMessageContainer) AddElements

AddElements adds elements to container.

func (CardMessageContainer) MarshalJSON

func (c CardMessageContainer) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling.

type CardMessageContext

type CardMessageContext []interface{}

CardMessageContext is the type for 模块-备注模块.

func (*CardMessageContext) AddItem

func (c *CardMessageContext) AddItem(i ...interface{}) *CardMessageContext

AddItem provides additional type-checking when adding elements to context.

Allowed elements: *CardMessageElementText, *CardMessageElementKMarkdown, *CardMessageElementImage

func (CardMessageContext) MarshalJSON

func (c CardMessageContext) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageCountdown

type CardMessageCountdown struct {
	EndTime   MilliTimeStamp           `json:"endTime"`
	StartTime MilliTimeStamp           `json:"startTime"`
	Mode      CardMessageCountdownMode `json:"mode"`
}

CardMessageCountdown is the type for 模块-倒计时模块.

func (CardMessageCountdown) MarshalJSON

func (c CardMessageCountdown) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageCountdownMode

type CardMessageCountdownMode string

CardMessageCountdownMode is the type for modes of CardMessageCountdown

const (
	CardMessageCountdownModeDay    CardMessageCountdownMode = "day"
	CardMessageCountdownModeHour   CardMessageCountdownMode = "hour"
	CardMessageCountdownModeSecond CardMessageCountdownMode = "second"
)

These are predefined usable CardMessageCountdownModes

type CardMessageDivider

type CardMessageDivider struct {
}

CardMessageDivider is the type for 模块-分割线模块.

func (CardMessageDivider) MarshalJSON

func (c CardMessageDivider) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageElementButton

type CardMessageElementButton struct {
	Theme CardTheme `json:"theme"`
	Value string    `json:"value"`
	Click string    `json:"click,omitempty"`
	Text  string    `json:"text"`
}

CardMessageElementButton is the type for 元素-按钮.

func (CardMessageElementButton) MarshalJSON

func (c CardMessageElementButton) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageElementButtonClick

type CardMessageElementButtonClick string

CardMessageElementButtonClick is the type for click modes of CardMessageElementButton

const (
	CardMessageElementButtonClickLink      CardMessageElementButtonClick = "link"
	CardMessageElementButtonClickReturnVal CardMessageElementButtonClick = "return-val"
)

These are predefined usable CardMessageElementButtonClicks

type CardMessageElementImage

type CardMessageElementImage struct {
	Src    string `json:"src"`
	Alt    string `json:"alt,omitempty"`
	Size   string `json:"size,omitempty"`
	Circle bool   `json:"circle"`
}

CardMessageElementImage is the type for 元素-图片.

func (CardMessageElementImage) MarshalJSON

func (c CardMessageElementImage) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageElementKMarkdown

type CardMessageElementKMarkdown struct {
	Content string `json:"content"`
}

CardMessageElementKMarkdown is the type for 元素-kmarkdown.

func (CardMessageElementKMarkdown) MarshalJSON

func (c CardMessageElementKMarkdown) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageElementText

type CardMessageElementText struct {
	Content string `json:"content"`
	Emoji   bool   `json:"emoji"`
}

CardMessageElementText is the type for 元素-普通文本.

func (CardMessageElementText) MarshalJSON

func (c CardMessageElementText) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageFile

type CardMessageFile struct {
	Type  CardMessageFileType `json:"type"`
	Src   string              `json:"src"`
	Title string              `json:"title,omitempty"`
	Cover string              `json:"cover,omitempty"`
}

CardMessageFile is the type for 模块-文件模块.

type CardMessageFileType

type CardMessageFileType string

CardMessageFileType is the type for types of CardMessageFile

const (
	CardMessageFileTypeFile  CardMessageFileType = "file"
	CardMessageFileTypeAudio CardMessageFileType = "audio"
	CardMessageFileTypeVideo CardMessageFileType = "video"
)

These are predefined usable CardMessageFileTypes

type CardMessageHeader

type CardMessageHeader struct {
	Text CardMessageElementText `json:"text"`
}

CardMessageHeader is the type for 模块-标题模块.

func (CardMessageHeader) MarshalJSON

func (c CardMessageHeader) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageImageGroup

type CardMessageImageGroup []CardMessageElementImage

CardMessageImageGroup is the type for 图片模块.

func (CardMessageImageGroup) MarshalJSON

func (c CardMessageImageGroup) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageInvite

type CardMessageInvite struct {
	Code string `json:"code"`
}

CardMessageInvite is the type for 邀请模块.

func (CardMessageInvite) MarshalJSON

func (c CardMessageInvite) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling.

type CardMessageParagraph

type CardMessageParagraph struct {
	Cols   int           `json:"cols"`
	Fields []interface{} `json:"fields"`
}

CardMessageParagraph is the type for 结构体-区域文本.

func (*CardMessageParagraph) AddField

func (c *CardMessageParagraph) AddField(i ...interface{}) *CardMessageParagraph

AddField provides additional type-checking when adding elements to paragraph.

Allowed elements: *CardMessageElementText, *CardMessageElementKMarkdown

func (CardMessageParagraph) MarshalJSON

func (c CardMessageParagraph) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling

type CardMessageSection

type CardMessageSection struct {
	Mode      CardMessageSectionMode `json:"mode,omitempty"`
	Text      interface{}            `json:"text"`
	Accessory interface{}            `json:"accessory,omitempty"`
}

CardMessageSection is the type for 模块-内容模块.

func (CardMessageSection) MarshalJSON

func (c CardMessageSection) MarshalJSON() ([]byte, error)

MarshalJSON adds additional type field when marshaling.

func (*CardMessageSection) SetAccessory

func (c *CardMessageSection) SetAccessory(i interface{}) *CardMessageSection

SetAccessory provides additional type-checking when setting elements to section accessory.

Allowed elements: *CardMessageElementImage, *CardMessageElementButton.

func (*CardMessageSection) SetText

func (c *CardMessageSection) SetText(i interface{}) *CardMessageSection

SetText provides additional type-checking when setting elements to section text.

Allowed elements: *CardMessageElementText, *CardMessageElementKMarkdown, *CardMessageParagraph.

type CardMessageSectionMode

type CardMessageSectionMode string

CardMessageSectionMode is the type of mode for CardMessageSection

const (
	CardMessageSectionModeLeft  CardMessageSectionMode = "left"
	CardMessageSectionModeRight CardMessageSectionMode = "right"
)

These are predefined usable CardMessageSectionModes

type CardSize

type CardSize string

CardSize is the type for card size.

const (
	CardSizeSm CardSize = "sm"
	CardSizeLg CardSize = "lg"
)

These are predefined usable card sizes.

type CardTheme

type CardTheme string

CardTheme is the type for card theme.

const (
	CardThemePrimary   CardTheme = "primary"
	CardThemeSuccess   CardTheme = "success"
	CardThemeDanger    CardTheme = "danger"
	CardThemeWarning   CardTheme = "warning"
	CardThemeInfo      CardTheme = "info"
	CardThemeSecondary CardTheme = "secondary"
)

These are predefined usable card themes.

type Channel

type Channel struct {
	ID                   string                    `json:"id"`
	Name                 string                    `json:"name"`
	UserID               string                    `json:"user_id"`
	MasterID             string                    `json:"master_id"`
	GuildID              string                    `json:"guild_id"`
	Topic                string                    `json:"topic"`
	IsCategory           IntBool                   `json:"is_category"`
	ParentID             string                    `json:"parent_id"`
	Level                int                       `json:"level"`
	SlowMode             int                       `json:"slow_mode"`
	Type                 ChannelType               `json:"type"`
	LimitAmount          int                       `json:"limit_amount"`
	PermissionOverwrites []PermissionOverwrite     `json:"permission_overwrites"`
	PermissionUsers      []UserPermissionOverwrite `json:"permission_users"`
	PermissionSync       IntBool                   `json:"permission_sync"`
	ServerURL            string                    `json:"server_url"`
	HasPassword          bool                      `json:"has_password"`
	VoiceQuality         string                    `json:"voice_quality"`
	Children             []string                  `json:"children"`
}

Channel is the struct for a channel in guild. For different channels, some fields may be empty.

type ChannelAddContext

type ChannelAddContext struct {
	*EventHandlerCommonContext
	Extra Channel
}

func (*ChannelAddContext) GetCommon

func (ctx *ChannelAddContext) GetCommon() *EventHandlerCommonContext

func (*ChannelAddContext) GetExtra

func (ctx *ChannelAddContext) GetExtra() interface{}

type ChannelAddEventHandler

type ChannelAddEventHandler func(*ChannelAddContext)

func (ChannelAddEventHandler) Handle

func (eh ChannelAddEventHandler) Handle(i EventContext)

func (ChannelAddEventHandler) New

func (ChannelAddEventHandler) Type

func (eh ChannelAddEventHandler) Type() string

type ChannelCreate

type ChannelCreate struct {
	GuildID      string      `json:"guild_id"`
	ParentID     string      `json:"parent_id,omitempty"`
	Name         string      `json:"name"`
	Type         ChannelType `json:"type,omitempty"`
	LimitAmount  int         `json:"limit_amount,omitempty"`
	VoiceQuality string      `json:"voice_quality,omitempty"`
	IsCategory   int         `json:"is_category"`
}

ChannelCreate is the arguments for creating a channel.

type ChannelDeleteContext

type ChannelDeleteContext struct {
	*EventHandlerCommonContext
	Extra struct {
		ID        string         `json:"id"`
		DeletedAt MilliTimeStamp `json:"deleted_at"`
	}
}

func (*ChannelDeleteContext) GetCommon

func (*ChannelDeleteContext) GetExtra

func (ctx *ChannelDeleteContext) GetExtra() interface{}

type ChannelDeleteEventHandler

type ChannelDeleteEventHandler func(*ChannelDeleteContext)

func (ChannelDeleteEventHandler) Handle

func (ChannelDeleteEventHandler) New

func (ChannelDeleteEventHandler) Type

type ChannelMessage

type ChannelMessage struct {
	MsgID       string   `json:"msg_id"`
	Content     string   `json:"content"`
	ContentID   string   `json:"content_id"`
	Mention     []string `json:"mention"`
	MentionAll  bool     `json:"mention_all"`
	MentionHere bool     `json:"mention_here"`
	MentionRole []string `json:"mention_role"`
	UpdatedAt   int64    `json:"updated_at"`
}

ChannelMessage is the struct for a message in a channel.

type ChannelRoleBase

type ChannelRoleBase struct {
	ChannelID string `json:"channel_id"`
	Type      string `json:"type,omitempty"`
	Value     string `json:"value,omitempty"`
}

ChannelRoleBase is the common arguments for channel role requests.

type ChannelRoleCreate

type ChannelRoleCreate ChannelRoleBase

ChannelRoleCreate is the request query data for ChannelRoleCreate.

type ChannelRoleCreateResp

type ChannelRoleCreateResp ChannelRoleUpdateResp

ChannelRoleCreateResp is the response for ChannelRoleCreate.

type ChannelRoleDelete

type ChannelRoleDelete ChannelRoleBase

ChannelRoleDelete is the type for settings when deleting a role from channel setting.

type ChannelRoleIndex

type ChannelRoleIndex struct {
	PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"`
	PermissionUsers      []struct {
		User  User           `json:"user"`
		Allow RolePermission `json:"allow"`
		Deny  RolePermission `json:"deny"`
	} `json:"permission_users"`
	PermissionSync IntBool `json:"permission_sync"`
}

ChannelRoleIndex is the role and permission list of a channel.

type ChannelRoleUpdate

type ChannelRoleUpdate struct {
	ChannelRoleBase
	Allow RolePermission `json:"allow,omitempty"`
	Deny  RolePermission `json:"deny,omitempty"`
}

ChannelRoleUpdate is the request query data for ChannelRoleUpdate

type ChannelRoleUpdateResp

type ChannelRoleUpdateResp struct {
	UserID string         `json:"user_id"`
	RoleID string         `json:"role_id"`
	Allow  RolePermission `json:"allow"`
	Deny   RolePermission `json:"deny"`
}

ChannelRoleUpdateResp is the response of ChannelRoleUpdate

type ChannelType

type ChannelType int8

ChannelType is the type of a channel.

const (
	ChannelTypeText ChannelType = 1 + iota
	ChannelTypeVoice
)

These are all channel types.

type ChannelUpdate added in v0.0.34

type ChannelUpdate struct {
	ChannelID    string `json:"channel_id"`
	Name         string `json:"name,omitempty"`
	Level        int    `json:"level,omitempty"`
	ParentID     string `json:"parent_id,omitempty"`
	Topic        string `json:"topic,omitempty"`
	SlowMode     int    `json:"slow_mode,omitempty"`
	LimitAmount  int    `json:"limit_amount,omitempty"`
	VoiceQuality string `json:"voice_quality,omitempty"`
	Password     string `json:"password,omitempty"`
}

ChannelUpdate is the arguments for updating a channel's settings.

type ChannelUpdateContext

type ChannelUpdateContext struct {
	*EventHandlerCommonContext
	Extra Channel
}

func (*ChannelUpdateContext) GetCommon

func (*ChannelUpdateContext) GetExtra

func (ctx *ChannelUpdateContext) GetExtra() interface{}

type ChannelUpdateEventHandler

type ChannelUpdateEventHandler func(*ChannelUpdateContext)

func (ChannelUpdateEventHandler) Handle

func (ChannelUpdateEventHandler) New

func (ChannelUpdateEventHandler) Type

type ChannelViewOption added in v0.0.34

type ChannelViewOption func(values url.Values)

ChannelViewOption is the type for optional arguments for ChannelView request.

func ChannelViewWithNeedChildren added in v0.0.34

func ChannelViewWithNeedChildren(needChildren bool) ChannelViewOption

ChannelViewWithNeedChildren adds optional `need_children` argument to ChannelView request.

type DetailedChannelMessage

type DetailedChannelMessage struct {
	ID          string                  `json:"id"`
	Type        MessageType             `json:"type"`
	Author      User                    `json:"author"`
	Content     string                  `json:"content"`
	Mention     []string                `json:"mention"`
	MentionAll  bool                    `json:"mention_all"`
	MentionHere bool                    `json:"mention_here"`
	MentionRole []string                `json:"mention_role"`
	Embeds      []map[string]string     `json:"embeds"`
	Attachments *Attachment             `json:"attachments"`
	Reactions   []ReactionItem          `json:"reactions"`
	Quote       *DetailedChannelMessage `json:"quote"`
	MentionInfo struct {
		MentionPart     []*User `json:"mention_part"`
		MentionRolePart []*Role `json:"mention_role_part"`
	} `json:"mention_info"`
	ChannelID string `json:"channel_id"`
}

DetailedChannelMessage is the struct for a detailed message in a channel.

type DirectMessageCreate

type DirectMessageCreate struct {
	MessageCreateBase
	ChatCode string `json:"chat_code,omitempty"`
}

DirectMessageCreate is the struct for settings of creating a message in direct chat.

type DirectMessageCreateOption

type DirectMessageCreateOption func(*DirectMessageCreate)

DirectMessageCreateOption is the type for decorator of DirectMessageCreate.

func DirectMessageCreateWithCard

func DirectMessageCreateWithCard() DirectMessageCreateOption

DirectMessageCreateWithCard changes message type to card.

func DirectMessageCreateWithKmarkdown

func DirectMessageCreateWithKmarkdown() DirectMessageCreateOption

DirectMessageCreateWithKmarkdown changes message type to Kmarkdown.

type DirectMessageDeleteContext

type DirectMessageDeleteContext struct {
	*EventHandlerCommonContext
	Extra struct {
		AuthorID  string         `json:"author_id"`
		TargetID  string         `json:"target_id"`
		ChatCode  string         `json:"chat_code"`
		DeletedAt MilliTimeStamp `json:"deleted_at"`
		MsgID     string         `json:"msg_id"`
	}
}

func (*DirectMessageDeleteContext) GetCommon

func (*DirectMessageDeleteContext) GetExtra

func (ctx *DirectMessageDeleteContext) GetExtra() interface{}

type DirectMessageDeleteEventHandler

type DirectMessageDeleteEventHandler func(*DirectMessageDeleteContext)

func (DirectMessageDeleteEventHandler) Handle

func (DirectMessageDeleteEventHandler) New

func (DirectMessageDeleteEventHandler) Type

type DirectMessageListOption

type DirectMessageListOption func(values url.Values)

DirectMessageListOption is the type for optional arguments for DirectMessageList request.

func DirectMessageListWithChatCode

func DirectMessageListWithChatCode(chatCode string) DirectMessageListOption

DirectMessageListWithChatCode adds optional `chat_code` argument to DirectMessageList request.

func DirectMessageListWithFlag

func DirectMessageListWithFlag(flag MessageListFlag) DirectMessageListOption

DirectMessageListWithFlag adds optional `flag` argument to DirectMessageList request.

func DirectMessageListWithMsgID

func DirectMessageListWithMsgID(msgID string) DirectMessageListOption

DirectMessageListWithMsgID adds optional `msg_id` argument to DirectMessageList request.

func DirectMessageListWithTargetID

func DirectMessageListWithTargetID(targetID string) DirectMessageListOption

DirectMessageListWithTargetID adds optional `target_id` argument to DirectMessageList request.

type DirectMessageReactionAddContext

type DirectMessageReactionAddContext struct {
	*EventHandlerCommonContext
	Extra EventDirectChatReactionItem
}

func (*DirectMessageReactionAddContext) GetCommon

func (*DirectMessageReactionAddContext) GetExtra

func (ctx *DirectMessageReactionAddContext) GetExtra() interface{}

type DirectMessageReactionAddEventHandler

type DirectMessageReactionAddEventHandler func(*DirectMessageReactionAddContext)

func (DirectMessageReactionAddEventHandler) Handle

func (DirectMessageReactionAddEventHandler) New

func (DirectMessageReactionAddEventHandler) Type

type DirectMessageReactionDeleteContext

type DirectMessageReactionDeleteContext struct {
	*EventHandlerCommonContext
	Extra EventDirectChatReactionItem
}

func (*DirectMessageReactionDeleteContext) GetCommon

func (*DirectMessageReactionDeleteContext) GetExtra

func (ctx *DirectMessageReactionDeleteContext) GetExtra() interface{}

type DirectMessageReactionDeleteEventHandler

type DirectMessageReactionDeleteEventHandler func(*DirectMessageReactionDeleteContext)

func (DirectMessageReactionDeleteEventHandler) Handle

func (DirectMessageReactionDeleteEventHandler) New

func (DirectMessageReactionDeleteEventHandler) Type

type DirectMessageResp

type DirectMessageResp struct {
	ID          string              `json:"id"`
	Type        MessageType         `json:"type"`
	Content     string              `json:"content"`
	Embeds      []map[string]string `json:"embeds"`
	Attachments []Attachment        `json:"attachments"`
	CreateAt    MilliTimeStamp      `json:"create_at"`
	UpdatedAt   MilliTimeStamp      `json:"updated_at"`
	Reactions   []ReactionItem      `json:"reactions"`
	ImageName   string              `json:"image_name"`
	ReadStatus  bool                `json:"read_status"`
	Quote       *User               `json:"quote"`
	MentionInfo struct {
		MentionPart     []*User `json:"mention_part"`
		MentionRolePart []*Role `json:"mention_role_part"`
	} `json:"mention_info"`
}

DirectMessageResp is the type for direct messages.

type DirectMessageUpdate

type DirectMessageUpdate MessageUpdateBase

DirectMessageUpdate is the type for settings of updating a message in direct chat.

type DirectMessageUpdateContext

type DirectMessageUpdateContext struct {
	*EventHandlerCommonContext
	Extra struct {
		Content   string         `json:"content"`
		ChatCode  string         `json:"chat_code"`
		UpdatedAt MilliTimeStamp `json:"updated_at"`
		MsgID     string         `json:"msg_id"`
		AuthorID  string         `json:"author_id"`
		TargetID  string         `json:"target_id"`
	}
}

func (*DirectMessageUpdateContext) GetCommon

func (*DirectMessageUpdateContext) GetExtra

func (ctx *DirectMessageUpdateContext) GetExtra() interface{}

type DirectMessageUpdateEventHandler

type DirectMessageUpdateEventHandler func(*DirectMessageUpdateContext)

func (DirectMessageUpdateEventHandler) Handle

func (DirectMessageUpdateEventHandler) New

func (DirectMessageUpdateEventHandler) Type

type EmojiAddedContext added in v0.0.34

type EmojiAddedContext struct {
	*EventHandlerCommonContext
	Extra EventEmojiItem
}

func (*EmojiAddedContext) GetCommon added in v0.0.34

func (ctx *EmojiAddedContext) GetCommon() *EventHandlerCommonContext

func (*EmojiAddedContext) GetExtra added in v0.0.34

func (ctx *EmojiAddedContext) GetExtra() interface{}

type EmojiAddedEventHandler added in v0.0.34

type EmojiAddedEventHandler func(*EmojiAddedContext)

func (EmojiAddedEventHandler) Handle added in v0.0.34

func (eh EmojiAddedEventHandler) Handle(i EventContext)

func (EmojiAddedEventHandler) New added in v0.0.34

func (eh EmojiAddedEventHandler) New() EventContext

func (EmojiAddedEventHandler) Type added in v0.0.34

func (eh EmojiAddedEventHandler) Type() string

type EmojiItem

type EmojiItem struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

EmojiItem is the type for an emoji.

func (*EmojiItem) Convert

func (e *EmojiItem) Convert() string

Convert converts kook's emoji to standard emoji.

func (*EmojiItem) IsEqual

func (e *EmojiItem) IsEqual(s string) bool

IsEqual compares standard emoji string with kook's emoji representation.

type EndpointGeneralResponse

type EndpointGeneralResponse struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data"`
}

EndpointGeneralResponse is the struct for initial parsing REST requests.

type Entry

type Entry interface {
	Bool(key string, b bool) Entry
	Bytes(key string, val []byte) Entry
	Caller(depth int) Entry
	Dur(key string, d time.Duration) Entry
	Err(key string, err error) Entry
	Float64(key string, f float64) Entry
	IPAddr(key string, ip net.IP) Entry
	Int(key string, i int) Entry
	Int64(key string, i int64) Entry
	Interface(key string, i interface{}) Entry
	Msg(msg string)
	Msgf(f string, i ...interface{})
	Str(key string, s string) Entry
	Strs(key string, s []string) Entry
	Time(key string, t time.Time) Entry
}

Entry is the interface which external loggers' entry should meet.

type Event

type Event struct {
	Signal         EventSignal     `json:"s"`
	Data           json.RawMessage `json:"d"`
	SequenceNumber int64           `json:"sn"`
}

Event is the struct for every received event.

type EventCardMessageContext

type EventCardMessageContext struct {
	*EventHandlerCommonContext
	Extra EventCustomMessage
}

func (*EventCardMessageContext) GetCommon

func (*EventCardMessageContext) GetExtra

func (ctx *EventCardMessageContext) GetExtra() interface{}

type EventCardMessageEventHandler

type EventCardMessageEventHandler func(*EventCardMessageContext)

func (EventCardMessageEventHandler) Handle

func (EventCardMessageEventHandler) New

func (EventCardMessageEventHandler) Type

type EventContext

type EventContext interface {
	GetExtra() interface{}
	GetCommon() *EventHandlerCommonContext
}

EventContext is the interface for objects containing context for event handlers.

type EventCustomMessage

type EventCustomMessage struct {
	Mention      []string       `json:"mention"`
	MentionAll   bool           `json:"mention_all"`
	MentionRoles []int64        `json:"mention_roles"`
	MentionHere  bool           `json:"mention_here"`
	Author       User           `json:"author"`
	Kmarkdown    EventKmarkdown `json:"kmarkdown"`
	Quote        *Quote         `json:"quote"`
	GuildID      string         `json:"guild_id"`
	ChannelName  string         `json:"channel_name"`
}

func (*EventCustomMessage) UnmarshalJSON

func (m *EventCustomMessage) UnmarshalJSON(bytes []byte) error

UnmarshalJSON deals with untyped mention in custom message in event.

type EventData

type EventData struct {
	*EventDataGeneral
	Extra json.RawMessage `json:"extra"`
}

EventData is the struct for initial parsing event's data payload.

type EventDataGeneral

type EventDataGeneral struct {
	ChannelType  string      `json:"channel_type"`
	Type         MessageType `json:"type"`
	TargetID     string      `json:"target_id"`
	AuthorID     string      `json:"author_id"`
	Content      string      `json:"content"`
	MsgID        string      `json:"msg_id"`
	MsgTimestamp int64       `json:"msg_timestamp"`
	Nonce        string      `json:"nonce"`
}

EventDataGeneral is the struct passed to all event handler.

type EventDataHello

type EventDataHello struct {
	Code      EventStatusCode `json:"code"`
	SessionID string          `json:"session_id"`
}

EventDataHello is the struct for the data of event hello

type EventDataResumeAck

type EventDataResumeAck struct {
	SessionID string `json:"session_id"`
}

EventDataResumeAck is the struct for the data of event resume ack.

type EventDataSystem

type EventDataSystem struct {
	Type string          `json:"type"`
	Body json.RawMessage `json:"body"`
}

EventDataSystem is the struct for initial parsing system events. TODO: Implement a marshaller.

type EventDirectChatReactionItem

type EventDirectChatReactionItem struct {
	ChatCode string         `json:"chat_code"`
	Emoji    EventEmojiItem `json:"emoji"`
	MsgID    string         `json:"msg_id"`
	UserID   string         `json:"user_id"`
}

type EventEmojiItem added in v0.0.34

type EventEmojiItem struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type EventGuild

type EventGuild struct {
	WelcomeChannelID string          `json:"welcome_channel_id"`
	ID               string          `json:"id"`
	Name             string          `json:"name"`
	UserID           string          `json:"user_id"`
	Icon             string          `json:"icon"`
	Region           string          `json:"region"`
	OpenID           int64           `json:"open_id"`
	DefaultChannelID string          `json:"default_channel_id"`
	NotifyType       GuildNotifyType `json:"notify_type"`
	EnableOpen       IntBool         `json:"enable_open"`
}

type EventGuildMemberOnlineItem

type EventGuildMemberOnlineItem struct {
	EventTime MilliTimeStamp `json:"event_time"`
	Guilds    []string       `json:"guilds"`
	UserId    string         `json:"user_id"`
}

type EventHandler

type EventHandler interface {
	Type() string
	Handle(EventContext)
}

EventHandler is the interface for objects handling event.

type EventHandlerCommonContext

type EventHandlerCommonContext struct {
	Session *Session
	Common  *EventDataGeneral
}

EventHandlerCommonContext is the common context for event handlers.

type EventHandlerProvider

type EventHandlerProvider interface {
	Type() string
	New() EventContext
}

EventHandlerProvider is the interface for objects providing event handlers.

type EventKmarkdown

type EventKmarkdown struct {
	RawContent      string                 `json:"raw_content"`
	MentionPart     []EventMentionPart     `json:"mention_part"`
	MentionRolePart []EventMentionRolePart `json:"mention_role_part"`
}

type EventMentionPart

type EventMentionPart struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	FullName string `json:"full_name"`
	Avatar   string `json:"avatar"`
}

type EventMentionRolePart

type EventMentionRolePart struct {
	RoleID int64  `json:"role_id"`
	Name   string `json:"name"`
}

type EventPinMessageItem

type EventPinMessageItem struct {
	ChannelID  string `json:"channel_id"`
	OperatorID string `json:"operator_id"`
	MsgID      string `json:"msg_id"`
}

type EventReactionItem

type EventReactionItem struct {
	MsgID     string         `json:"msg_id"`
	UserID    string         `json:"user_id"`
	ChannelID string         `json:"channel_id"`
	Emoji     EventEmojiItem `json:"emoji"`
}

type EventRichMessage

type EventRichMessage struct {
	GuildID     string     `json:"guild_id"`
	Attachments Attachment `json:"attachments"`
	Author      User       `json:"author"`
}

type EventSignal

type EventSignal int8

EventSignal is the type for event types.

const (
	EventSignalEvent EventSignal = iota
	EventSignalHello
	EventSignalPing
	EventSignalPong
	EventSignalReconnect EventSignal = iota + 1
	EventSignalResumeAck
)

All event signal consts.

type EventStatusCode

type EventStatusCode int

EventStatusCode is the type for various event status code.

const (
	EventStatusOk              EventStatusCode = 0
	EventStatusMissingArgument EventStatusCode = 40100 + iota
	EventStatusInvalidToken
	EventStatusTokenAuthFailed
	EventStatusTokenExpired
	EventStatusResumeFailed EventStatusCode = 40100 + 2 + iota
	EventStatusSessionExpired
	EventStatusInvalidSequenceNumber
)

EventStatusCode consts for event status

type FileMessageContext

type FileMessageContext struct {
	*EventHandlerCommonContext
	Extra EventRichMessage
}

func (*FileMessageContext) GetCommon

func (*FileMessageContext) GetExtra

func (ctx *FileMessageContext) GetExtra() interface{}

type FileMessageEventHandler

type FileMessageEventHandler func(*FileMessageContext)

func (FileMessageEventHandler) Handle

func (FileMessageEventHandler) New

func (FileMessageEventHandler) Type

func (eh FileMessageEventHandler) Type() string

type Game

type Game struct {
	ID          int64    `json:"id"`
	Name        string   `json:"name"`
	Type        GameType `json:"type"`
	Options     string   `json:"options"`
	KmhookAdmin bool     `json:"kmhook_admin"`
	ProcessName []string `json:"process_name"`
	ProductName []string `json:"product_name"`
	Icon        string   `json:"icon"`
}

Game is a game item registered at kook.

type GameActivityMusicBody

type GameActivityMusicBody struct {
	Software  MusicSoftware `json:"software,omitempty"`
	Singer    string        `json:"singer,omitempty"`
	MusicName string        `json:"music_name,omitempty"`
}

GameActivityMusicBody is the necessary data for music activity.

type GameCreate

type GameCreate struct {
	Name        string `json:"name"`
	ProcessName string `json:"process_name,omitempty"`
	Icon        string `json:"icon,omitempty"`
}

GameCreate is the type for arguments of GameCreate request.

type GameListOption added in v0.0.34

type GameListOption func(values url.Values)

GameListOption is the type for optional arguments for GameList request.

func GameListWithType added in v0.0.34

func GameListWithType(t GameType) GameListOption

GameListWithType filters the type of game in GameList request.

type GameType

type GameType int

GameType is an enum for Game's type.

type GameUpdate

type GameUpdate struct {
	ID   int64  `json:"id"`
	Name string `json:"name,omitempty"`
	Icon string `json:"icon,omitempty"`
}

GameUpdate is the type for arguments of GameUpdate request.

type GeneralListData

type GeneralListData struct {
	Items json.RawMessage `json:"items"`
	Meta  PageInfo        `json:"meta"`
	Sort  map[string]int  `json:"sort"`
}

GeneralListData is the struct for list GET responses.

type Guild

type Guild struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Topic    string `json:"topic"`
	MasterID string `json:"master_id"`
	// For compatibility reason
	UserID           string          `json:"user_id"`
	Icon             string          `json:"icon"`
	NotifyType       GuildNotifyType `json:"notify_type"`
	Region           string          `json:"region"`
	EnableOpen       IntBool         `json:"enable_open"`
	OpenID           string          `json:"open_id"`
	DefaultChannelID string          `json:"default_channel_id"`
	WelcomeChannelID string          `json:"welcome_channel_id"`
	Roles            []Role          `json:"roles"`
	Channels         []Channel       `json:"channels"`
}

Guild is the struct for a server/guild(服务器).

func (Guild) GetMasterID

func (g Guild) GetMasterID() string

GetMasterID returns the master id of the guild, not sure if it is necessary as may doc is wrong.

type GuildBoostHistoryItem added in v0.0.34

type GuildBoostHistoryItem struct {
	UserID    string `json:"user_id"`
	GuildID   string `json:"guild_id"`
	StartTime int64  `json:"start_time"`
	EndTime   int64  `json:"end_time"`
	User      *User  `json:"user"`
}

GuildBoostHistoryItem is the historical supporter' info.

type GuildBoostHistoryOption added in v0.0.34

type GuildBoostHistoryOption func(values url.Values)

GuildBoostHistoryOption is the optional arguments for GuildBoostHistory requests.

func GuildBoostHistoryWithEndTime added in v0.0.34

func GuildBoostHistoryWithEndTime(t int64) GuildBoostHistoryOption

GuildBoostHistoryWithEndTime adds optional `end_time` argument to GuildBoostHistory request.

func GuildBoostHistoryWithStartTime added in v0.0.34

func GuildBoostHistoryWithStartTime(t int64) GuildBoostHistoryOption

GuildBoostHistoryWithStartTime adds optional `start_time` argument to GuildBoostHistory request.

type GuildChannelMemberAddContext

type GuildChannelMemberAddContext struct {
	*EventHandlerCommonContext
	Extra struct {
		JoinedAt  MilliTimeStamp `json:"joined_at"`
		UserID    string         `json:"user_id"`
		ChannelID string         `json:"channel_id"`
	}
}

func (*GuildChannelMemberAddContext) GetCommon

func (*GuildChannelMemberAddContext) GetExtra

func (ctx *GuildChannelMemberAddContext) GetExtra() interface{}

type GuildChannelMemberAddEventHandler

type GuildChannelMemberAddEventHandler func(*GuildChannelMemberAddContext)

func (GuildChannelMemberAddEventHandler) Handle

func (GuildChannelMemberAddEventHandler) New

func (GuildChannelMemberAddEventHandler) Type

type GuildChannelMemberDeleteContext

type GuildChannelMemberDeleteContext struct {
	*EventHandlerCommonContext
	Extra struct {
		UserID    string         `json:"user_id"`
		ChannelID string         `json:"channel_id"`
		ExitedAt  MilliTimeStamp `json:"exited_at"`
	}
}

func (*GuildChannelMemberDeleteContext) GetCommon

func (*GuildChannelMemberDeleteContext) GetExtra

func (ctx *GuildChannelMemberDeleteContext) GetExtra() interface{}

type GuildChannelMemberDeleteEventHandler

type GuildChannelMemberDeleteEventHandler func(*GuildChannelMemberDeleteContext)

func (GuildChannelMemberDeleteEventHandler) Handle

func (GuildChannelMemberDeleteEventHandler) New

func (GuildChannelMemberDeleteEventHandler) Type

type GuildDeleteContext

type GuildDeleteContext struct {
	*EventHandlerCommonContext
	Extra EventGuild
}

func (*GuildDeleteContext) GetCommon

func (*GuildDeleteContext) GetExtra

func (ctx *GuildDeleteContext) GetExtra() interface{}

type GuildDeleteEventHandler

type GuildDeleteEventHandler func(*GuildDeleteContext)

func (GuildDeleteEventHandler) Handle

func (GuildDeleteEventHandler) New

func (GuildDeleteEventHandler) Type

func (eh GuildDeleteEventHandler) Type() string

type GuildEmojiResp

type GuildEmojiResp struct {
	Name     string `json:"name"`
	ID       string `json:"id"`
	UserInfo User   `json:"user_info"`
}

GuildEmojiResp is the type for response of GuildEmojiList request.

type GuildMemberAddContext

type GuildMemberAddContext struct {
	*EventHandlerCommonContext
	Extra struct {
		UserID   string         `json:"user_id"`
		JoinedAt MilliTimeStamp `json:"joined_at"`
	}
}

func (*GuildMemberAddContext) GetCommon

func (*GuildMemberAddContext) GetExtra

func (ctx *GuildMemberAddContext) GetExtra() interface{}

type GuildMemberAddEventHandler

type GuildMemberAddEventHandler func(*GuildMemberAddContext)

func (GuildMemberAddEventHandler) Handle

func (GuildMemberAddEventHandler) New

func (GuildMemberAddEventHandler) Type

type GuildMemberDeleteContext

type GuildMemberDeleteContext struct {
	*EventHandlerCommonContext
	Extra struct {
		UserID   string         `json:"user_id"`
		ExitedAt MilliTimeStamp `json:"exited_at"`
	}
}

func (*GuildMemberDeleteContext) GetCommon

func (*GuildMemberDeleteContext) GetExtra

func (ctx *GuildMemberDeleteContext) GetExtra() interface{}

type GuildMemberDeleteEventHandler

type GuildMemberDeleteEventHandler func(*GuildMemberDeleteContext)

func (GuildMemberDeleteEventHandler) Handle

func (GuildMemberDeleteEventHandler) New

func (GuildMemberDeleteEventHandler) Type

type GuildMemberOfflineContext

type GuildMemberOfflineContext struct {
	*EventHandlerCommonContext
	Extra EventGuildMemberOnlineItem
}

func (*GuildMemberOfflineContext) GetCommon

func (*GuildMemberOfflineContext) GetExtra

func (ctx *GuildMemberOfflineContext) GetExtra() interface{}

type GuildMemberOfflineEventHandler

type GuildMemberOfflineEventHandler func(*GuildMemberOfflineContext)

func (GuildMemberOfflineEventHandler) Handle

func (GuildMemberOfflineEventHandler) New

func (GuildMemberOfflineEventHandler) Type

type GuildMemberOnlineContext

type GuildMemberOnlineContext struct {
	*EventHandlerCommonContext
	Extra EventGuildMemberOnlineItem
}

func (*GuildMemberOnlineContext) GetCommon

func (*GuildMemberOnlineContext) GetExtra

func (ctx *GuildMemberOnlineContext) GetExtra() interface{}

type GuildMemberOnlineEventHandler

type GuildMemberOnlineEventHandler func(*GuildMemberOnlineContext)

func (GuildMemberOnlineEventHandler) Handle

func (GuildMemberOnlineEventHandler) New

func (GuildMemberOnlineEventHandler) Type

type GuildMemberUpdateContext

type GuildMemberUpdateContext struct {
	*EventHandlerCommonContext
	Extra struct {
		Nickname string `json:"nickname"`
		UserID   string `json:"user_id"`
	}
}

func (*GuildMemberUpdateContext) GetCommon

func (*GuildMemberUpdateContext) GetExtra

func (ctx *GuildMemberUpdateContext) GetExtra() interface{}

type GuildMemberUpdateEventHandler

type GuildMemberUpdateEventHandler func(*GuildMemberUpdateContext)

func (GuildMemberUpdateEventHandler) Handle

func (GuildMemberUpdateEventHandler) New

func (GuildMemberUpdateEventHandler) Type

type GuildMuteList

type GuildMuteList struct {
	Mic     []string `json:"1"`
	Headset []string `json:"2"`
}

GuildMuteList is the type for users that got muted in a guild.

type GuildMuteSetting

type GuildMuteSetting struct {
	GuildID string   `json:"guild_id"`
	UserID  string   `json:"user_id"`
	Type    MuteType `json:"type"`
}

GuildMuteSetting is the type for arguments of GuildMuteSetting.

type GuildNickname

type GuildNickname struct {
	GuildID  string `json:"guild_id"`
	Nickname string `json:"nickname,omitempty"`
	UserID   string `json:"user_id,omitempty"`
}

GuildNickname is the arguments for GuildNickname.

type GuildNotifyType

type GuildNotifyType int8

GuildNotifyType is the type of the notify type of a guild.

const (
	GuildNotifyTypeDefault GuildNotifyType = iota
	GuildNotifyTypeAll
	GuildNotifyTypeMention
	GuildNotifyTypeDisable
)

These are all notify types.

type GuildRoleAddContext

type GuildRoleAddContext struct {
	*EventHandlerCommonContext
	Extra Role
}

func (*GuildRoleAddContext) GetCommon

func (*GuildRoleAddContext) GetExtra

func (ctx *GuildRoleAddContext) GetExtra() interface{}

type GuildRoleAddEventHandler

type GuildRoleAddEventHandler func(*GuildRoleAddContext)

func (GuildRoleAddEventHandler) Handle

func (GuildRoleAddEventHandler) New

func (GuildRoleAddEventHandler) Type

func (eh GuildRoleAddEventHandler) Type() string

type GuildRoleDeleteContext

type GuildRoleDeleteContext struct {
	*EventHandlerCommonContext
	Extra Role
}

func (*GuildRoleDeleteContext) GetCommon

func (*GuildRoleDeleteContext) GetExtra

func (ctx *GuildRoleDeleteContext) GetExtra() interface{}

type GuildRoleDeleteEventHandler

type GuildRoleDeleteEventHandler func(*GuildRoleDeleteContext)

func (GuildRoleDeleteEventHandler) Handle

func (GuildRoleDeleteEventHandler) New

func (GuildRoleDeleteEventHandler) Type

type GuildRoleResp

type GuildRoleResp struct {
	GuildID string  `json:"guild_id"`
	UserID  string  `json:"user_id"`
	Roles   []int64 `json:"roles"`
}

GuildRoleResp is the response of GuildRoleGrant request.

type GuildRoleUpdateContext

type GuildRoleUpdateContext struct {
	*EventHandlerCommonContext
	Extra Role
}

func (*GuildRoleUpdateContext) GetCommon

func (*GuildRoleUpdateContext) GetExtra

func (ctx *GuildRoleUpdateContext) GetExtra() interface{}

type GuildRoleUpdateEventHandler

type GuildRoleUpdateEventHandler func(*GuildRoleUpdateContext)

func (GuildRoleUpdateEventHandler) Handle

func (GuildRoleUpdateEventHandler) New

func (GuildRoleUpdateEventHandler) Type

type GuildUpdateContext

type GuildUpdateContext struct {
	*EventHandlerCommonContext
	Extra EventGuild
}

func (*GuildUpdateContext) GetCommon

func (*GuildUpdateContext) GetExtra

func (ctx *GuildUpdateContext) GetExtra() interface{}

type GuildUpdateEventHandler

type GuildUpdateEventHandler func(*GuildUpdateContext)

func (GuildUpdateEventHandler) Handle

func (GuildUpdateEventHandler) New

func (GuildUpdateEventHandler) Type

func (eh GuildUpdateEventHandler) Type() string

type GuildUserListInfo

type GuildUserListInfo struct {
	UserCount    int64 `json:"user_count"`
	OnlineCount  int64 `json:"online_count"`
	OfflineCount int64 `json:"offline_count"`
}

type GuildUserListOption

type GuildUserListOption func(values url.Values)

GuildUserListOption is the type for optional arguments for GuildUserList request.

func GuildUserListWithActiveTime

func GuildUserListWithActiveTime(activeTime bool) GuildUserListOption

GuildUserListWithActiveTime adds optional `active_time` argument to GuildUserList request.

func GuildUserListWithChannelID

func GuildUserListWithChannelID(id string) GuildUserListOption

GuildUserListWithChannelID adds optional `channel_id` argument to GuildUserList request.

func GuildUserListWithJoinedAt

func GuildUserListWithJoinedAt(joinedAt bool) GuildUserListOption

GuildUserListWithJoinedAt adds optional `joined_at` argument to GuildUserList request.

func GuildUserListWithMobileVerified

func GuildUserListWithMobileVerified(verified bool) GuildUserListOption

GuildUserListWithMobileVerified adds optional `mobile_verified` argument to GuildUserList request.

func GuildUserListWithRoleID

func GuildUserListWithRoleID(roleID int64) GuildUserListOption

GuildUserListWithRoleID adds optional `role_id` argument to GuildUserList request.

func GuildUserListWithSearch

func GuildUserListWithSearch(search string) GuildUserListOption

GuildUserListWithSearch adds optional `search` argument to GuildUserList request.

type Identify

type Identify struct {
	Token        string
	Compress     bool
	WebsocketKey []byte
	ClientID     string
	ClientSecret string
	VerifyToken  string
}

Identify is the struct for the initial settings sent to kookapp.

type ImageMessageContext

type ImageMessageContext struct {
	*EventHandlerCommonContext
	Extra EventRichMessage
}

func (*ImageMessageContext) GetCommon

func (*ImageMessageContext) GetExtra

func (ctx *ImageMessageContext) GetExtra() interface{}

type ImageMessageEventHandler

type ImageMessageEventHandler func(*ImageMessageContext)

func (ImageMessageEventHandler) Handle

func (ImageMessageEventHandler) New

func (ImageMessageEventHandler) Type

func (eh ImageMessageEventHandler) Type() string

type IntBool

type IntBool bool

IntBool is the type for some int value in response which only has two valid values.

func (*IntBool) MarshalJSON

func (i *IntBool) MarshalJSON() ([]byte, error)

MarshalJSON is used to marshal IntBool for reqeust.

func (*IntBool) UnmarshalJSON

func (i *IntBool) UnmarshalJSON(bytes []byte) error

UnmarshalJSON is used to unmarshal IntBool from response.

type IntimacyIndexResp

type IntimacyIndexResp struct {
	ImgURL     string         `json:"img_url"`
	SocialInfo string         `json:"social_info"`
	LastRead   MilliTimeStamp `json:"last_read"`
	Score      int            `json:"score"`
	ImgList    []struct {
		ID  string `json:"id"`
		URL string `json:"url"`
	} `json:"img_list"`
}

IntimacyIndexResp is the type for intimacy info.

type IntimacyUpdate

type IntimacyUpdate struct {
	UserID     string `json:"user_id"`
	Score      *int   `json:"score,omitempty"`
	SocialInfo string `json:"social_info,omitempty"`
	ImgID      int    `json:"img_id,omitempty"`
}

IntimacyUpdate is the type for arguments for IntimacyUpdate request.

type InviteCreate

type InviteCreate struct {
	GuildID      string             `json:"guild_id,omitempty"`
	ChannelID    string             `json:"channel_id,omitempty"`
	Duration     InviteDuration     `json:"duration,omitempty"`
	SettingTimes InviteSettingTimes `json:"setting_times,omitempty"`
}

InviteCreate is the type for arguments of InviteCreate request.

type InviteDelete

type InviteDelete struct {
	GuildID   string `json:"guild_id,omitempty"`
	ChannelID string `json:"channel_id,omitempty"`
	URLCode   string `json:"url_code"`
}

InviteDelete is the type for arguments of InviteDelete request.

type InviteDuration

type InviteDuration string

InviteDuration is the type for Duration in InviteCreate

You MUST use the enum defined below.

const (
	InviteDurationInfinity   InviteDuration = "0"
	InviteDurationHalfHour   InviteDuration = "1800"
	InviteDurationHour       InviteDuration = "3600"
	InviteDurationSixHour    InviteDuration = "21600"
	InviteDurationTwelveHour InviteDuration = "43200"
	InviteDurationDay        InviteDuration = "86400"
	InviteDurationWeek       InviteDuration = "604800"
)

These are allowed InviteDuration enums. You MUST use them.

type InviteListOption

type InviteListOption func(values url.Values)

InviteListOption is the optional arguments for InviteList requests.

func InviteListWithChannelID

func InviteListWithChannelID(channelID string) InviteListOption

InviteListWithChannelID adds optional `channel_id` argument to InviteList request.

func InviteListWithGuildID

func InviteListWithGuildID(guildID string) InviteListOption

InviteListWithGuildID adds optional `guild_id` argument to InviteList request.

type InviteListResp

type InviteListResp struct {
	GuildID   string `json:"guild_id"`
	ChannelID string `json:"channel_id"`
	URLCode   string `json:"url_code"`
	URL       string `json:"url"`
	User      User   `json:"user"`
}

InviteListResp is the type for response of InviteList request.

type InviteSettingTimes

type InviteSettingTimes int

InviteSettingTimes is the type for SettingTimes in InviteCreate

You SHOULD use the enum defined below.

const (
	InviteSettingTimesInfinity   InviteSettingTimes = -1
	InviteSettingTimesOne        InviteSettingTimes = 1
	InviteSettingTimesFive       InviteSettingTimes = 5
	InviteSettingTimesTen        InviteSettingTimes = 10
	InviteSettingTimesTwentyFive InviteSettingTimes = 25
	InviteSettingTimesFifty      InviteSettingTimes = 50
	InviteSettingTimesHundred    InviteSettingTimes = 100
)

These are allowed InviteSettingTimes enums. You SHOULD use them.

type KmarkdownMessageContext

type KmarkdownMessageContext struct {
	*EventHandlerCommonContext
	Extra EventCustomMessage
}

func (*KmarkdownMessageContext) GetCommon

func (*KmarkdownMessageContext) GetExtra

func (ctx *KmarkdownMessageContext) GetExtra() interface{}

type KmarkdownMessageEventHandler

type KmarkdownMessageEventHandler func(*KmarkdownMessageContext)

func (KmarkdownMessageEventHandler) Handle

func (KmarkdownMessageEventHandler) New

func (KmarkdownMessageEventHandler) Type

type Logger

type Logger interface {
	Trace() Entry
	Debug() Entry
	Info() Entry
	Warn() Entry
	Error() Entry
	Fatal() Entry
}

Logger is the interface which external loggers should meet.

type MessageButtonClickContext

type MessageButtonClickContext struct {
	*EventHandlerCommonContext
	Extra struct {
		MsgID    string `json:"msg_id"`
		UserID   string `json:"user_id"`
		Value    string `json:"value"`
		TargetID string `json:"target_id"`
		GuildID  string `json:"guild_id"`
		UserInfo User   `json:"user_info"`
	}
}

func (*MessageButtonClickContext) GetCommon

func (*MessageButtonClickContext) GetExtra

func (ctx *MessageButtonClickContext) GetExtra() interface{}

type MessageButtonClickEventHandler

type MessageButtonClickEventHandler func(*MessageButtonClickContext)

func (MessageButtonClickEventHandler) Handle

func (MessageButtonClickEventHandler) New

func (MessageButtonClickEventHandler) Type

type MessageCreate

type MessageCreate struct {
	MessageCreateBase
	TempTargetID string `json:"temp_target_id,omitempty"`
}

MessageCreate is the type for message creation arguments.

type MessageCreateBase

type MessageCreateBase struct {
	Type     MessageType `json:"type,omitempty"`
	TargetID string      `json:"target_id,omitempty"`
	Content  string      `json:"content,omitempty"`
	Quote    string      `json:"quote,omitempty"`
	Nonce    string      `json:"nonce,omitempty"`
}

MessageCreateBase is the common arguments for message creation.

type MessageCreateOption

type MessageCreateOption func(*MessageCreate)

MessageCreateOption is the type for decorator of MessageCreate.

func MessageCreateWithCard

func MessageCreateWithCard() MessageCreateOption

MessageCreateWithCard changes message type to card.

func MessageCreateWithKmarkdown

func MessageCreateWithKmarkdown() MessageCreateOption

MessageCreateWithKmarkdown changes message type to Kmarkdown.

type MessageDeleteContext

type MessageDeleteContext struct {
	*EventHandlerCommonContext
	Extra struct {
		MsgID     string `json:"msg_id"`
		ChannelID string `json:"channel_id"`
	}
}

func (*MessageDeleteContext) GetCommon

func (*MessageDeleteContext) GetExtra

func (ctx *MessageDeleteContext) GetExtra() interface{}

type MessageDeleteEventHandler

type MessageDeleteEventHandler func(*MessageDeleteContext)

func (MessageDeleteEventHandler) Handle

func (MessageDeleteEventHandler) New

func (MessageDeleteEventHandler) Type

type MessageListFlag

type MessageListFlag string

MessageListFlag is the type for the flag of MessageList.

const (
	MessageListFlagBefore MessageListFlag = "before"
	MessageListFlagAround MessageListFlag = "around"
	MessageListFlagAfter  MessageListFlag = "after"
)

These are the usable flags

type MessageListOption

type MessageListOption func(values url.Values)

MessageListOption is the type for optional arguments for MessageList request.

func MessageListWithFlag

func MessageListWithFlag(flag MessageListFlag) MessageListOption

MessageListWithFlag adds optional `flag` argument to MessageList request.

func MessageListWithMsgID

func MessageListWithMsgID(msgID string) MessageListOption

MessageListWithMsgID adds optional `msg_id` argument to MessageList request.

func MessageListWithPageSize added in v0.0.32

func MessageListWithPageSize(size int) MessageListOption

MessageListWithPageSize adds optional `page_size` argument to MessageList request.

func MessageListWithPin

func MessageListWithPin(pin bool) MessageListOption

MessageListWithPin adds optional `pin` argument to MessageList request.

type MessagePinContext

type MessagePinContext struct {
	*EventHandlerCommonContext
	Extra EventPinMessageItem
}

func (*MessagePinContext) GetCommon

func (ctx *MessagePinContext) GetCommon() *EventHandlerCommonContext

func (*MessagePinContext) GetExtra

func (ctx *MessagePinContext) GetExtra() interface{}

type MessagePinEventHandler

type MessagePinEventHandler func(*MessagePinContext)

func (MessagePinEventHandler) Handle

func (eh MessagePinEventHandler) Handle(i EventContext)

func (MessagePinEventHandler) New

func (MessagePinEventHandler) Type

func (eh MessagePinEventHandler) Type() string

type MessageReaction

type MessageReaction struct {
	MsgID     string    `json:"msg_id"`
	UserID    string    `json:"user_id"`
	ChannelID string    `json:"channel_id"`
	ChatCode  string    `json:"chat_code"`
	Emoji     EmojiItem `json:"emoji"`
}

MessageReaction is the struct for reactions embedded to a message.

type MessageResp

type MessageResp struct {
	MsgID        string         `json:"msg_id"`
	MsgTimestamp MilliTimeStamp `json:"msg_timestamp"`
	Nonce        string         `json:"nonce"`
}

MessageResp is the type for response for MessageCreate.

type MessageType

type MessageType uint8

MessageType is the type for messages from events.

const (
	MessageTypeText MessageType = 1 + iota
	MessageTypeImage
	MessageTypeVideo
	MessageTypeFile
	MessageTypeAudio MessageType = 4 + iota
	MessageTypeKMarkdown
	MessageTypeCard
	MessageTypeSystem MessageType = 255
)

MessageType consts for event message type

type MessageUnpinContext

type MessageUnpinContext struct {
	*EventHandlerCommonContext
	Extra EventPinMessageItem
}

func (*MessageUnpinContext) GetCommon

func (*MessageUnpinContext) GetExtra

func (ctx *MessageUnpinContext) GetExtra() interface{}

type MessageUnpinEventHandler

type MessageUnpinEventHandler func(*MessageUnpinContext)

func (MessageUnpinEventHandler) Handle

func (MessageUnpinEventHandler) New

func (MessageUnpinEventHandler) Type

func (eh MessageUnpinEventHandler) Type() string

type MessageUpdate

type MessageUpdate struct {
	MessageUpdateBase
	TempTargetID string `json:"temp_target_id,omitempty"`
}

MessageUpdate is the request data for MessageUpdate.

type MessageUpdateBase

type MessageUpdateBase struct {
	MsgID   string `json:"msg_id"`
	Content string `json:"content"`
	Quote   string `json:"quote,omitempty"`
}

MessageUpdateBase is the shared arguments for message update related requests.

type MessageUpdateContext

type MessageUpdateContext struct {
	*EventHandlerCommonContext
	Extra struct {
		UpdatedAt    MilliTimeStamp `json:"updated_at"`
		MsgID        string         `json:"msg_id"`
		Content      string         `json:"content"`
		ChannelID    string         `json:"channel_id"`
		Mention      []string       `json:"mention"`
		MentionAll   bool           `json:"mention_all"`
		MentionHere  bool           `json:"mention_here"`
		MentionRoles []int64        `json:"mention_roles"`
	}
}

func (*MessageUpdateContext) GetCommon

func (*MessageUpdateContext) GetExtra

func (ctx *MessageUpdateContext) GetExtra() interface{}

type MessageUpdateEventHandler

type MessageUpdateEventHandler func(*MessageUpdateContext)

func (MessageUpdateEventHandler) Handle

func (MessageUpdateEventHandler) New

func (MessageUpdateEventHandler) Type

type MessageWithAttachment

type MessageWithAttachment struct {
	Type        MessageType `json:"type"`
	Code        string      `json:"code"`
	GuildID     string      `json:"guild_id"`
	Attachments Attachment  `json:"attachments"`
	Author      User        `json:"author"`
}

MessageWithAttachment is a message with attachment.

type MilliTimeStamp

type MilliTimeStamp int64

MilliTimeStamp is the timestamp used in kookapp API.

func MilliTimeStampOfTime

func MilliTimeStampOfTime(t time.Time) MilliTimeStamp

MilliTimeStampOfTime converts the time.Time to MillTimeStamp

func (*MilliTimeStamp) ToTime

func (t *MilliTimeStamp) ToTime() time.Time

ToTime converts the timestamp to golang's time.Time.

type MusicSoftware

type MusicSoftware string

MusicSoftware is the types for predefined music software.

const (
	MusicSoftwareCloudMusic MusicSoftware = "cloudmusic"
	MusicSoftwareQQMusic    MusicSoftware = "qqmusic"
	MusicSoftwareKuGou      MusicSoftware = "kugou"
)

type MuteType

type MuteType int8

MuteType is the type for mute status.

const (
	MuteTypeMic MuteType = iota + 1
	MuteTypeHeadset
)

These are all mute types.

type PageInfo

type PageInfo struct {
	Page      int `json:"page"`
	PageTotal int `json:"page_total"`
	PageSize  int `json:"page_size"`
	Total     int `json:"total"`
}

PageInfo is the struct for page info in list GET responses.

type PageSetting

type PageSetting struct {
	Page     *int    `json:"page"`
	PageSize *int    `json:"page_size"`
	Sort     *string `json:"sort"`
}

PageSetting is the type for page setting in list GET request arguments.

type PermissionOverwrite

type PermissionOverwrite struct {
	RoleID int64          `json:"role_id"`
	Allow  RolePermission `json:"allow"`
	Deny   RolePermission `json:"deny"`
}

PermissionOverwrite is the struct for where needs to customize permission for a role in a channel.

type PrivateMessage

type PrivateMessage struct {
	MsgID     string         `json:"msg_id"`
	AuthorID  string         `json:"author_id"`
	TargetID  string         `json:"target_id"`
	Content   string         `json:"content"`
	ChatCode  string         `json:"chat_code"`
	UpdatedAt MilliTimeStamp `json:"updated_at"`
	DeletedAt MilliTimeStamp `json:"deleted_at"`
}

PrivateMessage is the struct for messages in direct chat.

type Quote

type Quote struct {
	ID       string         `json:"id"`
	Type     MessageType    `json:"type"`
	Content  string         `json:"content"`
	CreateAt MilliTimeStamp `json:"create_at"`
	Author   *User          `json:"author"`
	RongID   string         `json:"rong_id"`
}

Quote is the struct for quotes in message events.

type ReactedUser

type ReactedUser struct {
	User
	ReactionTime MilliTimeStamp `json:"reaction_time"`
	TagInfo      struct {
		Color string `json:"color"`
		Text  string `json:"text"`
	} `json:"tag_info"`
}

ReactedUser is the type for every user reacted to a specific message with a specific emoji.

type ReactionAddContext

type ReactionAddContext struct {
	*EventHandlerCommonContext
	Extra EventReactionItem
}

func (*ReactionAddContext) GetCommon

func (*ReactionAddContext) GetExtra

func (ctx *ReactionAddContext) GetExtra() interface{}

type ReactionAddEventHandler

type ReactionAddEventHandler func(*ReactionAddContext)

func (ReactionAddEventHandler) Handle

func (ReactionAddEventHandler) New

func (ReactionAddEventHandler) Type

func (eh ReactionAddEventHandler) Type() string

type ReactionDeleteContext

type ReactionDeleteContext struct {
	*EventHandlerCommonContext
	Extra EventReactionItem
}

func (*ReactionDeleteContext) GetCommon

func (*ReactionDeleteContext) GetExtra

func (ctx *ReactionDeleteContext) GetExtra() interface{}

type ReactionDeleteEventHandler

type ReactionDeleteEventHandler func(*ReactionDeleteContext)

func (ReactionDeleteEventHandler) Handle

func (ReactionDeleteEventHandler) New

func (ReactionDeleteEventHandler) Type

type ReactionItem

type ReactionItem struct {
	Emoji EmojiItem `json:"emoji"`
	Count int       `json:"count"`
	Me    bool      `json:"me"`
}

ReactionItem is the reactions for a emoji to a message.

type ReplyOption

type ReplyOption string

ReplyOption is the type providing additional options to Message event reply.

const (
	// ReplyOptionTemp let reply temporary.
	ReplyOptionTemp ReplyOption = "reply_option_temp"
)

type RestError

type RestError struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data"`
}

RestError is the error type for errors from kook

func (RestError) Error

func (r RestError) Error() string

Error provides the formatted error string

type Role

type Role struct {
	RoleID      int64          `json:"role_id"`
	Name        string         `json:"name,omitempty"`
	Color       int            `json:"color,omitempty"`
	Position    int            `json:"position"`
	Hoist       IntBool        `json:"hoist,omitempty"`
	Mentionable IntBool        `json:"mentionable,omitempty"`
	Permissions RolePermission `json:"permissions,omitempty"`
}

Role is the struct for a role in the guild.

type RolePermission

type RolePermission int64

RolePermission is the type for the permission of a user in guilds or channels.

const (
	RolePermissionAdmin RolePermission = 1 << iota
	RolePermissionManageGuild
	RolePermissionViewAuditLog
	RolePermissionCreateInvite
	RolePermissionManageInvite
	RolePermissionManageChannel
	RolePermissionKickUser
	RolePermissionBanUser
	RolePermissionManageGuildEmoji
	RolePermissionChangeNickname
	RolePermissionManageRolePermission
	RolePermissionViewChannel
	RolePermissionSendMessage
	RolePermissionManageMessage
	RolePermissionUploadFile
	RolePermissionConnectVoice
	RolePermissionManageVoice
	RolePermissionMentionEveryone
	RolePermissionCreateReaction
	RolePermissionFollowReaction
	RolePermissionInvitedToVoice
	RolePermissionForceManualVoice
	RolePermissionFreeVoice
	RolePermissionVoice
	RolePermissionManageUserVoiceReceive
	RolePermissionManageUserVoiceCreate
	RolePermissionManageNickname
	RolePermissionPlayMusic
)

These are the permission defined in system.

func (RolePermission) HasPermission

func (r RolePermission) HasPermission(p RolePermission) bool

HasPermission checks if having the provided permission.

type Session

type Session struct {
	sync.RWMutex

	Identify          Identify
	LastHeartbeatAck  time.Time
	LastHeartbeatSent time.Time
	Client            *http.Client
	MaxRetry          int
	RetryTimeout      time.Duration
	ContentType       string
	Logger            Logger
	Sync              bool
	// contains filtered or unexported fields
}

Session is the struct for a bot session.

func New

func New(token string, l Logger, o ...SessionOption) (s *Session)

New creates a kook session with default settings

func (*Session) AddHandler

func (s *Session) AddHandler(h interface{}) func()

AddHandler adds event handlers to session, and provides additional type check.

func (*Session) AssetCreate

func (s *Session) AssetCreate(name string, file []byte) (url string, err error)

AssetCreate uploads attachments to kook server.

FYI: https://developer.kookapp.cn/doc/http/asset#%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6/%E5%9B%BE%E7%89%87

func (*Session) BadgeGuildUrl

func (s *Session) BadgeGuildUrl(guildID string, style int) string

BadgeGuildUrl builds the url for guild badge.

func (*Session) BlacklistCreate

func (s *Session) BlacklistCreate(bc *BlacklistCreate) (err error)

BlacklistCreate adds user to blacklist

FYI: https://developer.kookapp.cn/doc/http/blacklist#%E5%8A%A0%E5%85%A5%E9%BB%91%E5%90%8D%E5%8D%95

func (*Session) BlacklistDelete

func (s *Session) BlacklistDelete(guildID, targetID string) (err error)

BlacklistDelete removes user from blacklist

FYI: https://developer.kookapp.cn/doc/http/blacklist#%E7%A7%BB%E9%99%A4%E9%BB%91%E5%90%8D%E5%8D%95

func (*Session) BlacklistList

func (s *Session) BlacklistList(guildID string, page *PageSetting) (bi []*BlacklistItem, meta *PageInfo, err error)

BlacklistList lists the users in blacklist.

FYI: https://developer.kookapp.cn/doc/http/blacklist

func (*Session) ChannelCreate

func (s *Session) ChannelCreate(cc *ChannelCreate) (c *Channel, err error)

ChannelCreate creates a channel. FYI: https://developer.kookapp.cn/doc/http/channel#%E5%88%9B%E5%BB%BA%E9%A2%91%E9%81%93

func (*Session) ChannelDelete

func (s *Session) ChannelDelete(channelID string) (err error)

ChannelDelete deletes a channel. FYI: https://developer.kookapp.cn/doc/http/channel#%E5%88%A0%E9%99%A4%E9%A2%91%E9%81%93

func (*Session) ChannelList

func (s *Session) ChannelList(guildID string, page *PageSetting) (cs []*Channel, meta *PageInfo, err error)

ChannelList lists all channels from a guild. FYI: https://developer.kookapp.cn/doc/http/channel#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E5%88%97%E8%A1%A8

func (*Session) ChannelMoveUsers

func (s *Session) ChannelMoveUsers(targetChannelID string, userIDs []string) (err error)

ChannelMoveUsers moves users to a channel. FYI: https://developer.kookapp.cn/doc/http/channel#%E8%AF%AD%E9%9F%B3%E9%A2%91%E9%81%93%E4%B9%8B%E9%97%B4%E7%A7%BB%E5%8A%A8%E7%94%A8%E6%88%B7

func (*Session) ChannelRoleDelete

func (s *Session) ChannelRoleDelete(crd *ChannelRoleDelete) (err error)

ChannelRoleDelete deletes a role form channel setting. FYI: https://developer.kookapp.cn/doc/http/channel#%E5%88%A0%E9%99%A4%E9%A2%91%E9%81%93%E8%A7%92%E8%89%B2%E6%9D%83%E9%99%90

func (*Session) ChannelRoleIndex

func (s *Session) ChannelRoleIndex(channelID string) (cr *ChannelRoleIndex, err error)

ChannelRoleIndex returns the role and permission list of the channel. FYI: https://developer.kookapp.cn/doc/http/channel#%E9%A2%91%E9%81%93%E8%A7%92%E8%89%B2%E6%9D%83%E9%99%90%E8%AF%A6%E6%83%85

func (*Session) ChannelRoleSync added in v0.0.34

func (s *Session) ChannelRoleSync(cid string) (err error)

ChannelRoleSync syncs the roles' permissions. FYI: https://developer.kookapp.cn/doc/http/channel#%E5%90%8C%E6%AD%A5%E9%A2%91%E9%81%93%E8%A7%92%E8%89%B2%E6%9D%83%E9%99%90

func (*Session) ChannelRoleUpdate

func (s *Session) ChannelRoleUpdate(cru *ChannelRoleUpdate) (crur *ChannelRoleUpdateResp, err error)

ChannelRoleUpdate updates a role from channel setting. FYI: https://developer.kookapp.cn/doc/http/channel#%E6%9B%B4%E6%96%B0%E9%A2%91%E9%81%93%E8%A7%92%E8%89%B2%E6%9D%83%E9%99%90

func (*Session) ChannelUpdate added in v0.0.34

func (s *Session) ChannelUpdate(cu *ChannelUpdate) (c *Channel, err error)

ChannelUpdate updates a channel's settings. FYI: https://developer.kookapp.cn/doc/http/channel#%E7%BC%96%E8%BE%91%E9%A2%91%E9%81%93

func (*Session) ChannelUserGetJoinedChannel

func (s *Session) ChannelUserGetJoinedChannel(guildID, userID string, page *PageSetting) (us []*UserInVoiceChannel, meta *PageInfo, err error)

ChannelUserGetJoinedChannel gets the user in voice channel

func (*Session) ChannelUserList

func (s *Session) ChannelUserList(channelID string) (us []*User, err error)

ChannelUserList returns a list of users in a voice channel.

func (*Session) ChannelView

func (s *Session) ChannelView(channelID string, options ...ChannelViewOption) (c *Channel, err error)

ChannelView returns the detailed information for a channel. FYI: https://developer.kookapp.cn/doc/http/channel#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E8%AF%A6%E6%83%85

func (*Session) Close

func (s *Session) Close() (err error)

Close closes a websocket connection.

func (*Session) CloseWithCode

func (s *Session) CloseWithCode(code int) (err error)

CloseWithCode closes a websocket connection with custom websocket closing code.

func (*Session) DirectMessageAddReaction

func (s *Session) DirectMessageAddReaction(msgID, emoji string) (err error)

DirectMessageAddReaction add a reaction to a message as the bot.

FYI: https://developer.kookapp.cn/doc/http/direct-message#%E7%BB%99%E6%9F%90%E4%B8%AA%E6%B6%88%E6%81%AF%E6%B7%BB%E5%8A%A0%E5%9B%9E%E5%BA%94

func (*Session) DirectMessageCreate

func (s *Session) DirectMessageCreate(create *DirectMessageCreate) (mr *MessageResp, err error)

DirectMessageCreate creates a message in direct chat. FYI: https://developer.kookapp.cn/doc/http/direct-message#%E5%8F%91%E9%80%81%E7%A7%81%E4%BF%A1%E8%81%8A%E5%A4%A9%E6%B6%88%E6%81%AF

func (*Session) DirectMessageDelete

func (s *Session) DirectMessageDelete(msgID string) (err error)

DirectMessageDelete deletes a message in direct chat. FYI: https://developer.kookapp.cn/doc/http/direct-message#%E5%88%A0%E9%99%A4%E7%A7%81%E4%BF%A1%E8%81%8A%E5%A4%A9%E6%B6%88%E6%81%AF

func (*Session) DirectMessageDeleteReaction

func (s *Session) DirectMessageDeleteReaction(msgID, emoji string) (err error)

DirectMessageDeleteReaction deletes a reaction of a user from a message.

FYI: https://developer.kookapp.cn/doc/http/direct-message#%E5%88%A0%E9%99%A4%E6%B6%88%E6%81%AF%E7%9A%84%E6%9F%90%E4%B8%AA%E5%9B%9E%E5%BA%94

func (*Session) DirectMessageReactionList

func (s *Session) DirectMessageReactionList(msgID, emoji string) (us []*ReactedUser, err error)

DirectMessageReactionList returns the list of the reacted users with a specific emoji to a message.

FYI: https://developer.kookapp.cn/doc/http/direct-message#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E6%B6%88%E6%81%AF%E6%9F%90%E5%9B%9E%E5%BA%94%E7%9A%84%E7%94%A8%E6%88%B7%E5%88%97%E8%A1%A8

func (*Session) DirectMessageUpdate

func (s *Session) DirectMessageUpdate(update *DirectMessageUpdate) (err error)

DirectMessageUpdate updates a message in direct chat. FYI: https://developer.kookapp.cn/doc/http/direct-message#%E6%9B%B4%E6%96%B0%E7%A7%81%E4%BF%A1%E8%81%8A%E5%A4%A9%E6%B6%88%E6%81%AF

func (*Session) DirectMessageView added in v0.0.34

func (s *Session) DirectMessageView(chatCode, msgID string) (dmr *DirectMessageResp, err error)

DirectMessageView returns the specified message. FYI: https://developer.kookapp.cn/doc/http/direct-message#%E8%8E%B7%E5%8F%96%E7%A7%81%E4%BF%A1%E8%81%8A%E5%A4%A9%E6%B6%88%E6%81%AF%E8%AF%A6%E6%83%85

func (*Session) GameActivity

func (s *Session) GameActivity(id int64, payloads ...interface{}) (err error)

GameActivity begins playing a game or music. Pass a GameActivityMusicBody to select music activity.

func (*Session) GameCreate

func (s *Session) GameCreate(gc *GameCreate) (g *Game, err error)

GameCreate creates a new Game in kook.

func (*Session) GameDelete

func (s *Session) GameDelete(id int64) (err error)

GameDelete deletes the Game info in kook

func (*Session) GameDeleteActivity

func (s *Session) GameDeleteActivity() (err error)

GameDeleteActivity stops playing a game.

func (*Session) GameList

func (s *Session) GameList(page *PageSetting, options ...GameListOption) (gs []*Game, meta *PageInfo, err error)

GameList lists the games registered.

func (*Session) GameUpdate

func (s *Session) GameUpdate(gu *GameUpdate) (g *Game, err error)

GameUpdate updates the Game info in kook

func (*Session) Gateway

func (s *Session) Gateway() (gateway string, err error)

Gateway returns the url for websocket gateway. FYI: https://developer.kookapp.cn/doc/http/gateway#%E8%8E%B7%E5%8F%96%E7%BD%91%E5%85%B3%E8%BF%9E%E6%8E%A5%E5%9C%B0%E5%9D%80

func (*Session) GuildBoostHistory added in v0.0.34

func (s *Session) GuildBoostHistory(guildID string, page *PageSetting, options ...GuildBoostHistoryOption) (hs []*GuildBoostHistoryItem, meta *PageInfo, err error)

GuildBoostHistory returns the boost history. FYI: https://developer.kookapp.cn/doc/http/guild#%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%8A%A9%E5%8A%9B%E5%8E%86%E5%8F%B2

func (*Session) GuildEmojiCreate

func (s *Session) GuildEmojiCreate(name, guildID string, emoji []byte) (ger *GuildEmojiResp, err error)

GuildEmojiCreate uploads emoji to guild.

FYI: https://developer.kookapp.cn/doc/http/guild-emoji#%E5%88%9B%E5%BB%BA%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%A1%A8%E6%83%85

func (*Session) GuildEmojiDelete

func (s *Session) GuildEmojiDelete(id string) (err error)

GuildEmojiDelete deletes an emoji from a guild.

FYI: https://developer.kookapp.cn/doc/http/guild-emoji#%E5%88%A0%E9%99%A4%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%A1%A8%E6%83%85

func (*Session) GuildEmojiList

func (s *Session) GuildEmojiList(guildID string, page *PageSetting) (gers []*GuildEmojiResp, meta *PageInfo, err error)

GuildEmojiList returns the list of emojis in a guild

FYI: https://developer.kookapp.cn/doc/http/guild-emoji#%E8%8E%B7%E5%8F%96%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%A1%A8%E6%83%85%E5%88%97%E8%A1%A8

func (*Session) GuildEmojiUpdate

func (s *Session) GuildEmojiUpdate(name, id string) (err error)

GuildEmojiUpdate updates an emoji's info in a guild.

FYI: https://developer.kookapp.cn/doc/http/guild-emoji#%E6%9B%B4%E6%96%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%A1%A8%E6%83%85

func (*Session) GuildKickout

func (s *Session) GuildKickout(guildID, targetID string) (err error)

GuildKickout force a user to leave a guild. FYI: https://developer.kookapp.cn/doc/http/guild#%E8%B8%A2%E5%87%BA%E6%9C%8D%E5%8A%A1%E5%99%A8

func (*Session) GuildLeave

func (s *Session) GuildLeave(guildID string) (err error)

GuildLeave let the bot leave a guild. FYI: https://developer.kookapp.cn/doc/http/guild#%E7%A6%BB%E5%BC%80%E6%9C%8D%E5%8A%A1%E5%99%A8

func (*Session) GuildMuteCreate

func (s *Session) GuildMuteCreate(gms *GuildMuteSetting) (err error)

GuildMuteCreate revokes a users privilege of using mic or headset. FYI: https://developer.kookapp.cn/doc/http/guild#%E6%B7%BB%E5%8A%A0%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%9D%99%E9%9F%B3%E6%88%96%E9%97%AD%E9%BA%A6

func (*Session) GuildMuteDelete

func (s *Session) GuildMuteDelete(gms *GuildMuteSetting) (err error)

GuildMuteDelete re-grants a users privilege of using mic or headset. FYI: https://developer.kookapp.cn/doc/http/guild#%E5%88%A0%E9%99%A4%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%9D%99%E9%9F%B3%E6%88%96%E9%97%AD%E9%BA%A6

func (*Session) GuildMuteList

func (s *Session) GuildMuteList(guildID string) (gml *GuildMuteList, err error)

GuildMuteList returns the list of users got mutes in mic or earphone. FYI: https://developer.kookapp.cn/doc/http/guild#%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%9D%99%E9%9F%B3%E9%97%AD%E9%BA%A6%E5%88%97%E8%A1%A8

func (*Session) GuildRoleCreate

func (s *Session) GuildRoleCreate(name, guildID string) (r *Role, err error)

GuildRoleCreate creates a role for a guild.

FYI: https://developer.kookapp.cn/doc/http/guild-role#%E5%88%9B%E5%BB%BA%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%A7%92%E8%89%B2

func (*Session) GuildRoleDelete

func (s *Session) GuildRoleDelete(guildID, roleID string) (err error)

GuildRoleDelete deletes a role from a guild.

FYI: https://developer.kookapp.cn/doc/http/guild-role#%E5%88%A0%E9%99%A4%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%A7%92%E8%89%B2

func (*Session) GuildRoleGrant

func (s *Session) GuildRoleGrant(guildID, userID string, roleID int64) (grr *GuildRoleResp, err error)

GuildRoleGrant grants a role to a user.

FYI: https://developer.kookapp.cn/doc/http/guild-role#%E8%B5%8B%E4%BA%88%E7%94%A8%E6%88%B7%E8%A7%92%E8%89%B2

func (*Session) GuildRoleList

func (s *Session) GuildRoleList(guildID string, page *PageSetting) (rs []*Role, meta *PageInfo, err error)

GuildRoleList returns the roles in a guild. FYI: https://developer.kookapp.cn/doc/http/guild-role#%E8%8E%B7%E5%8F%96%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%A7%92%E8%89%B2%E5%88%97%E8%A1%A8

func (*Session) GuildRoleRevoke

func (s *Session) GuildRoleRevoke(guildID, userID string, roleID int64) (grr *GuildRoleResp, err error)

GuildRoleRevoke revokes a role from a user.

FYI: https://developer.kookapp.cn/doc/http/guild-role#%E5%88%A0%E9%99%A4%E7%94%A8%E6%88%B7%E8%A7%92%E8%89%B2

func (*Session) GuildRoleUpdate

func (s *Session) GuildRoleUpdate(guildID string, role *Role) (r *Role, err error)

GuildRoleUpdate updates a role for a guild.

FYI: https://developer.kookapp.cn/doc/http/guild-role#%E6%9B%B4%E6%96%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%A7%92%E8%89%B2

func (*Session) GuildUserList

func (s *Session) GuildUserList(guildID string, page *PageSetting, options ...GuildUserListOption) (us []*User, guli *GuildUserListInfo, meta *PageInfo, err error)

GuildUserList returns the list of users in a guild. FYI: https://developer.kookapp.cn/doc/http/guild#%E8%8E%B7%E5%8F%96%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%AD%E7%9A%84%E7%94%A8%E6%88%B7%E5%88%97%E8%A1%A8

func (*Session) GuildView

func (s *Session) GuildView(guildID string) (g *Guild, err error)

GuildView returns a detailed info for a guild. FYI: https://developer.kookapp.cn/doc/http/guild#%E8%8E%B7%E5%8F%96%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%AF%A6%E6%83%85

func (*Session) IntimacyIndex

func (s *Session) IntimacyIndex(userID string) (iir *IntimacyIndexResp, err error)

IntimacyIndex returns the intimacy info for a user.

FYI: https://developer.kookapp.cn/doc/http/intimacy#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E4%BA%B2%E5%AF%86%E5%BA%A6

func (*Session) IntimacyUpdate

func (s *Session) IntimacyUpdate(iu *IntimacyUpdate) (err error)

IntimacyUpdate updates the intimacy info for a user.

FYI: https://developer.kookapp.cn/doc/http/intimacy#%E6%9B%B4%E6%96%B0%E7%94%A8%E6%88%B7%E4%BA%B2%E5%AF%86%E5%BA%A6

func (*Session) InviteCreate

func (s *Session) InviteCreate(ic *InviteCreate) (URL string, err error)

InviteCreate creates an invite link.

FYI: https://developer.kookapp.cn/doc/http/invite#%E5%88%9B%E5%BB%BA%E9%82%80%E8%AF%B7%E9%93%BE%E6%8E%A5

func (*Session) InviteDelete

func (s *Session) InviteDelete(id *InviteDelete) (err error)

InviteDelete deletes an invite link.

FYI: https://developer.kookapp.cn/doc/http/invite#%E5%88%A0%E9%99%A4%E9%82%80%E8%AF%B7%E9%93%BE%E6%8E%A5

func (*Session) InviteList

func (s *Session) InviteList(page *PageSetting, options ...InviteListOption) (ilrs []*InviteListResp, meta *PageInfo, err error)

InviteList lists invite links of a guild.

FYI: https://developer.kookapp.cn/doc/http/invite#%E8%8E%B7%E5%8F%96%E9%82%80%E8%AF%B7%E5%88%97%E8%A1%A8

func (*Session) MessageAddReaction

func (s *Session) MessageAddReaction(msgID, emoji string) (err error)

MessageAddReaction add a reaction to a message as the bot. FYI: https://developer.kookapp.cn/doc/http/message#%E7%BB%99%E6%9F%90%E4%B8%AA%E6%B6%88%E6%81%AF%E6%B7%BB%E5%8A%A0%E5%9B%9E%E5%BA%94

func (*Session) MessageDeleteReaction

func (s *Session) MessageDeleteReaction(msgID, emoji string, userID string) (err error)

MessageDeleteReaction deletes a reaction of a user from a message. FYI: https://developer.kookapp.cn/doc/http/message#%E5%88%A0%E9%99%A4%E6%B6%88%E6%81%AF%E7%9A%84%E6%9F%90%E4%B8%AA%E5%9B%9E%E5%BA%94

func (*Session) MessageList

func (s *Session) MessageList(targetID string, options ...MessageListOption) (ms []*DetailedChannelMessage, err error)

MessageList returns a list of messages of a channel. FYI: https://developer.kookapp.cn/doc/http/message#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E8%81%8A%E5%A4%A9%E6%B6%88%E6%81%AF%E5%88%97%E8%A1%A8

func (*Session) MessageReactionList

func (s *Session) MessageReactionList(msgID, emoji string) (us []*ReactedUser, err error)

MessageReactionList returns the list of the reacted users with a specific emoji to a message. FYI: https://developer.kookapp.cn/doc/http/message#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E6%B6%88%E6%81%AF%E6%9F%90%E5%9B%9E%E5%BA%94%E7%9A%84%E7%94%A8%E6%88%B7%E5%88%97%E8%A1%A8

func (*Session) Open

func (s *Session) Open() (err error)

Open starts a websocket connection. It does not block the function.

func (*Session) Request

func (s *Session) Request(method, url string, data interface{}) (response []byte, err error)

Request is the wrapper for internal request method, you would prefer to use other method other than this.

func (*Session) RequestWithPage

func (s *Session) RequestWithPage(method, u string, page *PageSetting) (response []byte, meta *PageInfo, err error)

RequestWithPage is the wrapper for internal list GET request, you would prefer to use other method other than this.

func (*Session) UserChatCreate

func (s *Session) UserChatCreate(UserID string) (uc *UserChat, err error)

UserChatCreate creates a direct chat session. FYI: https://developer.kookapp.cn/doc/http/user-chat#%E5%88%9B%E5%BB%BA%E7%A7%81%E4%BF%A1%E8%81%8A%E5%A4%A9%E4%BC%9A%E8%AF%9D

func (*Session) UserChatDelete

func (s *Session) UserChatDelete(ChatCode string) (err error)

UserChatDelete deletes a direct chat session. FYI: https://developer.kookapp.cn/doc/http/user-chat#%E5%88%9B%E5%BB%BA%E7%A7%81%E4%BF%A1%E8%81%8A%E5%A4%A9%E4%BC%9A%E8%AF%9D

func (*Session) UserChatList

func (s *Session) UserChatList(page *PageSetting) (ucs []*UserChat, meta *PageInfo, err error)

UserChatList returns a list of user chats that bot owns.

Note: for User in TargetInfo, only ID, Username, Online, Avatar is filled

FYI: https://developer.kookapp.cn/doc/http/user-chat#%E8%8E%B7%E5%8F%96%E7%A7%81%E4%BF%A1%E8%81%8A%E5%A4%A9%E4%BC%9A%E8%AF%9D%E5%88%97%E8%A1%A8

func (*Session) UserOffline

func (s *Session) UserOffline() error

UserOffline logout the bot.

func (*Session) UserView

func (s *Session) UserView(userID string, options ...UserViewOption) (u *User, err error)

UserView returns a user's info FYI: https://developer.kookapp.cn/doc/http/user#%E8%8E%B7%E5%8F%96%E7%9B%AE%E6%A0%87%E7%94%A8%E6%88%B7%E4%BF%A1%E6%81%AF

func (*Session) WebhookHandler

func (s *Session) WebhookHandler() http.HandlerFunc

WebhookHandler provides a http.HandlerFunc for webhook.

type SessionOption

type SessionOption func(*Session)

SessionOption is the optional arguments for creating a session.

func SessionWithEncryptKey

func SessionWithEncryptKey(key []byte) SessionOption

SessionWithEncryptKey adds the key for decrypting webhook request.

func SessionWithVerifyToken

func SessionWithVerifyToken(token string) SessionOption

SessionWithVerifyToken adds the token for verifying webhook request.

type SnStore

type SnStore interface {
	TestAndInsert(int64) bool
	Lock()
	Unlock()
	Clear()
}

SnStore is the interface for storing sequence numbers.

type TextMessageContext

type TextMessageContext struct {
	*EventHandlerCommonContext
	Extra struct {
		Author       User     `json:"author"`
		Quote        *Quote   `json:"quote"`
		GuildID      string   `json:"guild_id"`
		ChannelName  string   `json:"channel_name"`
		Mention      []string `json:"mention"`
		MentionAll   bool     `json:"mention_all"`
		MentionRoles []int64  `json:"mention_roles"`
		MentionHere  bool     `json:"mention_here"`
	}
}

func (*TextMessageContext) GetCommon

func (*TextMessageContext) GetExtra

func (ctx *TextMessageContext) GetExtra() interface{}

func (*TextMessageContext) Reply

func (c *TextMessageContext) Reply(text string, options ...interface{}) (*MessageResp, error)

Reply is a helper function for replying to a message.

It accept optional MessageCreateOption, DirectMessageCreateOption and ReplyOption arguments.

type TextMessageEventHandler

type TextMessageEventHandler func(*TextMessageContext)

func (TextMessageEventHandler) Handle

func (TextMessageEventHandler) New

func (TextMessageEventHandler) Type

func (eh TextMessageEventHandler) Type() string

type User

type User struct {
	ID          string     `json:"id"`
	Username    string     `json:"username"`
	IdentifyNum string     `json:"identify_num"`
	Online      bool       `json:"online"`
	Status      UserStatus `json:"status"`
	Avatar      string     `json:"avatar"`
	VipAvatar   string     `json:"vip_avatar"`
	Bot         bool       `json:"bot"`
	// MobileVerified bool           `json:"mobile_verified"`
	System       bool           `json:"system"`
	MobilePrefix string         `json:"mobile_prefix"`
	Mobile       string         `json:"mobile"`
	InviteCount  int64          `json:"invite_count"`
	Nickname     string         `json:"nickname"`
	Roles        []int64        `json:"roles"`
	FullName     string         `json:"full_name"`
	IsVip        bool           `json:"is_vip"`
	JoinedAt     MilliTimeStamp `json:"joined_at"`
	ActiveTime   MilliTimeStamp `json:"active_time"`
	Os           string         `json:"os"`
	Banner       string         `json:"banner"`
}

User is the struct for a user. Some property may missing.

type UserChat

type UserChat struct {
	Code            string         `json:"code"`
	LastReadTime    MilliTimeStamp `json:"last_read_time"`
	LatestMsgTime   MilliTimeStamp `json:"latest_msg_time"`
	UnreadCount     int            `json:"unread_count"`
	IsFriend        bool           `json:"is_friend"`
	IsBlocked       bool           `json:"is_blocked"`
	IsTargetBlocked bool           `json:"is_target_blocked"`
	TargetInfo      User           `json:"target_info"`
}

UserChat is the struct for DirectMessage or UserChat

type UserInVoiceChannel

type UserInVoiceChannel struct {
	ID                   string                    `json:"id"`
	GuildID              string                    `json:"guild_id"`
	MasterID             string                    `json:"master_id"`
	ParentID             string                    `json:"parent_id"`
	UserID               string                    `json:"user_id"`
	Name                 string                    `json:"name"`
	Topic                string                    `json:"topic"`
	Type                 ChannelType               `json:"type"`
	Level                int                       `json:"level"`
	SlowMode             int                       `json:"slow_mode"`
	LimitAmount          int                       `json:"limit_amount"`
	IsCategory           bool                      `json:"is_category"`
	PermissionOverwrites []PermissionOverwrite     `json:"permission_overwrites"`
	PermissionUsers      []UserPermissionOverwrite `json:"permission_users"`
	PermissionSync       IntBool                   `json:"permission_sync"`
}

UserInVoiceChannel is a user in a voice channel

type UserPermissionOverwrite

type UserPermissionOverwrite struct {
	User  *User          `json:"user"`
	Allow RolePermission `json:"allow"`
	Deny  RolePermission `json:"deny"`
}

UserPermissionOverwrite is the struct for where needs to customize permission for a user in a channel.

type UserStatus

type UserStatus int8

UserStatus is the type for user status(banned or not).

const (
	UserStatusNormal UserStatus = 1
	UserStatusBanned UserStatus = 10
)

These are all the status of a user.

func (UserStatus) IsBanned

func (r UserStatus) IsBanned() bool

IsBanned checks if the user is banned.

type UserUpdateContext

type UserUpdateContext struct {
	*EventHandlerCommonContext
	Extra struct {
		UserID   string `json:"user_id"`
		Username string `json:"username"`
		Avatar   string `json:"avatar"`
	}
}

func (*UserUpdateContext) GetCommon

func (ctx *UserUpdateContext) GetCommon() *EventHandlerCommonContext

func (*UserUpdateContext) GetExtra

func (ctx *UserUpdateContext) GetExtra() interface{}

type UserUpdateEventHandler

type UserUpdateEventHandler func(*UserUpdateContext)

func (UserUpdateEventHandler) Handle

func (eh UserUpdateEventHandler) Handle(i EventContext)

func (UserUpdateEventHandler) New

func (UserUpdateEventHandler) Type

func (eh UserUpdateEventHandler) Type() string

type UserViewOption

type UserViewOption func(value url.Values)

UserViewOption is the optional arguments for UserView requests.

func UserViewWithGuildID

func UserViewWithGuildID(guildID string) UserViewOption

UserViewWithGuildID add the optional `guild_id` arguments to UserView request

type VideoMessageContext

type VideoMessageContext struct {
	*EventHandlerCommonContext
	Extra EventRichMessage
}

func (*VideoMessageContext) GetCommon

func (*VideoMessageContext) GetExtra

func (ctx *VideoMessageContext) GetExtra() interface{}

type VideoMessageEventHandler

type VideoMessageEventHandler func(*VideoMessageContext)

func (VideoMessageEventHandler) Handle

func (VideoMessageEventHandler) New

func (VideoMessageEventHandler) Type

func (eh VideoMessageEventHandler) Type() string

Directories

Path Synopsis
examples module
log_adapter
plog Module
zap Module
tools

Jump to

Keyboard shortcuts

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