regolt

package module
v0.0.0-...-c171d4e Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

README

regolt

A Highly performant, low level libray for Revolt written in Go

Documentation

Index

Constants

View Source
const BASE_URL = "http://api.revolt.chat"
View Source
const VERSION = "v0.1.0"
View Source
const WS_URL = "wss://ws.revolt.chat"

Variables

View Source
var (
	ErrLabelMe               = "LabelMe"               // uncategorised error
	ErrInternalError         = "InternalError"         // the server ran into an issue
	ErrInvalidSession        = "InvalidSession"        // authentication details are incorrect
	ErrOnboardingNotFinished = "OnboardingNotFinished" // user has not chosen a username
	ErrAlreadyAuthenticated  = "AlreadyAuthenticated"  // this connection is already authenticated
)
View Source
var (
	TypeAuthenticated      = "Authenticated"
	TypePong               = "Pong"
	TypeReady              = "Ready"
	TypeMessageCreate      = "Message"
	TypeMessageUpdate      = "MessageUpdate"
	TypeMessageDelete      = "MessageDelete"
	TypeChannelCreate      = "ChannelCreate"
	TypeChannelUpdate      = "ChannelUpdate"
	TypeChannelDelete      = "ChannelDelete"
	TypeChannelGroupJoin   = "ChannelGroupJoin"
	TypeChannelGroupLeave  = "ChannelGroupLeave"
	TypeChannelStartTyping = "ChannelStartTyping"
	TypeChannelStopTyping  = "ChannelStopTyping"
	TypeChannelAck         = "ChannelAck"
	TypeServerUpdate       = "ServerUpdate"
	TypeServerDelete       = "ServerDelete"
	TypeServerMemberUpdate = "ServerMemberUpdate"
	TypeServerMemberJoin   = "ServerMemberJoin"
	TypeServerMemberLeave  = "ServerMemberLeave"
	TypeServerRoleUpdate   = "ServerRoleUpdate"
	TypeServerRoleDelete   = "ServerRoleDelete"
	TypeUserUpdate         = "UserUpdate"
	TypeUserRelationship   = "UserRelationship"
)
View Source
var ErrNoToken = fmt.Errorf("no token found")

Functions

This section is empty.

Types

type Ban

type Ban struct {
	ID struct {
		Server string `json:"server"`
		User   string `json:"user"`
	} `json:"_id"`

	Reason string `json:"reason"`
}

type Categories

type Categories struct {
	ID       string   `json:"id"`
	Title    string   `json:"title"`
	Channels []string `json:"channels"`
}

type Channel

type Channel struct {
	ID          string `json:"_id"`
	Server      string `json:"server"`
	Name        string `json:"name"`
	Description string `json:"description"`

	Icon struct {
		ID       string `json:"_id"`
		Tag      string `json:"tag"`
		Size     int    `json:"size"`
		Filename string `json:"filename"`

		Metadata struct {
			Type string `json:"type"`
		} `json:"metadata"`

		ContentType string `json:"content_type"`
	} `json:"icon"`

	DefaultPermissions int `json:"default_permissions"`

	RolePermissions map[string]int `json:"role_permissions"`

	Nsfw        bool   `json:"nsfw"`
	ChannelType string `json:"channel_type"`
}

Channel

type ChannelAck

type ChannelAck struct {
	Type      string `json:"type"`
	Id        string `json:"id"`
	User      string `json:"user"`
	MessageId string `json:"message_id"`
}

type ChannelCreate

type ChannelCreate struct {
	Type    string  `json:"type"`
	Channel Channel `json:"channel"`
}

type ChannelDelete

type ChannelDelete struct {
	Type string `json:"type"`
	Id   string `json:"id"`
}

type ChannelGroupJoin

type ChannelGroupJoin struct {
	Type string `json:"type"`
	Id   string `json:"id"`
	User string `json:"user"`
}

type ChannelGroupLeave

type ChannelGroupLeave struct {
	Type string `json:"type"`
	Id   string `json:"id"`
	User string `json:"user"`
}

type ChannelStartTyping

type ChannelStartTyping struct {
	Type string `json:"type"`
	Id   string `json:"id"`
	User string `json:"user"`
}

type ChannelStopTyping

type ChannelStopTyping struct {
	Type string `json:"type"`
	Id   string `json:"id"`
	User string `json:"user"`
}

type ChannelType

type ChannelType string
const ChannelTypeText ChannelType = "Text"
const ChannelTypeVoice ChannelType = "Voice"

func (ChannelType) IsText

func (c ChannelType) IsText() bool

func (ChannelType) IsVoice

func (c ChannelType) IsVoice() bool

type ChannelUpdate

type ChannelUpdate struct {
	Type    string    `json:"type"`
	Id      string    `json:"id"`
	Channel Channel   `json:"data"`
	Clear   ClearType `json:"clear,omitempty"`
}

type ClearType

type ClearType string
const ClearTypeBanner ClearType = "Banner"
const ClearTypeColour ClearType = "Colour"
const ClearTypeDescription ClearType = "Description"
const ClearTypeIcon ClearType = "Icon"

func (ClearType) IsBanner

func (c ClearType) IsBanner() bool

func (ClearType) IsColour

func (c ClearType) IsColour() bool

func (ClearType) IsDescription

func (c ClearType) IsDescription() bool

func (ClearType) IsIcon

func (c ClearType) IsIcon() bool

type DirectMessage

type DirectMessage []struct {
	ID            string   `json:"_id"`
	ChannelType   string   `json:"channel_type"`
	Active        bool     `json:"active"`
	Recipients    []string `json:"recipients"`
	LastMessageID string   `json:"last_message_id"`
}

DM

type EditChannel

type EditChannel struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Icon        string `json:"icon,omitempty"`
	Nsfw        bool   `json:"nsfw,omitempty"`
	Remove      string `json:"remove,omitempty"`
}

type EditMember

type EditMember struct {
	Nickname string   `json:"nickname,omitempty"`
	Avatar   string   `json:"avatar,omitempty"`
	Roles    []string `json:"roles,omitempty"`
	Remove   string   `json:"remove,omitempty"`
}

type EditServer

type EditServer struct {
	Name           string          `json:"name,omitempty"`
	Description    string          `json:"description,omitempty"`
	Icon           string          `json:"icon,omitempty"`
	Banner         string          `json:"banner,omitempty"`
	Categories     []*Categories   `json:"categories,omitempty"`
	SystemMessages *SystemMessages `json:"system_messages,omitempty"`
	Nsfw           bool            `json:"nsfw,omitempty"`
	Remove         string          `json:"remove,omitempty"`
}

type EditUser

type EditUser struct {
	Status struct {
		Text     string `json:"text,omitempty"`
		Presence string `json:"presence,omitempty"`
	} `json:"status,omitempty"`

	Profile struct {
		Content    string `json:"content,omitempty"`
		Background string `json:"background,omitempty"`
	} `json:"profile,omitempty"`

	Avatar string `json:"avatar,omitempty"`
	Remove string `json:"remove,omitempty"`
}

type Embed

type Embed struct {
	Type string `json:"type"`
	URL  string `json:"url"`

	Special struct {
		Type string `json:"type"`
	} `json:"special"`

	Title       string `json:"title"`
	Description string `json:"description"`

	Image struct {
		URL    string `json:"url"`
		Width  int    `json:"width"`
		Height int    `json:"height"`
		Size   string `json:"size"`
	} `json:"image"`

	Video struct {
		URL    string `json:"url"`
		Width  int    `json:"width"`
		Height int    `json:"height"`
	} `json:"video"`

	SiteName string `json:"site_name"`
	IconURL  string `json:"icon_url"`
	Colour   string `json:"colour"`
}

type Event

type Event struct {
	Type string `json:"type"`
}

type Group

type Group struct {
	ID            string   `json:"_id"`
	ChannelType   string   `json:"channel_type"`
	Recipients    []string `json:"recipients"`
	Name          string   `json:"name"`
	Owner         string   `json:"owner"`
	Description   string   `json:"description"`
	LastMessageID string   `json:"last_message_id"`

	Icon struct {
		ID       string `json:"_id"`
		Tag      string `json:"tag"`
		Size     int    `json:"size"`
		Filename string `json:"filename"`

		Metadata struct {
			Type string `json:"type"`
		} `json:"metadata"`

		ContentType string `json:"content_type"`
	} `json:"icon"`

	Permissions int  `json:"permissions"`
	Nsfw        bool `json:"nsfw"`
}

Group

type Member

type Member struct {
	ID struct {
		Server string `json:"server"`
		User   string `json:"user"`
	} `json:"_id"`

	Nickname string `json:"nickname"`

	Avatar struct {
		ID       string `json:"_id"`
		Tag      string `json:"tag"`
		Size     int    `json:"size"`
		Filename string `json:"filename"`

		Metadata struct {
			Type string `json:"type"`
		} `json:"metadata"`

		ContentType string `json:"content_type"`
	} `json:"avatar"`

	Roles []string `json:"roles"`
}

type Message

type Message struct {
	ID      string `json:"_id"`
	Nonce   string `json:"nonce"`
	Channel string `json:"channel"`
	Author  string `json:"author"`

	Content interface{} `json:"content"`

	Attachments []struct {
		ID       string `json:"_id"`
		Tag      string `json:"tag"`
		Size     int    `json:"size"`
		Filename string `json:"filename"`

		Metadata struct {
			Type string `json:"type"`
		} `json:"metadata"`

		ContentType string `json:"content_type"`
	} `json:"attachments"`

	Edited struct {
		Date string `json:"$date"`
	} `json:"edited"`

	Embeds []*Embed `json:"embeds"`

	Mentions []string `json:"mentions"`
	Replies  []string `json:"replies"`

	Masquerade struct {
		Name   string `json:"name"`
		Avatar string `json:"avatar"`
	} `json:"masquerade"`
}

type MessageCreate

type MessageCreate struct {
	Type    string `json:"type"`
	Message Message
}

type MessageDelete

type MessageDelete struct {
	Type    string `json:"type"`
	Id      string `json:"id"`
	Channel string `json:"channel"`
}

type MessageSend

type MessageSend struct {
	Content     string   `json:"content"`
	Attachments []string `json:"attachments,omitempty"`

	Embeds []*struct {
		Type        string `json:"type"`
		IconURL     string `json:"icon_url"`
		URL         string `json:"url"`
		Title       string `json:"title"`
		Description string `json:"description"`
		Media       string `json:"media"`
		Colour      string `json:"colour"`
	} `json:"embeds,omitempty"`

	Replies []*struct {
		ID      string `json:"id"`
		Mention bool   `json:"mention"`
	} `json:"replies,omitempty"`

	Masquerade *struct {
		Name   string `json:"name"`
		Avatar string `json:"avatar"`
	} `json:"masquerade,omitempty"`
}

type MessageUpdate

type MessageUpdate struct {
	Type    string  `json:"type"`
	Id      string  `json:"id"`
	Message Message `json:"data"`
}

type MutualFriendsAndServers

type MutualFriendsAndServers struct {
	Users   []string `json:"users"`
	Servers []string `json:"servers"`
}

type Pong

type Pong struct {
	Type string `json:"type"`
	Data int    `json:"data"`
}

type Ready

type Ready struct {
	Type     string     `json:"type"`
	Users    []*User    `json:"users"`
	Servers  []*Server  `json:"servers"`
	Channels []*Channel `json:"channels"`
}

type RelationshipStatus

type RelationshipStatus string
const RelationshipBlocked RelationshipStatus = "Blocked"
const RelationshipBlockedOther RelationshipStatus = "BlockedOther"
const RelationshipFriend RelationshipStatus = "Friend"
const RelationshipIncoming RelationshipStatus = "Incoming"
const RelationshipNone RelationshipStatus = "None"
const RelationshipOutgoing RelationshipStatus = "Outgoing"
const RelationshipUser RelationshipStatus = "User"

func (RelationshipStatus) IsBlocked

func (r RelationshipStatus) IsBlocked() bool

func (RelationshipStatus) IsBlockedOther

func (r RelationshipStatus) IsBlockedOther() bool

func (RelationshipStatus) IsFriend

func (r RelationshipStatus) IsFriend() bool

func (RelationshipStatus) IsIncoming

func (r RelationshipStatus) IsIncoming() bool

func (RelationshipStatus) IsNone

func (r RelationshipStatus) IsNone() bool

func (RelationshipStatus) IsOutgoing

func (r RelationshipStatus) IsOutgoing() bool

func (RelationshipStatus) IsUser

func (r RelationshipStatus) IsUser() bool

type RestContent

type RestContent struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

type Role

type Role struct {
	Name        string `json:"name"`
	Permissions []int  `json:"permissions"`
	Colour      string `json:"colour"`
	Hoist       bool   `json:"hoist"`
	Rank        int    `json:"rank"`
	Remove      string `json:"remove,omitempty"`
}

type RoleClearType

type RoleClearType string
const RoleClearTypeColour RoleClearType = "Colour"

func (RoleClearType) IsColour

func (r RoleClearType) IsColour() bool

type RoleCreated

type RoleCreated struct {
	Id          string `json:"id"`
	Permissions []int  `json:"permissions"`
}

type Server

type Server struct {
	ID          string   `json:"_id"`
	Owner       string   `json:"owner"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Channels    []string `json:"channels"`

	Categories []*Categories `json:"categories"`

	SystemMessages *SystemMessages `json:"system_messages"`

	Roles []Role `json:"roles"`

	DefaultPermissions []int `json:"default_permissions"`

	Icon struct {
		ID       string `json:"_id"`
		Tag      string `json:"tag"`
		Size     int    `json:"size"`
		Filename string `json:"filename"`

		Metadata struct {
			Type string `json:"type"`
		} `json:"metadata"`

		ContentType string `json:"content_type"`
	} `json:"icon"`

	Banner struct {
		ID       string `json:"_id"`
		Tag      string `json:"tag"`
		Size     int    `json:"size"`
		Filename string `json:"filename"`

		Metadata struct {
			Type string `json:"type"`
		} `json:"metadata"`

		ContentType string `json:"content_type"`
	} `json:"banner"`

	Nsfw         bool `json:"nsfw"`
	Flags        int  `json:"flags"`
	Analytics    bool `json:"analytics"`
	Discoverable bool `json:"discoverable"`
}

Server

type ServerDelete

type ServerDelete struct {
	Type string `json:"type"`
	Id   string `json:"id"`
}

type ServerMemberJoin

type ServerMemberJoin struct {
	Type string `json:"type"`
	Id   string `json:"id"`
	User string `json:"user"`
}

type ServerMemberLeave

type ServerMemberLeave struct {
	Type string `json:"type"`
	Id   string `json:"id"`
	User string `json:"user"`
}

type ServerMemberUpdate

type ServerMemberUpdate struct {
	Type string `json:"type"`
	Ids  struct {
		Server string `json:"server"`
		User   string `json:"user"`
	} `json:"id"`

	Member Member    `json:"data"`
	Clear  ClearType `json:"clear,omitempty"`
}

type ServerRoleDelete

type ServerRoleDelete struct {
	Type   string `json:"type"`
	Id     string `json:"id"`
	RoleId string `json:"role_id"`
}

type ServerRoleUpdate

type ServerRoleUpdate struct {
	Type   string    `json:"type"`
	Id     string    `json:"id"`
	RoleId string    `json:"role_id"`
	Role   Role      `json:"data"`
	Clear  ClearType `json:"clear,omitempty"`
}

type ServerUpdate

type ServerUpdate struct {
	Type   string    `json:"type"`
	Id     string    `json:"id"`
	Server Server    `json:"data"`
	Clear  ClearType `json:"clear,omitempty"`
}

type Session

type Session struct {
	sync.RWMutex

	Token string
	// contains filtered or unexported fields
}

func CreateBot

func CreateBot(token string) *Session

func (*Session) AddGroupMember

func (s *Session) AddGroupMember(channelId, userId string) (err error)

Unimplemented (Session Token) + documentation error

func (*Session) AddHandler

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

func (*Session) BanMember

func (s *Session) BanMember(serverId, memberId, reason string) (err error)

Bans

func (*Session) ChangeUsername

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

Unimplemented

func (*Session) ChannelMessageSend

func (s *Session) ChannelMessageSend(channelId string, msg *MessageSend) (resp []byte, err error)

Messages

func (*Session) ChannelMessageSendString

func (s *Session) ChannelMessageSendString(channelId string, msg string) (resp []byte, err error)

func (*Session) CloseChannel

func (s *Session) CloseChannel(channelId string, edit *EditChannel) (err error)

func (*Session) CreateGroup

func (s *Session) CreateGroup(name, description string, users []string, nsfw bool) (group *Group, err error)

Unimplemented (Session Token)

func (*Session) CreateInvite

func (s *Session) CreateInvite(channelId string) (invite string, err error)

Create invite from channel ID

func (*Session) CreateRole

func (s *Session) CreateRole(serverId, name string) (role *RoleCreated, err error)

func (*Session) CreateServer

func (s *Session) CreateServer(name, description string, nsfw bool) (server *Server, err error)

Unimplemented (Session Token)

func (*Session) CreateServerChannel

func (s *Session) CreateServerChannel(serverId, name, description string, channelType ChannelType, nsfw bool) (err error)

func (*Session) DeleteInvite

func (s *Session) DeleteInvite(invite string) (err error)

func (*Session) DeleteMessage

func (s *Session) DeleteMessage(channelId, messageId string) (err error)

func (*Session) DeleteRole

func (s *Session) DeleteRole(serverId, roleId string) (err error)

func (*Session) DeleteServer

func (s *Session) DeleteServer(serverId string) (err error)

func (*Session) EditChannel

func (s *Session) EditChannel(channelId string, edit *EditChannel) (channel *Channel, err error)

func (*Session) EditMember

func (s *Session) EditMember(serverId, memberId string, edit *EditMember) (err error)

func (*Session) EditMessage

func (s *Session) EditMessage(channelId, messageId, content string, embeds []*Embed) (err error)

func (*Session) EditRole

func (s *Session) EditRole(serverId, roleId, name, colour string, hoist bool, rank int, remove RoleClearType) (err error)

func (*Session) EditServer

func (s *Session) EditServer(serverId string, edit *EditServer) (err error)

func (*Session) EditUser

func (s *Session) EditUser(edit *EditUser) (err error)

func (*Session) FetchBans

func (s *Session) FetchBans(serverId string) (users []*User, bans []*Ban, err error)

func (*Session) FetchChannel

func (s *Session) FetchChannel(channelId string) (channel *Channel, err error)

func (*Session) FetchDMs

func (s *Session) FetchDMs() (dms []*DirectMessage, err error)

func (*Session) FetchDefaultAvatar

func (s *Session) FetchDefaultAvatar(id string) (img []byte, err error)

func (*Session) FetchGroupMembers

func (s *Session) FetchGroupMembers(channelId, messageId string) (members []*Member, err error)

func (*Session) FetchInvite

func (s *Session) FetchInvite(invite string) (server *Server, err error)

func (*Session) FetchInvites

func (s *Session) FetchInvites(serverId string) (invites []string, err error)

func (*Session) FetchMember

func (s *Session) FetchMember(serverId, memberId string) (member *Member, err error)

Server Members

func (*Session) FetchMembers

func (s *Session) FetchMembers(serverId, memberId string) (members []*Member, users []*User, err error)

func (*Session) FetchMessage

func (s *Session) FetchMessage(channelId, messageId string) (message *Message, err error)

func (*Session) FetchMessages

func (s *Session) FetchMessages(channelId string, limit int, before string, after string, sort string, nearby string, includeUsers bool) (
	messages []*Message, users []*User, members []*Member, err error)

func (*Session) FetchMutualFriendsAndServers

func (s *Session) FetchMutualFriendsAndServers(id string) (mutuals *MutualFriendsAndServers, err error)

func (*Session) FetchMutuals

func (s *Session) FetchMutuals(id string) (mutuals *MutualFriendsAndServers, err error)

Alias for FetchMutualFriendsAndServers

func (*Session) FetchSelf

func (s *Session) FetchSelf() (user *User, err error)

func (*Session) FetchServer

func (s *Session) FetchServer(serverId string) (server *Server, err error)

func (*Session) FetchUser

func (s *Session) FetchUser(id string) (user *User, err error)

func (*Session) FetchUserProfile

func (s *Session) FetchUserProfile(id string) (profile *UserProfile, err error)

func (*Session) JoinInvite

func (s *Session) JoinInvite(invite string) (server *Server, err error)

Unimplemented (Session Token)

func (*Session) JoinVoiceChannel

func (s *Session) JoinVoiceChannel(channelId string) (token string, err error)

func (*Session) KickMember

func (s *Session) KickMember(serverId, memberId string) (err error)

func (*Session) MarkServerAsRead

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

Unimplemented (Session Token)

func (*Session) MessageAck

func (s *Session) MessageAck(channelId, messageId string) (err error)

Unimplemented (Session Token)

func (*Session) Open

func (s *Session) Open() error

func (*Session) OpenDM

func (s *Session) OpenDM(id string) (dm *DirectMessage, err error)

func (*Session) PollMessageChanges

func (s *Session) PollMessageChanges(channelId string, messageIds []string) (changed []*Message, deleted []string, err error)

func (*Session) RemoveGroupMember

func (s *Session) RemoveGroupMember(channelId, userId string) (err error)

Unimplemented (Session Token) + documentation error

func (*Session) SearchMessages

func (s *Session) SearchMessages(channelId string, query string, limit int, before string, after string, sort string, nearby string, includeUsers *bool) (
	messages []*Message, users []*User, members []*Member, err error)

func (*Session) SetDefaultPermission

func (s *Session) SetDefaultPermission(id string, permissions int) (err error)

func (*Session) SetRolePermission

func (s *Session) SetRolePermission(channelId string, roleId string, permissions int) (err error)

func (*Session) UnbanMember

func (s *Session) UnbanMember(serverId, memberId, reason string) (err error)

type SystemMessages

type SystemMessages struct {
	UserJoined string `json:"user_joined"`
	UserLeft   string `json:"user_left"`
	UserKicked string `json:"user_kicked"`
	UserBanned string `json:"user_banned"`
}

type User

type User struct {
	ID       string `json:"_id"`
	Username string `json:"username"`

	Avatar struct {
		ID       string `json:"_id"`
		Tag      string `json:"tag"`
		Size     int    `json:"size"`
		Filename string `json:"filename"`

		Metadata struct {
			Type string `json:"type"`
		} `json:"metadata"`

		ContentType string `json:"content_type"`
	} `json:"avatar"`

	Relations []struct {
		Status string `json:"status"`
		ID     string `json:"_id"`
	} `json:"relations"`

	Badges int `json:"badges"`

	Status struct {
		Text     string `json:"text"`
		Presence string `json:"presence"`
	} `json:"status"`

	Relationship string `json:"relationship"`
	Online       bool   `json:"online"`
	Flags        int    `json:"flags"`

	Bot struct {
		Owner string `json:"owner"`
	} `json:"bot,omitempty"`
}

User

type UserProfile

type UserProfile struct {
	Content string `json:"content"`

	Background struct {
		ID       string `json:"_id"`
		Tag      string `json:"tag"`
		Size     int    `json:"size"`
		Filename string `json:"filename"`

		Metadata struct {
			Type string `json:"type"`
		} `json:"metadata"`

		ContentType string `json:"content_type"`
	} `json:"background"`
}

type UserRelationship

type UserRelationship struct {
	Type   string             `json:"type"`
	Id     string             `json:"id"`
	User   string             `json:"user"`
	Status RelationshipStatus `json:"status"`
}

type UserUpdate

type UserUpdate struct {
	Type string `json:"type"`
	Id   string `json:"id"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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