khl

package module
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: ISC Imports: 23 Imported by: 0

README

KHL

A low level library for interacting with kaiheila(开黑啦) bot API. Currently, it is WIP.

Go Reference Go Report Card Server Badger

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/khl

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/khl/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

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

Special Thanks To:

GoLand logo

Built using IntelliJ IDEA

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	APIVersion = "v3"

	EndpointBase          = "https://www.kaiheila.cn/api"
	EndpointAPI           = urlJoin(EndpointBase, APIVersion)
	EndpointGuild         = urlJoin(EndpointAPI, "guild")
	EndpointGuildMute     = urlJoin(EndpointAPI, "guild-mute")
	EndpointChannel       = urlJoin(EndpointAPI, "channel")
	EndpointChannelRole   = urlJoin(EndpointAPI, "channel-role")
	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")

	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")

	// EndpointChannelMessage is Deprecated.
	EndpointChannelMessage    = urlJoin(EndpointChannel, "message")
	EndpointChannelList       = urlJoin(EndpointChannel, "list")
	EndpointChannelView       = urlJoin(EndpointChannel, "view")
	EndpointChannelCreate     = urlJoin(EndpointChannel, "create")
	EndpointChannelMoveUser   = urlJoin(EndpointChannel, "move-user")
	EndpointChannelDelete     = urlJoin(EndpointChannel, "delete")
	EndpointChannelRoleIndex  = urlJoin(EndpointChannelRole, "index")
	EndpointChannelRoleCreate = urlJoin(EndpointChannelRole, "create")
	EndpointChannelRoleUpdate = urlJoin(EndpointChannelRole, "update")
	EndpointChannelRoleDelete = urlJoin(EndpointChannelRole, "delete")

	EndpointMessageList           = urlJoin(EndpointMessage, "list")
	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")
	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")
)

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 added in v0.0.4

type AudioMessageContext struct {
	*EventHandlerCommonContext
	Extra EventRichMessage
}

func (*AudioMessageContext) GetCommon added in v0.0.4

func (*AudioMessageContext) GetExtra added in v0.0.4

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

type AudioMessageEventHandler added in v0.0.4

type AudioMessageEventHandler func(*AudioMessageContext)

func (AudioMessageEventHandler) Handle added in v0.0.4

func (AudioMessageEventHandler) New added in v0.0.4

func (AudioMessageEventHandler) Type added in v0.0.4

func (eh AudioMessageEventHandler) Type() string

type BlockListAddContext added in v0.0.4

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

func (*BlockListAddContext) GetCommon added in v0.0.4

func (*BlockListAddContext) GetExtra added in v0.0.4

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

type BlockListAddEventHandler added in v0.0.4

type BlockListAddEventHandler func(*BlockListAddContext)

func (BlockListAddEventHandler) Handle added in v0.0.4

func (BlockListAddEventHandler) New added in v0.0.4

func (BlockListAddEventHandler) Type added in v0.0.4

func (eh BlockListAddEventHandler) Type() string

type BlockListDeleteContext added in v0.0.4

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

func (*BlockListDeleteContext) GetCommon added in v0.0.4

func (*BlockListDeleteContext) GetExtra added in v0.0.4

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

type BlockListDeleteEventHandler added in v0.0.4

type BlockListDeleteEventHandler func(*BlockListDeleteContext)

func (BlockListDeleteEventHandler) Handle added in v0.0.4

func (BlockListDeleteEventHandler) New added in v0.0.4

func (BlockListDeleteEventHandler) Type added in v0.0.4

type BotExitContext added in v0.0.4

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

func (*BotExitContext) GetCommon added in v0.0.4

func (ctx *BotExitContext) GetCommon() *EventHandlerCommonContext

func (*BotExitContext) GetExtra added in v0.0.4

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

type BotExitEventHandler added in v0.0.4

type BotExitEventHandler func(*BotExitContext)

func (BotExitEventHandler) Handle added in v0.0.4

func (eh BotExitEventHandler) Handle(i EventContext)

func (BotExitEventHandler) New added in v0.0.4

func (BotExitEventHandler) Type added in v0.0.4

func (eh BotExitEventHandler) Type() string

type BotJoinContext added in v0.0.4

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

func (*BotJoinContext) GetCommon added in v0.0.4

func (ctx *BotJoinContext) GetCommon() *EventHandlerCommonContext

func (*BotJoinContext) GetExtra added in v0.0.4

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

type BotJoinEventHandler added in v0.0.4

type BotJoinEventHandler func(*BotJoinContext)

func (BotJoinEventHandler) Handle added in v0.0.4

func (eh BotJoinEventHandler) Handle(i EventContext)

func (BotJoinEventHandler) New added in v0.0.4

func (BotJoinEventHandler) Type added in v0.0.4

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, *CardMessageActionGroup, *CardMessageContext, *CardMessageDivider, *CardMessageFile, *CardMessageCountdown.

func (CardMessageCard) MarshalJSON

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

MarshalJSON adds additional type field when marshaling

type CardMessageContainer added in v0.0.14

type CardMessageContainer []CardMessageElementImage

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

func (*CardMessageContainer) AddElements added in v0.0.14

AddElements adds elements to container.

func (CardMessageContainer) MarshalJSON added in v0.0.14

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 added in v0.0.17

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 added in v0.0.17

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 added in v0.0.17

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 added in v0.0.17

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

CardMessageInvite is the type for 邀请模块.

func (CardMessageInvite) MarshalJSON added in v0.0.17

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 and *CardMessageContext

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 added in v0.0.17

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"`
}

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

type ChannelAddContext added in v0.0.4

type ChannelAddContext struct {
	*EventHandlerCommonContext
	Extra Channel
}

func (*ChannelAddContext) GetCommon added in v0.0.4

func (ctx *ChannelAddContext) GetCommon() *EventHandlerCommonContext

func (*ChannelAddContext) GetExtra added in v0.0.4

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 int         `json:"voice_quality,omitempty"`
}

ChannelCreate is the arguments for creating a channel.

type ChannelDeleteContext added in v0.0.4

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

func (*ChannelDeleteContext) GetCommon added in v0.0.4

func (*ChannelDeleteContext) GetExtra added in v0.0.4

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

type ChannelDeleteEventHandler added in v0.0.4

type ChannelDeleteEventHandler func(*ChannelDeleteContext)

func (ChannelDeleteEventHandler) Handle added in v0.0.4

func (ChannelDeleteEventHandler) New added in v0.0.4

func (ChannelDeleteEventHandler) Type added in v0.0.4

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 added in v0.0.17

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 ChannelUpdateContext added in v0.0.4

type ChannelUpdateContext struct {
	*EventHandlerCommonContext
	Extra Channel
}

func (*ChannelUpdateContext) GetCommon added in v0.0.4

func (*ChannelUpdateContext) GetExtra added in v0.0.4

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

type ChannelUpdateEventHandler

type ChannelUpdateEventHandler func(*ChannelUpdateContext)

func (ChannelUpdateEventHandler) Handle

func (ChannelUpdateEventHandler) New

func (ChannelUpdateEventHandler) Type

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"`
}

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 added in v0.0.16

type DirectMessageCreateOption func(*DirectMessageCreate)

DirectMessageCreateOption is the type for decorator of DirectMessageCreate.

func DirectMessageCreateWithCard added in v0.0.16

func DirectMessageCreateWithCard() DirectMessageCreateOption

DirectMessageCreateWithCard changes message type to card.

func DirectMessageCreateWithKmarkdown added in v0.0.16

func DirectMessageCreateWithKmarkdown() DirectMessageCreateOption

DirectMessageCreateWithKmarkdown changes message type to Kmarkdown.

type DirectMessageDeleteContext added in v0.0.4

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 added in v0.0.4

func (*DirectMessageDeleteContext) GetExtra added in v0.0.4

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

type DirectMessageDeleteEventHandler added in v0.0.4

type DirectMessageDeleteEventHandler func(*DirectMessageDeleteContext)

func (DirectMessageDeleteEventHandler) Handle added in v0.0.4

func (DirectMessageDeleteEventHandler) New added in v0.0.4

func (DirectMessageDeleteEventHandler) Type added in v0.0.4

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 added in v0.0.4

type DirectMessageReactionAddContext struct {
	*EventHandlerCommonContext
	Extra EventDirectChatReactionItem
}

func (*DirectMessageReactionAddContext) GetCommon added in v0.0.4

func (*DirectMessageReactionAddContext) GetExtra added in v0.0.4

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

type DirectMessageReactionAddEventHandler added in v0.0.4

type DirectMessageReactionAddEventHandler func(*DirectMessageReactionAddContext)

func (DirectMessageReactionAddEventHandler) Handle added in v0.0.4

func (DirectMessageReactionAddEventHandler) New added in v0.0.4

func (DirectMessageReactionAddEventHandler) Type added in v0.0.4

type DirectMessageReactionDeleteContext added in v0.0.4

type DirectMessageReactionDeleteContext struct {
	*EventHandlerCommonContext
	Extra EventDirectChatReactionItem
}

func (*DirectMessageReactionDeleteContext) GetCommon added in v0.0.4

func (*DirectMessageReactionDeleteContext) GetExtra added in v0.0.4

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

type DirectMessageReactionDeleteEventHandler added in v0.0.4

type DirectMessageReactionDeleteEventHandler func(*DirectMessageReactionDeleteContext)

func (DirectMessageReactionDeleteEventHandler) Handle added in v0.0.4

func (DirectMessageReactionDeleteEventHandler) New added in v0.0.4

func (DirectMessageReactionDeleteEventHandler) Type added in v0.0.4

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 added in v0.0.4

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

func (*DirectMessageUpdateContext) GetCommon added in v0.0.4

func (*DirectMessageUpdateContext) GetExtra added in v0.0.4

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

type DirectMessageUpdateEventHandler added in v0.0.4

type DirectMessageUpdateEventHandler func(*DirectMessageUpdateContext)

func (DirectMessageUpdateEventHandler) Handle added in v0.0.4

func (DirectMessageUpdateEventHandler) New added in v0.0.4

func (DirectMessageUpdateEventHandler) Type added in v0.0.4

type EmojiItem

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

EmojiItem is the type for an emoji.

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 added in v0.0.4

type EventCardMessageContext struct {
	*EventHandlerCommonContext
	Extra EventCustomMessage
}

func (*EventCardMessageContext) GetCommon added in v0.0.4

func (*EventCardMessageContext) GetExtra added in v0.0.4

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

type EventCardMessageEventHandler

type EventCardMessageEventHandler func(*EventCardMessageContext)

func (EventCardMessageEventHandler) Handle

func (EventCardMessageEventHandler) New

func (EventCardMessageEventHandler) Type

type EventContext added in v0.0.4

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

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

type EventCustomMessage added in v0.0.4

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

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 added in v0.0.4

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

type EventGuild added in v0.0.4

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

type EventGuildMemberOnlineItem added in v0.0.4

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 added in v0.0.4

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 added in v0.0.4

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

type EventMentionPart added in v0.0.13

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

type EventMentionRolePart added in v0.0.13

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

type EventPinMessageItem added in v0.0.4

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

type EventReactionItem added in v0.0.4

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

type EventRichMessage added in v0.0.4

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 added in v0.0.4

type FileMessageContext struct {
	*EventHandlerCommonContext
	Extra EventRichMessage
}

func (*FileMessageContext) GetCommon added in v0.0.4

func (*FileMessageContext) GetExtra added in v0.0.4

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

type FileMessageEventHandler added in v0.0.4

type FileMessageEventHandler func(*FileMessageContext)

func (FileMessageEventHandler) Handle added in v0.0.4

func (FileMessageEventHandler) New added in v0.0.4

func (FileMessageEventHandler) Type added in v0.0.4

func (eh FileMessageEventHandler) Type() string

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 GuildChannelMemberAddContext added in v0.0.4

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

func (*GuildChannelMemberAddContext) GetCommon added in v0.0.4

func (*GuildChannelMemberAddContext) GetExtra added in v0.0.4

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

type GuildChannelMemberAddEventHandler added in v0.0.4

type GuildChannelMemberAddEventHandler func(*GuildChannelMemberAddContext)

func (GuildChannelMemberAddEventHandler) Handle added in v0.0.4

func (GuildChannelMemberAddEventHandler) New added in v0.0.4

func (GuildChannelMemberAddEventHandler) Type added in v0.0.4

type GuildChannelMemberDeleteContext added in v0.0.4

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

func (*GuildChannelMemberDeleteContext) GetCommon added in v0.0.4

func (*GuildChannelMemberDeleteContext) GetExtra added in v0.0.4

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

type GuildChannelMemberDeleteEventHandler added in v0.0.4

type GuildChannelMemberDeleteEventHandler func(*GuildChannelMemberDeleteContext)

func (GuildChannelMemberDeleteEventHandler) Handle added in v0.0.4

func (GuildChannelMemberDeleteEventHandler) New added in v0.0.4

func (GuildChannelMemberDeleteEventHandler) Type added in v0.0.4

type GuildDeleteContext added in v0.0.4

type GuildDeleteContext struct {
	*EventHandlerCommonContext
	Extra EventGuild
}

func (*GuildDeleteContext) GetCommon added in v0.0.4

func (*GuildDeleteContext) GetExtra added in v0.0.4

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 added in v0.0.4

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

func (*GuildMemberAddContext) GetCommon added in v0.0.4

func (*GuildMemberAddContext) GetExtra added in v0.0.4

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

type GuildMemberAddEventHandler

type GuildMemberAddEventHandler func(*GuildMemberAddContext)

func (GuildMemberAddEventHandler) Handle

func (GuildMemberAddEventHandler) New

func (GuildMemberAddEventHandler) Type

type GuildMemberDeleteContext added in v0.0.4

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

func (*GuildMemberDeleteContext) GetCommon added in v0.0.4

func (*GuildMemberDeleteContext) GetExtra added in v0.0.4

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

type GuildMemberDeleteEventHandler added in v0.0.4

type GuildMemberDeleteEventHandler func(*GuildMemberDeleteContext)

func (GuildMemberDeleteEventHandler) Handle added in v0.0.4

func (GuildMemberDeleteEventHandler) New added in v0.0.4

func (GuildMemberDeleteEventHandler) Type added in v0.0.4

type GuildMemberOfflineContext added in v0.0.4

type GuildMemberOfflineContext struct {
	*EventHandlerCommonContext
	Extra EventGuildMemberOnlineItem
}

func (*GuildMemberOfflineContext) GetCommon added in v0.0.4

func (*GuildMemberOfflineContext) GetExtra added in v0.0.4

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

type GuildMemberOfflineEventHandler

type GuildMemberOfflineEventHandler func(*GuildMemberOfflineContext)

func (GuildMemberOfflineEventHandler) Handle

func (GuildMemberOfflineEventHandler) New

func (GuildMemberOfflineEventHandler) Type

type GuildMemberOnlineContext added in v0.0.4

type GuildMemberOnlineContext struct {
	*EventHandlerCommonContext
	Extra EventGuildMemberOnlineItem
}

func (*GuildMemberOnlineContext) GetCommon added in v0.0.4

func (*GuildMemberOnlineContext) GetExtra added in v0.0.4

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

type GuildMemberOnlineEventHandler

type GuildMemberOnlineEventHandler func(*GuildMemberOnlineContext)

func (GuildMemberOnlineEventHandler) Handle

func (GuildMemberOnlineEventHandler) New

func (GuildMemberOnlineEventHandler) Type

type GuildMemberUpdateContext added in v0.0.4

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

func (*GuildMemberUpdateContext) GetCommon added in v0.0.4

func (*GuildMemberUpdateContext) GetExtra added in v0.0.4

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 added in v0.0.4

type GuildRoleAddContext struct {
	*EventHandlerCommonContext
	Extra Role
}

func (*GuildRoleAddContext) GetCommon added in v0.0.4

func (*GuildRoleAddContext) GetExtra added in v0.0.4

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 added in v0.0.4

type GuildRoleDeleteContext struct {
	*EventHandlerCommonContext
	Extra Role
}

func (*GuildRoleDeleteContext) GetCommon added in v0.0.4

func (*GuildRoleDeleteContext) GetExtra added in v0.0.4

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

type GuildRoleDeleteEventHandler added in v0.0.4

type GuildRoleDeleteEventHandler func(*GuildRoleDeleteContext)

func (GuildRoleDeleteEventHandler) Handle added in v0.0.4

func (GuildRoleDeleteEventHandler) New added in v0.0.4

func (GuildRoleDeleteEventHandler) Type added in v0.0.4

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 added in v0.0.4

type GuildRoleUpdateContext struct {
	*EventHandlerCommonContext
	Extra Role
}

func (*GuildRoleUpdateContext) GetCommon added in v0.0.4

func (*GuildRoleUpdateContext) GetExtra added in v0.0.4

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

type GuildRoleUpdateEventHandler

type GuildRoleUpdateEventHandler func(*GuildRoleUpdateContext)

func (GuildRoleUpdateEventHandler) Handle

func (GuildRoleUpdateEventHandler) New

func (GuildRoleUpdateEventHandler) Type

type GuildUpdateContext added in v0.0.4

type GuildUpdateContext struct {
	*EventHandlerCommonContext
	Extra EventGuild
}

func (*GuildUpdateContext) GetCommon added in v0.0.4

func (*GuildUpdateContext) GetExtra added in v0.0.4

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 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 kaiheila.

type ImageMessageContext added in v0.0.4

type ImageMessageContext struct {
	*EventHandlerCommonContext
	Extra EventRichMessage
}

func (*ImageMessageContext) GetCommon added in v0.0.4

func (*ImageMessageContext) GetExtra added in v0.0.4

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

type ImageMessageEventHandler added in v0.0.4

type ImageMessageEventHandler func(*ImageMessageContext)

func (ImageMessageEventHandler) Handle added in v0.0.4

func (ImageMessageEventHandler) New added in v0.0.4

func (ImageMessageEventHandler) Type added in v0.0.4

func (eh ImageMessageEventHandler) Type() string

type IntBool added in v0.0.2

type IntBool bool

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

func (*IntBool) MarshalJSON added in v0.0.2

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

MarshalJSON is used to marshal IntBool for reqeust.

func (*IntBool) UnmarshalJSON added in v0.0.2

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"`
	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 added in v0.0.17

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 added in v0.0.17

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 added in v0.0.4

type KmarkdownMessageContext struct {
	*EventHandlerCommonContext
	Extra EventCustomMessage
}

func (*KmarkdownMessageContext) GetCommon added in v0.0.4

func (*KmarkdownMessageContext) GetExtra added in v0.0.4

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

type KmarkdownMessageEventHandler added in v0.0.4

type KmarkdownMessageEventHandler func(*KmarkdownMessageContext)

func (KmarkdownMessageEventHandler) Handle added in v0.0.4

func (KmarkdownMessageEventHandler) New added in v0.0.4

func (KmarkdownMessageEventHandler) Type added in v0.0.4

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 added in v0.0.4

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

func (*MessageButtonClickContext) GetCommon added in v0.0.4

func (*MessageButtonClickContext) GetExtra added in v0.0.4

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

type MessageButtonClickEventHandler added in v0.0.4

type MessageButtonClickEventHandler func(*MessageButtonClickContext)

func (MessageButtonClickEventHandler) Handle added in v0.0.4

func (MessageButtonClickEventHandler) New added in v0.0.4

func (MessageButtonClickEventHandler) Type added in v0.0.4

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 added in v0.0.16

type MessageCreateOption func(*MessageCreate)

MessageCreateOption is the type for decorator of MessageCreate.

func MessageCreateWithCard added in v0.0.16

func MessageCreateWithCard() MessageCreateOption

MessageCreateWithCard changes message type to card.

func MessageCreateWithKmarkdown added in v0.0.16

func MessageCreateWithKmarkdown() MessageCreateOption

MessageCreateWithKmarkdown changes message type to Kmarkdown.

type MessageDeleteContext added in v0.0.4

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

func (*MessageDeleteContext) GetCommon added in v0.0.4

func (*MessageDeleteContext) GetExtra added in v0.0.4

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

type MessageDeleteEventHandler added in v0.0.4

type MessageDeleteEventHandler func(*MessageDeleteContext)

func (MessageDeleteEventHandler) Handle added in v0.0.4

func (MessageDeleteEventHandler) New added in v0.0.4

func (MessageDeleteEventHandler) Type added in v0.0.4

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 MessageListWithPin

func MessageListWithPin(pin bool) MessageListOption

MessageListWithPin adds optional `pin` argument to MessageList request.

type MessagePinContext added in v0.0.4

type MessagePinContext struct {
	*EventHandlerCommonContext
	Extra EventPinMessageItem
}

func (*MessagePinContext) GetCommon added in v0.0.4

func (ctx *MessagePinContext) GetCommon() *EventHandlerCommonContext

func (*MessagePinContext) GetExtra added in v0.0.4

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

type MessagePinEventHandler added in v0.0.4

type MessagePinEventHandler func(*MessagePinContext)

func (MessagePinEventHandler) Handle added in v0.0.4

func (eh MessagePinEventHandler) Handle(i EventContext)

func (MessagePinEventHandler) New added in v0.0.4

func (MessagePinEventHandler) Type added in v0.0.4

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 added in v0.0.4

type MessageUnpinContext struct {
	*EventHandlerCommonContext
	Extra EventPinMessageItem
}

func (*MessageUnpinContext) GetCommon added in v0.0.4

func (*MessageUnpinContext) GetExtra added in v0.0.4

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

type MessageUnpinEventHandler added in v0.0.4

type MessageUnpinEventHandler func(*MessageUnpinContext)

func (MessageUnpinEventHandler) Handle added in v0.0.4

func (MessageUnpinEventHandler) New added in v0.0.4

func (MessageUnpinEventHandler) Type added in v0.0.4

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 added in v0.0.4

type MessageUpdateContext struct {
	*EventHandlerCommonContext
	Extra struct {
		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"`
		UpdatedAt    MilliTimeStamp `json:"updated_at"`
		MsgID        string         `json:"msg_id"`
	}
}

func (*MessageUpdateContext) GetCommon added in v0.0.4

func (*MessageUpdateContext) GetExtra added in v0.0.4

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

type MessageUpdateEventHandler added in v0.0.4

type MessageUpdateEventHandler func(*MessageUpdateContext)

func (MessageUpdateEventHandler) Handle added in v0.0.4

func (MessageUpdateEventHandler) New added in v0.0.4

func (MessageUpdateEventHandler) Type added in v0.0.4

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 kaiheila API.

func MilliTimeStampOfTime added in v0.0.17

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 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 added in v0.0.16

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

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 added in v0.0.4

type ReactionAddContext struct {
	*EventHandlerCommonContext
	Extra EventReactionItem
}

func (*ReactionAddContext) GetCommon added in v0.0.4

func (*ReactionAddContext) GetExtra added in v0.0.4

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

type ReactionAddEventHandler added in v0.0.4

type ReactionAddEventHandler func(*ReactionAddContext)

func (ReactionAddEventHandler) Handle added in v0.0.4

func (ReactionAddEventHandler) New added in v0.0.4

func (ReactionAddEventHandler) Type added in v0.0.4

func (eh ReactionAddEventHandler) Type() string

type ReactionDeleteContext added in v0.0.4

type ReactionDeleteContext struct {
	*EventHandlerCommonContext
	Extra EventReactionItem
}

func (*ReactionDeleteContext) GetCommon added in v0.0.4

func (*ReactionDeleteContext) GetExtra added in v0.0.4

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

type ReactionDeleteEventHandler added in v0.0.4

type ReactionDeleteEventHandler func(*ReactionDeleteContext)

func (ReactionDeleteEventHandler) Handle added in v0.0.4

func (ReactionDeleteEventHandler) New added in v0.0.4

func (ReactionDeleteEventHandler) Type added in v0.0.4

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 added in v0.0.16

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 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 khl 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 khl server.

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

func (*Session) ChannelCreate

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

ChannelCreate creates a channel. FYI: https://developer.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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) ChannelRoleUpdate

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

ChannelRoleUpdate updates a role from channel setting. FYI: https://developer.kaiheila.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) ChannelView

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

ChannelView returns the detailed information for a channel. FYI: https://developer.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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) Gateway

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

Gateway returns the url for websocket gateway. FYI: https://developer.kaiheila.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) GuildEmojiCreate

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

GuildEmojiCreate uploads emoji to guild.

FYI: https://developer.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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, meta *PageInfo, err error)

GuildUserList returns the list of users in a guild. FYI: https://developer.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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.kaiheila.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 added in v0.0.17

func (s *Session) UserOffline() error

UserOffline logout the bot.

func (*Session) UserView added in v0.0.9

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

UserView returns a user's info FYI: https://developer.kaiheila.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 added in v0.0.8

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

WebhookHandler provides a http.HandlerFunc for webhook.

type SessionOption added in v0.0.8

type SessionOption func(*Session)

SessionOption is the optional arguments for creating a session.

func SessionWithEncryptKey added in v0.0.8

func SessionWithEncryptKey(key []byte) SessionOption

SessionWithEncryptKey adds the key for decrypting webhook request.

func SessionWithVerifyToken added in v0.0.8

func SessionWithVerifyToken(token string) SessionOption

SessionWithVerifyToken adds the token for verifying webhook request.

type SnStore added in v0.0.8

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

SnStore is the interface for storing sequence numbers.

type TextMessageContext added in v0.0.4

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

func (*TextMessageContext) GetCommon added in v0.0.4

func (*TextMessageContext) GetExtra added in v0.0.4

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

func (*TextMessageContext) Reply added in v0.0.16

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 added in v0.0.4

type TextMessageEventHandler func(*TextMessageContext)

func (TextMessageEventHandler) Handle added in v0.0.4

func (TextMessageEventHandler) New added in v0.0.4

func (TextMessageEventHandler) Type added in v0.0.4

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"`
}

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 UserPermissionOverwrite added in v0.0.11

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 added in v0.0.4

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

func (*UserUpdateContext) GetCommon added in v0.0.4

func (ctx *UserUpdateContext) GetCommon() *EventHandlerCommonContext

func (*UserUpdateContext) GetExtra added in v0.0.4

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 added in v0.0.9

type UserViewOption func(value url.Values)

UserViewOption is the optional arguments for UserView requests.

func UserViewWithGuildID added in v0.0.9

func UserViewWithGuildID(guildID string) UserViewOption

UserViewWithGuildID add the optional `guild_id` arguments to UserView request

type VideoMessageContext added in v0.0.4

type VideoMessageContext struct {
	*EventHandlerCommonContext
	Extra EventRichMessage
}

func (*VideoMessageContext) GetCommon added in v0.0.4

func (*VideoMessageContext) GetExtra added in v0.0.4

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

type VideoMessageEventHandler added in v0.0.4

type VideoMessageEventHandler func(*VideoMessageContext)

func (VideoMessageEventHandler) Handle added in v0.0.4

func (VideoMessageEventHandler) New added in v0.0.4

func (VideoMessageEventHandler) Type added in v0.0.4

func (eh VideoMessageEventHandler) Type() string

Directories

Path Synopsis
log_adapter
plog Module
zap Module

Jump to

Keyboard shortcuts

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