Documentation
¶
Index ¶
- Constants
- Variables
- func Ref[V any](v V) *V
- type BaseClient
- type BaseRTCResponse
- type Channel
- type ChannelCurrentlyTypingUpdate
- type ChannelID
- type ChannelPosition
- type ChannelStateEvent
- type ChannelType
- type ChannelWatchingUpdate
- type Clickable
- type Client
- type CreatePlanetData
- type EditMessageData
- type EditPlanetData
- type Embed
- type EmbedButton
- type EmbedEventTarget
- type EmbedFormSubmitTarget
- type EmbedItem
- type EmbedItemType
- type EmbedLinkTarget
- type EmbedOption
- type EmbedPage
- type EmbedPageTarget
- type EmbedRow
- type EmbedText
- type Emoji
- type EmojiID
- type Member
- type MemberID
- type Message
- type MessageAttachment
- type MessageAttachmentType
- type MessageCreateEvent
- type MessageDeleteEvent
- type MessageEditEvent
- type MessageID
- type MessageReactionAddedEvent
- type MessageReactionEvent
- type MessageReactionRemovedEvent
- type Node
- func (n *Node) Channels(id PlanetID) ([]Channel, error)
- func (n *Node) Close() error
- func (n *Node) Connected() bool
- func (n *Node) CreatePlanet(planet CreatePlanetData) (*Planet, error)
- func (n *Node) DeleteMessage(id MessageID) error
- func (n *Node) DeletePlanet(id PlanetID) error
- func (n *Node) DeleteRole(planetID PlanetID, roleID RoleID) error
- func (n *Node) EditMessage(id MessageID, m EditMessageData) (*Message, error)
- func (n *Node) GetNodeNameForPlanet(planetID PlanetID) (string, error)
- func (n *Node) IsPrimary() bool
- func (n *Node) JoinAllChannels(ctx context.Context) error
- func (n *Node) JoinPlanet(planet PlanetID, inviteCode string) error
- func (n *Node) Me() (*User, error)
- func (n *Node) Member(id MemberID) (*Member, error)
- func (n *Node) MemberByUser(planetID PlanetID, id UserID) (*Member, error)
- func (n *Node) Message(id MessageID) (*Message, error)
- func (n *Node) MessageReactionAdd(id MessageID, emoji string) error
- func (n *Node) MessageReactionRemove(id MessageID, emoji string) error
- func (n *Node) Messages(planetID PlanetID, channelID ChannelID, limit uint) ([]Message, error)
- func (n *Node) MessagesBefore(planetID PlanetID, channelID ChannelID, index MessageID, limit uint) ([]Message, error)
- func (n *Node) MyMember(planetID PlanetID) (*Member, error)
- func (n *Node) NodeForPlanet(planetID PlanetID) (*Node, error)
- func (n *Node) NodeName() (string, error)
- func (n *Node) Open(ctx context.Context) error
- func (n *Node) Planet(id PlanetID) (*Planet, error)
- func (n *Node) PlanetInitialData(id PlanetID) (*PlanetInitialData, error)
- func (n *Node) Planets() ([]Planet, error)
- func (n *Node) Role(planetID PlanetID, roleID RoleID) (*Role, error)
- func (n *Node) SendMessage(planetID PlanetID, channelID ChannelID, content string) (*Message, error)
- func (n *Node) SendMessageComplex(planetID PlanetID, channelID ChannelID, send SendMessageData) (*Message, error)
- func (n *Node) UpdatePlanet(id PlanetID, data EditPlanetData) (*Planet, error)
- func (n *Node) UpdateRole(planetID PlanetID, role Role) (*Role, error)
- func (n *Node) UploadFile(fileName string, r io.Reader, size int64) (*MessageAttachment, error)
- func (n *Node) UploadImage(fileName string, r io.Reader, size int64) (*MessageAttachment, error)
- func (n *Node) Version() (string, error)
- type NodeOption
- type Option
- type Planet
- type PlanetDeleteEvent
- type PlanetID
- type PlanetInitialData
- type PlanetJoinEvent
- type PlanetMemberDelete
- type PlanetMemberUpdate
- type PlanetUpdateEvent
- type RTC
- func (r *RTC) Authorize(token string) error
- func (r *RTC) Close() error
- func (r *RTC) JoinChannel(channel ChannelID) error
- func (r *RTC) JoinPlanet(planet PlanetID) error
- func (r *RTC) JoinUser() error
- func (r *RTC) LeaveChannel(channel ChannelID) error
- func (r *RTC) LeavePlanet(planet PlanetID) error
- func (r *RTC) Ping() error
- func (r *RTC) Start()
- func (r *RTC) State() RTCState
- type RTCAuthResponse
- type RTCError
- type RTCState
- type Reaction
- type Role
- type RoleID
- type SendMessageData
- type Snowflake
- type Tag
- type TargetType
- type Time
- type User
- type UserID
- type UserUpdateEvent
Constants ¶
const ( ClickTargetLink = 1 + iota ClickTargetPage ClickTargetEvent ClickTargetFormSubmit )
const Epoch = 1610339820000 * time.Millisecond
Epoch timestamp is 01/11/2021 4:37:00 UTC
const (
LatestMessageIndex = MessageID(9223372036854775807)
)
LatestMessageIndex is long.MaxValue in C#, this will return our latest messages only
const NullSnowflake = Snowflake(0)
Variables ¶
var ( ErrAlreadyOpen = errors.New("connection already open") ErrInvalidResponseType = errors.New("invalid response type for request") )
var ErrInvalidCount = errors.New("invalid message count")
var (
ErrInvalidPing = errors.New("invalid ping response")
)
Functions ¶
Types ¶
type BaseClient ¶
type BaseClient struct {
*Node
// contains filtered or unexported fields
}
type BaseRTCResponse ¶
type Channel ¶
type Channel struct {
ID ChannelID `json:"id"`
PlanetID PlanetID `json:"planetId"`
ParentID ChannelID `json:"parentId"`
ChannelType ChannelType `json:"channelType"`
Name string `json:"name"`
Description string `json:"description"`
InheritsPerms bool `json:"inheritsPerms"`
IsDefault bool `json:"isDefault"`
RawPosition int64 `json:"rawPosition"`
Position ChannelPosition `json:"position"`
LastUpdateTime time.Time `json:"lastUpdateTime"`
}
type ChannelPosition ¶
type ChannelStateEvent ¶
type ChannelType ¶
type ChannelType int
const ( PlanetChat ChannelType = iota PlanetCategory PlanetVoice DirectChat DirectVoice GroupChat GroupVoice )
type ChannelWatchingUpdate ¶
type Client ¶
type Client interface {
handler.HandlerInterface
NodeName() (string, error)
Version() (string, error)
Open(ctx context.Context) error
Connected() bool
JoinAllChannels(ctx context.Context) error
Close() error
NodeForPlanet(planetID PlanetID) (*Node, error)
GetNodeNameForPlanet(planetID PlanetID) (string, error)
Planets() ([]Planet, error)
Planet(id PlanetID) (*Planet, error)
CreatePlanet(planet CreatePlanetData) (*Planet, error)
UpdatePlanet(id PlanetID, data EditPlanetData) (*Planet, error)
DeletePlanet(id PlanetID) error
PlanetInitialData(id PlanetID) (*PlanetInitialData, error)
JoinPlanet(planet PlanetID, inviteCode string) error
Channels(id PlanetID) ([]Channel, error)
Me() (*User, error)
MyMember(planetID PlanetID) (*Member, error)
Member(id MemberID) (*Member, error)
MemberByUser(planetID PlanetID, id UserID) (*Member, error)
}
type CreatePlanetData ¶
type EditMessageData ¶
type EditMessageData struct {
ID MessageID `json:"id"`
PlanetID PlanetID `json:"planetId"`
Content *string `json:"content"`
Embed *Embed `json:"-"`
}
func (EditMessageData) MarshalJSON ¶
func (e EditMessageData) MarshalJSON() ([]byte, error)
MarshalJSON marshals necessary options of a message send This serializes Embed and Attachments
type EditPlanetData ¶
type Embed ¶
type Embed struct {
Id *string `json:"Id"`
Name *string `json:"Name"`
StartPage int `json:"StartPage"`
HideChangePageArrows bool `json:"HideChangePageArrows"`
Version string `json:"EmbedVersion"`
Pages []EmbedPage `json:"Pages"`
}
func NewEmbed ¶
func NewEmbed(opts ...EmbedOption) *Embed
NewEmbed is recommended instead of creating Embeds directly as it sets some defaults
type EmbedButton ¶
func (EmbedButton) MarshalJSON ¶
func (e EmbedButton) MarshalJSON() ([]byte, error)
func (EmbedButton) Type ¶
func (e EmbedButton) Type() EmbedItemType
type EmbedEventTarget ¶
type EmbedEventTarget struct {
EventElementID string `json:"e"`
}
func (EmbedEventTarget) MarshalJSON ¶
func (e EmbedEventTarget) MarshalJSON() ([]byte, error)
type EmbedFormSubmitTarget ¶
type EmbedFormSubmitTarget struct {
EventElementID string `json:"e"`
}
func (EmbedFormSubmitTarget) MarshalJSON ¶
func (e EmbedFormSubmitTarget) MarshalJSON() ([]byte, error)
type EmbedItem ¶
type EmbedItem interface {
Type() EmbedItemType
}
type EmbedItemType ¶
type EmbedItemType int
const ( EmbedTypeItem EmbedItemType = 1 + iota EmbedTypeText EmbedTypeButton EmbedTypeInputBox EmbedTypeTextArea EmbedTypeProgressBar EmbedTypeForm EmbedTypeGoTo EmbedTypeDropDownItem EmbedTypeDropDownMenu EmbedTypeEmbedRow EmbedTypeEmbedPage EmbedTypeProgress EmbedTypeMedia )
type EmbedLinkTarget ¶
type EmbedLinkTarget struct {
Href string `json:"h"`
}
func (EmbedLinkTarget) MarshalJSON ¶
func (e EmbedLinkTarget) MarshalJSON() ([]byte, error)
type EmbedOption ¶
type EmbedOption func(e *Embed)
func WithEmbedID ¶
func WithEmbedID(id string) EmbedOption
func WithEmbedName ¶
func WithEmbedName(name string) EmbedOption
func WithEmbedPages ¶
func WithEmbedPages(pages ...EmbedPage) EmbedOption
func WithEmbedStartPage ¶
func WithEmbedStartPage(page int) EmbedOption
type EmbedPage ¶
func (EmbedPage) MarshalJSON ¶
func (EmbedPage) Type ¶
func (e EmbedPage) Type() EmbedItemType
type EmbedPageTarget ¶
type EmbedPageTarget struct {
Page int `json:"p"`
}
func (EmbedPageTarget) MarshalJSON ¶
func (e EmbedPageTarget) MarshalJSON() ([]byte, error)
type EmbedRow ¶
type EmbedRow struct {
Children []EmbedItem
}
func (EmbedRow) MarshalJSON ¶
func (EmbedRow) Type ¶
func (e EmbedRow) Type() EmbedItemType
type EmbedText ¶
func (EmbedText) MarshalJSON ¶
func (EmbedText) Type ¶
func (e EmbedText) Type() EmbedItemType
type Message ¶
type Message struct {
ID MessageID `json:"id"`
PlanetID PlanetID `json:"planetId"`
ChannelID ChannelID `json:"channelId"`
ReplyToID *UserID `json:"replyToId"`
ReplyTo *Message `json:"replyTo"`
AuthorID UserID `json:"authorUserId"`
MemberID MemberID `json:"authorMemberId"`
Content string `json:"content"`
TimeSent time.Time `json:"timeSent"`
EditedTime *time.Time `json:"editedTime"`
Fingerprint string `json:"fingerprint"`
Reactions []Reaction `json:"reactions"`
Attachments []MessageAttachment `json:"attachments"`
AttachmentsData string `json:"attachmentsData"`
}
type MessageAttachment ¶
type MessageAttachmentType ¶
type MessageAttachmentType int
const ( AttachmentTypeImage MessageAttachmentType = iota AttachmentTypeVideo AttachmentTypeAudio AttachmentTypeFile // Future embedded attachments for Valour functions AttachmentTypeValourMessage AttachmentTypeValourInvite AttachmentTypeValourPlanet AttachmentTypeValourChannel AttachmentTypeValourItem AttachmentTypeValourEcoAccount AttachmentTypeValourEcoTrade AttachmentTypeValourReceipt AttachmentTypeValourBot // Generic link preview using Open Graph AttachmentTypeSitePreview // Video platforms AttachmentTypeYouTube AttachmentTypeVimeo AttachmentTypeTwitch AttachmentTypeTikTok // Social platforms AttachmentTypeTwitter AttachmentTypeReddit AttachmentTypeInstagram AttachmentTypeBluesky // Music platforms AttachmentTypeSpotify AttachmentTypeSoundCloud // Developer platforms AttachmentTypeGitHub )
type MessageCreateEvent ¶
type MessageCreateEvent struct {
Message
}
type MessageDeleteEvent ¶
type MessageDeleteEvent struct {
Message
}
type MessageEditEvent ¶
type MessageEditEvent struct {
Message
}
type MessageReactionAddedEvent ¶
type MessageReactionAddedEvent struct {
MessageReactionEvent
}
type MessageReactionEvent ¶
type MessageReactionRemovedEvent ¶
type MessageReactionRemovedEvent struct {
MessageReactionEvent
}
type Node ¶
type Node struct {
*handler.Handler
Name string
Primary *Node
// contains filtered or unexported fields
}
func (*Node) Close ¶
Close will close any open rtc connections. If this is called on the primary node, all child nodes will also be closed.
func (*Node) CreatePlanet ¶
func (n *Node) CreatePlanet(planet CreatePlanetData) (*Planet, error)
CreatePlanet will create a new planet This request always goes to the primary node
func (*Node) DeleteMessage ¶
DeleteMessage deletes a message
func (*Node) DeletePlanet ¶
DeletePlanet will delete a planet
func (*Node) EditMessage ¶
func (n *Node) EditMessage(id MessageID, m EditMessageData) (*Message, error)
EditMessage updates a message
func (*Node) GetNodeNameForPlanet ¶
GetNodeNameForPlanet retrieves the node name for the specified planet
func (*Node) JoinAllChannels ¶
JoinAllChannels will join all channels the account has access to. This will always be called on the primary node.
func (*Node) JoinPlanet ¶
JoinPlanet allows you to join a planet, with optional invite code
func (*Node) MemberByUser ¶
func (*Node) MessageReactionAdd ¶
MessageReactionAdd adds a reaction to a message
func (*Node) MessageReactionRemove ¶
MessageReactionRemove removes a reaction from a message
func (*Node) MessagesBefore ¶
func (n *Node) MessagesBefore(planetID PlanetID, channelID ChannelID, index MessageID, limit uint) ([]Message, error)
MessagesBefore retrieves messages before a specific message
func (*Node) NodeName ¶
NodeName requests the current node name from the API, guaranteeing an accurate result This shouldn't be needed, Node.Name should be plenty for everyday use.
func (*Node) Planet ¶
Planet retrieves a planet by a specified ID This request always goes to the primary node
func (*Node) PlanetInitialData ¶
func (n *Node) PlanetInitialData(id PlanetID) (*PlanetInitialData, error)
PlanetInitialData retrieves initial data for a planet, such as channels, roles, and emojis
func (*Node) Planets ¶
Planets returns the user's planets This request always goes to the primary node
func (*Node) SendMessage ¶
func (n *Node) SendMessage(planetID PlanetID, channelID ChannelID, content string) (*Message, error)
SendMessage sends a simple text message
func (*Node) SendMessageComplex ¶
func (n *Node) SendMessageComplex(planetID PlanetID, channelID ChannelID, send SendMessageData) (*Message, error)
SendMessageComplex sends a message with optional text, attachments, and embeds
func (*Node) UpdatePlanet ¶
func (n *Node) UpdatePlanet(id PlanetID, data EditPlanetData) (*Planet, error)
UpdatePlanet will update an existing planet with the specified data This request always goes to the primary node
func (*Node) UploadFile ¶
UploadFile uploads a file to Valour
func (*Node) UploadImage ¶
UploadImage uploads an image to Valour
type NodeOption ¶
type NodeOption func(*Node)
func WithNodeHandler ¶
func WithNodeHandler(h *handler.Handler) NodeOption
type Planet ¶
type Planet struct {
ID PlanetID `json:"id"`
OwnerID UserID `json:"ownerId"`
Name string `json:"name"`
NodeName string `json:"nodeName"`
HasCustomIcon bool `json:"hasCustomIcon"`
HasAnimatedIcon bool `json:"hasAnimatedIcon"`
Description string `json:"description"`
Public bool `json:"public"`
Discoverable bool `json:"discoverable"`
NSFW bool `json:"nsfw"`
Version int `json:"version"`
HasCustomBackground bool `json:"hasCustomBackground"`
Tags []Tag `json:"tags"`
}
Planet is Valour's representation of a server/group
type PlanetDeleteEvent ¶
type PlanetDeleteEvent struct {
PlanetID PlanetID
}
type PlanetInitialData ¶
type PlanetInitialData struct {
Channels []Channel `json:"channels"`
Roles []Role `json:"roles"`
Emojis []Emoji `json:"emojis"`
}
PlanetInitialData contains planet data
type PlanetJoinEvent ¶
type PlanetJoinEvent struct {
PlanetID PlanetID
}
PlanetJoinEvent is called when RTC "joins" a planet for updates
type PlanetMemberDelete ¶
type PlanetMemberDelete struct {
Member
}
type PlanetMemberUpdate ¶
type PlanetMemberUpdate struct {
Member
}
type PlanetUpdateEvent ¶
type PlanetUpdateEvent struct {
Planet
}
type RTC ¶
type RTC struct {
// contains filtered or unexported fields
}
func ConnectRTC ¶
func (*RTC) JoinChannel ¶
JoinChannel subscribes to the channel's updates/messages
func (*RTC) JoinPlanet ¶
JoinPlanet will subscribe to the planet channel to receive updates for a planet
func (*RTC) LeaveChannel ¶
LeaveChannel unsubscribes from channel updates/messages
func (*RTC) LeavePlanet ¶
LeavePlanet removes our subscription to the planet channel
type RTCAuthResponse ¶
type RTCAuthResponse struct {
BaseRTCResponse
}
type Role ¶
type Role struct {
ID RoleID `json:"id"`
PlanetID PlanetID `json:"planetId"`
Name string `json:"name"`
Position int `json:"position"`
IsDefault bool `json:"isDefault"`
Permissions int64 `json:"permissions"`
ChatPermissions int `json:"chatPermissions"`
CategoryPermissions int `json:"categoryPermissions"`
VoicePermissions int `json:"voicePermissions"`
Color string `json:"color"`
Bold bool `json:"bold"`
Italics bool `json:"italics"`
FlagBitIndex int `json:"flagBitIndex"`
AnyoneCanMention bool `json:"anyoneCanMention"`
IsAdmin bool `json:"isAdmin"`
}
type SendMessageData ¶
type SendMessageData struct {
AuthorMemberID MemberID `json:"authorMemberId"`
PlanetID PlanetID `json:"planetId"`
ChannelID ChannelID `json:"channelId"`
ReplyToID *MessageID `json:"replyToId"`
Content string `json:"content"`
Attachments []*MessageAttachment `json:"attachments,omitempty"`
Embed *Embed `json:"-"`
Fingerprint string `json:"fingerprint"`
}
func (SendMessageData) MarshalJSON ¶
func (s SendMessageData) MarshalJSON() ([]byte, error)
MarshalJSON marshals necessary options of a message send This serializes Embed and Attachments
type TargetType ¶
type TargetType int
type Time ¶
func (*Time) UnmarshalJSON ¶
type User ¶
type User struct {
HasCustomAvatar bool `json:"hasCustomAvatar"`
HasAnimatedAvatar bool `json:"hasAnimatedAvatar"`
TimeJoined time.Time `json:"timeJoined"`
Name string `json:"name"`
Tag string `json:"tag"`
Bot bool `json:"bot"`
Disabled bool `json:"disabled"`
ValourStaff bool `json:"valourStaff"`
Status *string `json:"status"`
UserStateCode int `json:"userStateCode"`
TimeLastActive time.Time `json:"timeLastActive"`
IsMobile bool `json:"isMobile"`
Compliance bool `json:"compliance"`
SubscriptionType string `json:"subscriptionType"`
PriorName string `json:"priorName"`
NameChangeTime time.Time `json:"nameChangeTime"`
Version int `json:"version"`
TutorialState int `json:"tutorialState"`
OwnerId interface{} `json:"ownerId"`
NameAndTag string `json:"nameAndTag"`
ID UserID `json:"id"`
}
type UserUpdateEvent ¶
type UserUpdateEvent struct {
User
}