revolt

package
v0.0.0-...-b3a6475 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const AutumnHTTPBase = "https://autumn.revolt.chat"
View Source
const RevoltHTTPBase = "https://api.revolt.chat"
View Source
const RevoltWS = "wss://ws.revolt.chat?format=json"

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticate

type Authenticate struct {
	SentBase

	UserID       *string `json:"user_id,omitempty"`
	SessionToken *string `json:"session_token,omitempty"`

	Token *string `json:"token,omitempty"`
}

type Authenticated

type Authenticated struct {
	SentBase
}

type BeginTyping

type BeginTyping struct {
	SentBase

	Channel string `json:"channel"`
}

type Channel

type Channel struct {
	ID          string `json:"_id"`
	ChannelType string `json:"channel_type"`
	Server      string `json:"server"`
	Nonce       string `json:"nonce"`
	Name        string `json:"name"`
}

type ChannelAck

type ChannelAck struct {
	SentBase

	ChannelID string `json:"id"`
	UserID    string `json:"user"`
	MessageID string `json:"message_id"`
}

type ChannelCreate

type ChannelCreate struct {
	SentBase

	*Channel
}

type ChannelDelete

type ChannelDelete struct {
	SentBase

	ID string `json:"id"`
}

type ChannelGroupJoin

type ChannelGroupJoin struct {
	SentBase

	ChannelID string `json:"id"`
	UserID    string `json:"user"`
}

type ChannelGroupLeave

type ChannelGroupLeave struct {
	SentBase

	ChannelID string `json:"id"`
	UserID    string `json:"user"`
}

type ChannelStartTyping

type ChannelStartTyping struct {
	SentBase

	ChannelID string `json:"id"`
	UserID    string `json:"user"`
}

type ChannelStopTyping

type ChannelStopTyping struct {
	SentBase

	ChannelID string `json:"id"`
	UserID    string `json:"user"`
}

type ChannelUpdate

type ChannelUpdate struct {
	SentBase
	ID      string   `json:"id"`
	Channel *Channel `json:"data"`
	Clear   string   `json:"clear"`
}

type EndTyping

type EndTyping struct {
	SentBase

	Channel string `json:"channel"`
}

type Error

type Error struct {
	SentBase

	Error string `json:"error"`
}

type File

type File struct {
	ID          string    `json:"_id"`
	Tag         string    `json:"tag"`
	Size        int       `json:"size"`
	Filename    string    `json:"filename"`
	Metadata    *Metadata `json:"metadata"`
	ContentType string    `json:"content_type"`
}

type Guild

type Guild struct {
	ID                 string `json:"_id"`
	Nonce              string `json:"nonce"`
	Owner              string `json:"owner"`
	Name               string `json:"name"`
	Description        string
	Channels           []string             `json:"channels"`
	Categories         []*GuildCategory     `json:"categories"`
	Roles              []*GuildRole         `json:"roles"`
	SystemMessages     *GuildSystemMessages `json:"system_messages"`
	DefaultPermissions []int                `json:"default_permissions"`

	Icon   *File `json:"icon"`
	Banner *File `json:"banner"`
}

type GuildCategory

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

type GuildMember

type GuildMember struct {
	ID *GuildMemberIDs `json:"_id"`
}

type GuildMemberIDs

type GuildMemberIDs struct {
	Server string `json:"server"`
	User   string `json:"user"`
}

type GuildRole

type GuildRole struct {
	Name        string `json:"name"`
	Permissions []int  `json:"permissions"`
	Colour      string `json:"colour"`
	Hoist       bool   `json:"hoist"`
	Rank        int    `json:"rank"`
}

type GuildSystemMessages

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

type ImageCreateArguments

type ImageCreateArguments struct {
	// cache = force_cache or filesize >= filesize_limit
	ForceCache    bool      `json:"force_cache"`
	FilesizeLimit int       `json:"filesize_limit"`
	Options       ImageOpts `json:"options"`
}

type ImageOpts

type ImageOpts struct {
	// Newline split message
	Text string `json:"text"`

	GuildId int64 `json:"guild_id"`

	ImageURL string `json:"image_url"`

	UserId int64  `json:"user_id"`
	Avatar string `json:"avatar"`

	AllowGIF bool `json:"allow_gif"`

	// Which theme to use when generating images
	Theme Theme `json:"layout"`

	// Identifier for background
	Background string `json:"background"`

	// Identifier for font to use (along with Noto)
	Font string `json:"font"`

	// Border applied to entire image. If transparent, there is no border.
	BorderColour    color.RGBA `json:"-"`
	BorderColourHex string     `json:"border_colour"`
	BorderWidth     int        `json:"border_width"`

	// Alignment of left or right (assuming not vertical layout)
	ProfileAlignment ProfileAlignment `json:"profile_alignment"`

	// Text alignment (left, center, right) (top, middle, bottom)
	TextAlignmentX Xalignment `json:"text_alignment_x"`
	TextAlignmentY Yalignment `json:"text_alignment_y"`

	// Include a border around profile pictures. This also fills
	// under the profile.
	ProfileBorderColour    color.RGBA `json:"-"`
	ProfileBorderColourHex string     `json:"profile_border_colour"`
	// Padding applied to profile pictures inside profile border
	ProfileBorderWidth int `json:"profile_border_width"`
	// Type of curving on the profile border (circle, rounded, square)
	ProfileBorderCurve ProfileBorderCurve `json:"profile_border_curve"`

	// Text stroke. If 0, there is no stroke
	TextStroke          int        `json:"text_stroke"`
	TextStrokeColour    color.RGBA `json:"-"`
	TextStrokeColourHex string     `json:"text_stroke_colour"`

	TextColour    color.RGBA `json:"-"`
	TextColourHex string     `json:"text_colour"`
}

type Message

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

	Content  string `json:"-"`
	TargetID string `json:"-"`
	By       string `json:"-"`
	Name     string `json:"-"`

	ContentType string `json:"-"`

	RawContent interface{} `json:"content"`

	Attachments []*File  `json:"attachments"`
	Edited      int      `json:"edited"`
	Mentions    []string `json:"mentions"`
	Replies     []string `json:"replies"`
}

type MessageContent

type MessageContent struct {
	Type string `json:"type"`

	// text
	Content *string `json:"content,omitempty"`

	// system messages
	ID *string `json:"id,omitempty"`

	// system messages/channel_description_changed/channel_icon_changed
	By *string `json:"by,omitempty"`

	// channel_renamed
	Name *string `json:"name,omitempty"`
}

type MessageCreate

type MessageCreate struct {
	SentBase

	*Message
}

type MessageDelete

type MessageDelete struct {
	SentBase

	MessageID string `json:"id"`
	ChannelID string `json:"channel"`
}

type MessageRequest

type MessageRequest struct {
	Content     string   `json:"content"`
	Nonce       string   `json:"nonce"`
	Attachments []string `json:"attachments"`
	Replies     []*Reply `json:"replies"`
}

type MessageUpdate

type MessageUpdate struct {
	SentBase

	ID      string   `json:"id"`
	Message *Message `json:"data"`
}

type Metadata

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

type Ping

type Ping struct {
	SentBase

	Time int `json:"time"`
}

type Pong

type Pong struct {
	SentBase

	Time int `json:"time"`
}

type ProfileAlignment

type ProfileAlignment uint8
const (
	FloatLeft ProfileAlignment = iota
	FloatRight
)

type ProfileBorderCurve

type ProfileBorderCurve uint8
const (
	CurveCircle ProfileBorderCurve = iota
	CurveSoft
	CurveSquare
)

type Ready

type Ready struct {
	SentBase

	Users    []*User        `json:"users"`
	Guilds   []*Guild       `json:"servers"`
	Channels []*Channel     `json:"channels"`
	Members  []*GuildMember `json:"members"`
}

type Reply

type Reply struct {
	ID      string `json:"id"`
	Mention bool   `json:"mention"`
}

type RevoltBot

type RevoltBot struct {
	Token string

	Users map[string]*User

	Guilds map[string]*Guild

	Channels map[string]*Channel

	Members map[string]*GuildMember
	// contains filtered or unexported fields
}

func NewRevoltBot

func NewRevoltBot(token string) (rb *RevoltBot)

func (*RevoltBot) FetchUser

func (rb *RevoltBot) FetchUser(userID string) (user *User, err error)

func (*RevoltBot) Get

func (rb *RevoltBot) Get(path string) (resp *http.Response, err error)

func (*RevoltBot) Heartbeat

func (rb *RevoltBot) Heartbeat()

func (*RevoltBot) OnAuthenticated

func (rb *RevoltBot) OnAuthenticated(o Authenticated)

func (*RevoltBot) OnChannelAck

func (rb *RevoltBot) OnChannelAck(o ChannelAck)

func (*RevoltBot) OnChannelCreate

func (rb *RevoltBot) OnChannelCreate(o ChannelCreate)

func (*RevoltBot) OnChannelDelete

func (rb *RevoltBot) OnChannelDelete(o ChannelDelete)

func (*RevoltBot) OnChannelGroupJoin

func (rb *RevoltBot) OnChannelGroupJoin(o ChannelGroupJoin)

func (*RevoltBot) OnChannelGroupLeave

func (rb *RevoltBot) OnChannelGroupLeave(o ChannelGroupLeave)

func (*RevoltBot) OnChannelStartTyping

func (rb *RevoltBot) OnChannelStartTyping(o ChannelStartTyping)

func (*RevoltBot) OnChannelStopTyping

func (rb *RevoltBot) OnChannelStopTyping(o ChannelStopTyping)

func (*RevoltBot) OnChannelUpdate

func (rb *RevoltBot) OnChannelUpdate(o ChannelUpdate)

func (*RevoltBot) OnDispatch

func (rb *RevoltBot) OnDispatch(messageType string, data []byte) (err error)

func (*RevoltBot) OnMessageCreate

func (rb *RevoltBot) OnMessageCreate(o MessageCreate)

func (*RevoltBot) OnMessageDelete

func (rb *RevoltBot) OnMessageDelete(o MessageDelete)

func (*RevoltBot) OnMessageUpdate

func (rb *RevoltBot) OnMessageUpdate(o MessageUpdate)

func (*RevoltBot) OnPong

func (rb *RevoltBot) OnPong(o Pong)

func (*RevoltBot) OnReady

func (rb *RevoltBot) OnReady(o Ready)

func (*RevoltBot) OnServerDelete

func (rb *RevoltBot) OnServerDelete(o ServerDelete)

func (*RevoltBot) OnServerMemberJoin

func (rb *RevoltBot) OnServerMemberJoin(o ServerMemberJoin)

func (*RevoltBot) OnServerMemberLeave

func (rb *RevoltBot) OnServerMemberLeave(o ServerMemberLeave)

func (*RevoltBot) OnServerMemberUpdate

func (rb *RevoltBot) OnServerMemberUpdate(o ServerMemberUpdate)

func (*RevoltBot) OnServerRoleDelete

func (rb *RevoltBot) OnServerRoleDelete(o ServerRoleDelete)

func (*RevoltBot) OnServerRoleUpdate

func (rb *RevoltBot) OnServerRoleUpdate(o ServerRoleUpdate)

func (*RevoltBot) OnServerUpdate

func (rb *RevoltBot) OnServerUpdate(o ServerUpdate)

func (*RevoltBot) OnUserRelationship

func (rb *RevoltBot) OnUserRelationship(o UserRelationship)

func (*RevoltBot) OnUserUpdate

func (rb *RevoltBot) OnUserUpdate(o UserUpdate)

func (*RevoltBot) Post

func (rb *RevoltBot) Post(path string, data interface{}) (resp *http.Response, err error)

func (*RevoltBot) SendEvent

func (rb *RevoltBot) SendEvent(data interface{}) (err error)

func (*RevoltBot) SendMessage

func (rb *RevoltBot) SendMessage(channelID string, messageRequest *MessageRequest) (message *Message, err error)

func (*RevoltBot) Start

func (rb *RevoltBot) Start() (err error)

func (*RevoltBot) UploadFile

func (rb *RevoltBot) UploadFile(fileName string, fileContent []byte) (autumnID string, err error)

type SentBase

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

type ServerDelete

type ServerDelete struct {
	SentBase

	GuildID string `json:"id"`
}

type ServerMemberJoin

type ServerMemberJoin struct {
	SentBase

	GuildID string `json:"id"`
	UserID  string `json:"user"`
}

type ServerMemberLeave

type ServerMemberLeave struct {
	SentBase

	GuildID string `json:"id"`
	UserID  string `json:"user"`
}

type ServerMemberUpdate

type ServerMemberUpdate struct {
	SentBase

	GuildID string       `json:"id"`
	Member  *GuildMember `json:"data"`
	Clear   string       `json:"clear"`
}

type ServerRoleDelete

type ServerRoleDelete struct {
	SentBase

	GuildID string `json:"id"`
	RoleID  string `json:"role_id"`
}

type ServerRoleUpdate

type ServerRoleUpdate struct {
	SentBase

	GuildID string `json:"id"`
	UserID  string `json:"user"`
}

type ServerUpdate

type ServerUpdate struct {
	SentBase

	*Guild
	Clear string `json:"clear"`
}

type Theme

type Theme uint8
const (
	ThemeRegular Theme = iota
	ThemeBadge
	ThemeVertical
)

type User

type User struct {
	ID           string           `json:"_id"`
	Username     string           `json:"username"`
	Avatar       *File            `json:"avatar"`
	Relations    []*UserRelations `json:"relations"`
	Badges       int              `json:"badges"`
	Status       *UserStatus      `json:"status"`
	Bot          *UserBot         `json:"bot,omitempty"`
	Relationship string           `json:"relationship"`
	Online       bool             `json:"online"`
	Flags        int              `json:"flags"`
}

type UserBot

type UserBot struct {
	Owner string `json:"owner"`
}

type UserRelations

type UserRelations struct {
	Status string `json:"status"`
	UserID string `json:"_id"`
}

type UserRelationship

type UserRelationship struct {
	SentBase

	UserID      string `json:"id"`
	OtherUserID string `json:"user"`
	Status      string `json:"status"`
}

type UserStatus

type UserStatus struct {
	CustomStatus string `json:"text"`
	Presence     string `json:"presence"`
}

type UserUpdate

type UserUpdate struct {
	SentBase

	UserID string `json:"id"`
	Data   *User  `json:"data"`
	Clear  string `json:"clear"`
}

type Xalignment

type Xalignment uint8
const (
	AlignLeft Xalignment = iota
	AlignMiddle
	AlignRight
)

type Yalignment

type Yalignment uint8
const (
	AlignTop Yalignment = iota
	AlignCenter
	AlignBottom
)

Jump to

Keyboard shortcuts

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