rebel

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

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 10 Imported by: 0

README

Rebel

an API wrapper for Revolt written in Go

more coming soon

Documentation

Index

Constants

View Source
const API_URL = "https://api.revolt.chat"
View Source
const PING_INTERVAL = 15

Variables

This section is empty.

Functions

func GenerateNonce

func GenerateNonce() string

Types

type ApiResponse

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

type Category

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

type Channel

type Channel struct {
	Id                 string                   `json:"_id"`
	ChannelType        string                   `json:"channel_type"`
	User               string                   `json:"user"`
	Name               string                   `json:"name"`
	Active             bool                     `json:"active"`
	Recipients         []string                 `json:"recipients"`
	LastMessageId      string                   `json:"last_message_id"`
	Owner              string                   `json:"owner"`
	Description        string                   `json:"description"`
	Icon               File                     `json:"icon"`
	Permissions        int                      `json:"permissions"`
	Nsfw               bool                     `json:"nsfw"`
	DefaultPermissions OverrideField            `json:"default_permissions"`
	RolePermissions    map[string]OverrideField `json:"role_permissions"`
}

This is a confusing one because the Type key is used to differeniate instead of separate objects so the fields are as follows:

SavedMessages : Id, User DirectMessages: Id, Active, Recipients, LastMessageId Group : Id, Name, Owner, Description, Recipients, Icon, LastMessageId, Nsfw, TextChannel : Id, Server, Name, Description, Icon, LastMessageId, DefaultPermissions, RolePermissions, Nsfw VoiceCHannel : Id, Server, Name, Description, Icon, DefaultPermissions, RolePermissions, Nsfw

If anyone has ideas to improve this please feel free to make a PR

type Client

type Client struct {
	Token string
	// contains filtered or unexported fields
}

func New

func New(token string) *Client

func (*Client) Close

func (client *Client) Close()

func (*Client) OnMessage

func (client *Client) OnMessage(handler func(*Client, *Message))

func (*Client) OnMessageUpdate

func (client *Client) OnMessageUpdate(handler func(*Client, *MessageUpdate))

func (*Client) OnReady

func (client *Client) OnReady(handler func(*Client, *Ready))

func (*Client) Open

func (client *Client) Open() error

func (*Client) Request

func (client *Client) Request(method string, route string, data []byte) ([]byte, error)

func (*Client) SendMessage

func (client *Client) SendMessage(channel string, message *Message) (*Message, error)

func (*Client) SendMessageContent

func (client *Client) SendMessageContent(channel string, message string) (*Message, error)

type Context

type Context struct {
	Client *Client
}

type Embed

type Embed struct {
	Type        string       `json:"type"`
	Url         string       `json:"url"`
	OriginalUrl string       `json:"original_url"`
	Special     EmbedSpecial `json:"special"`
	Title       string       `json:"title"`
	Description string       `json:"description"`
	Image       EmbedImage   `json:"image"`
	Video       EmbedVideo   `json:"video"`
	SiteName    string       `json:"site_name"`
	IconUrl     string       `json:"icon_url"`
	Colour      string       `json:"colour"`
}

type EmbedImage

type EmbedImage struct {
	Url       string `json:"url"`
	Width     int    `json:"width"`
	Height    int    `json:"height"`
	ImageSize string `json:"image_size"`
}

type EmbedSpecial

type EmbedSpecial struct {
	Id          string `json:"_id"`
	Type        string `json:"type"`
	ContentType string `json:"content_type"`
}

type EmbedVideo

type EmbedVideo struct {
	Url    string `json:"url"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

type File

type File struct {
	Id          string       `json:"_id"`
	Tag         string       `json:"tag"`
	Name        string       `json:"filename"`
	Size        int          `json:"size"`
	Metadata    FileMetadata `json:"metadata"`
	ContentType string       `json:"content_type"`
}

type FileMetadata

type FileMetadata struct {
	Type   string `json:"type"`
	Height int    `json:"height"`
	Width  int    `json:"width"`
}

type Message

type Message struct {
	Id          string        `json:"_id"`
	Nonce       string        `json:"nonce"`
	Channel     string        `json:"channel"`
	Author      string        `json:"author"`
	Content     string        `json:"content"`
	Attachments []File        `json:"attachments"`
	Edited      *iso8601.Time `json:"edited"`
}

type MessageUpdate

type MessageUpdate struct {
	Id      string  `json:"id"`
	Channel string  `json:"channel"`
	Data    Message `json:"data"`
}

type OverrideField

type OverrideField struct {
	Allowed    int `json:"a"`
	Disallowed int `json:"d"`
}

type Ping

type Ping struct {
	ApiResponse

	Data int `json:"data"`
}

type Ready

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

type Role

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

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         []Category      `json:"categories"`
	SystemMessages     SystemMessages  `json:"system_messages"`
	Roles              map[string]Role `json:"roles"`
	DefaultPermissions int             `json:"default_permissions"`
	Icon               File            `json:"file"`
	Banner             File            `json:"banner"`
	Nsfw               bool            `json:"nsfw"`
	Flags              int             `json:"flags"`
}

type SystemMessages

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

type User

type User struct {
	Id           string           `json:"_id"`
	Username     string           `json:"username"`
	Avatar       File             `json:"avatar"`
	Badges       int              `json:"badges"`
	Status       UserStatus       `json:"status"`
	Relationship UserRelationship `json:"relationship"`
	Online       bool             `json:"online"`
	Privileged   bool             `json:"privileged"`
	Flags        int              `json:"flags"`
	Bot          UserBot          `json:"bot"`
}

type UserBot

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

type UserRelationship

type UserRelationship struct {
	Id     string `json:"_id"`
	Status string `json:"status"`
}

type UserStatus

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

Jump to

Keyboard shortcuts

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