revolt

package
v0.0.0-...-fa60fbe Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: ISC Imports: 1 Imported by: 0

Documentation

Overview

Package revolt contains types shared by the other packages.

Index

Constants

This section is empty.

Variables

View Source
var APIBaseURL = "https://api.revolt.chat"

APIBaseURL is the base URL of the API. Exported as a variable so clients can set a different URL for self-hosting.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	ID  string        `json:"_id"`
	Tag AttachmentTag `json:"tag"`

	Size        uint64             `json:"size"` // Size in bytes
	Filename    string             `json:"filename"`
	Metadata    AttachmentMetadata `json:"metadata"`
	ContentType string             `json:"content_type"`
}

Attachment is a message attachment.

type AttachmentMetadata

type AttachmentMetadata struct {
	Type   string `json:"type"`
	Width  int    `json:"width,omitempty"`
	Height int    `json:"height,omitempty"`
}

AttachmentMetadata ...

type AttachmentTag

type AttachmentTag string

AttachmentTag is used in the Attachment struct.

const (
	TagAttachments AttachmentTag = "attachments"
	TagAvatars     AttachmentTag = "avatars"
	TagBackgrounds AttachmentTag = "backgrounds"
	TagBanners     AttachmentTag = "banners"
	TagIcons       AttachmentTag = "icons"
)

Attachment tag constants. Not sure what these do?

type Badges

type Badges uint16

Badges ...

const (
	BadgeDeveloper             Badges = 1 << 0
	BadgeTranslator            Badges = 1 << 1
	BadgeSupporter             Badges = 1 << 2
	BadgeResponsibleDisclosure Badges = 1 << 3
	BadgeRevoltTeam            Badges = 1 << 4

	BadgeEarlyAdopter Badges = 1 << 8
)

Badges constants

type BotInformation

type BotInformation struct {
	OwnerID string `json:"owner"`
}

BotInformation ...

type Channel

type Channel struct {
	ID       string      `json:"_id"`
	ServerID string      `json:"server,omitempty"`
	Type     string      `json:"channel_type"`
	Name     string      `json:"name"`
	Icon     *Attachment `json:"icon"`
	NSFW     bool        `json:"nsfw"`

	Description string `json:"description,omitempty"`

	LastMessageID string `json:"last_message_id"`

	// Only in groups
	Permissions uint64 `json:"permissions"`
	// Only in servers
	DefaultPermissions uint64            `json:"default_permissions"`
	RolePermissions    map[string]uint64 `json:"role_permissions"`

	// If a DM, whether it's active
	DMActive bool `json:"active"`
	// If a group, the owner's ID
	GroupOwnerID string   `json:"owner"`
	Recipients   []string `json:"recipients"`
}

Channel ...

type Message

type Message struct {
	ID        string `json:"_id"`
	Nonce     string `json:"nonce,omitempty"`
	ChannelID string `json:"channel"`
	AuthorID  string `json:"author"`

	// Not a string because the API can return one of 10(!) objects *or* a string! Beautiful.
	// To get message content, assuming it's a string, use the m.String() method;
	// To get a MessageContent object, use m.Object().
	Content jsonutil.Raw `json:"content"`

	Attachments []Attachment `json:"attachments,omitempty"`
}

Message is a Revolt message.

func (Message) Object

func (m Message) Object() (c MessageContent, err error)

Object unmarshals m.Content to a MessageContent.

func (Message) String

func (m Message) String() string

String unmarshals m.Content to a string. Any errors are ignored.

type MessageContent

type MessageContent struct {
	Type string

	Content string `json:"content,omitempty"`
	Name    string `json:"name,omitempty"`
	// User ID
	ID string `json:"id,omitempty"`
	// User ID?
	By string `json:"by,omitempty"`
}

MessageContent is used for the Message.Content field, but only sometimes.

type Relation

type Relation struct {
	User   string `json:"_id"`
	Status string `json:"status"`
}

Relation ...

type Role

type Role struct {
	Name        string    `json:"name"`
	Colour      string    `json:"colour"`
	Permissions [2]uint64 `json:"permissions"`
	Hoist       bool      `json:"hoist"`
	Rank        uint      `json:"rank"`
}

Role ...

type Server

type Server struct {
	ID      string `json:"_id"`
	OwnerID string `json:"owner"`

	Name        string `json:"name"`
	Description string `json:"description,omitempty"`

	Icon   *Attachment `json:"icon,omitempty"`
	Banner *Attachment `json:"banner,omitempty"`

	Channels   []string         `json:"channels"`
	Categories []ServerCategory `json:"categories"`

	DefaultPermissions [2]uint64 `json:"default_permissions"`
}

Server ...

type ServerCategory

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

ServerCategory ...

type ServerSystemMessages

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

ServerSystemMessages ...

type Status

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

Status ...

type User

type User struct {
	ID       string          `json:"_id"`
	Username string          `json:"username"`
	Avatar   *Attachment     `json:"avatar"`
	Bot      *BotInformation `json:"bot,omitempty"`
	Badges   Badges          `json:"badges"`
	Flags    UserFlags       `json:"flags"`

	Relations    []Relation `json:"relations"`
	Relationship string     `json:"relationship"`

	Status *Status `json:"status"`
	Online bool    `json:"online"`
}

User is a user.

func (User) Mention

func (u User) Mention() string

Mention returns a formatted mention.

type UserFlags

type UserFlags uint16

UserFlags ...

const (
	FlagSuspended UserFlags = 1 << 0
	FlagDeleted   UserFlags = 1 << 1
	FlagBanned    UserFlags = 1 << 2
)

UserFlags constants

Jump to

Keyboard shortcuts

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