api

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: 5 Imported by: 0

Documentation

Overview

Package api contains types and methods for interacting with Revolt's REST API.

Index

Constants

View Source
const (
	ErrNotFound  = errors.Sentinel("not found")
	ErrForbidden = errors.Sentinel("forbidden")
)

HTTP error codes

View Source
const (
	EndpointQueryNode = "/"
	EndpointChannels  = "/channels/"
	EndpointMessages  = "/messages/"
	EndpointUsers     = "/users/"
)

Endpoint constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*httputil.Client
}

Client is an API client.

func New

func New(token string) *Client

New returns a new API client.

func (*Client) EditMessage

func (c *Client) EditMessage(channelID, msgID string, content string) error

EditMessage edits the given message's content.

func (*Client) QueryNode

func (c *Client) QueryNode() (*QueryNodeResponse, error)

QueryNode returns information about the remote node.

func (*Client) RequestJSON

func (c *Client) RequestJSON(out interface{}, method, url string, opts ...httputil.RequestOption) (err error)

RequestJSON ...

func (*Client) SendMessage

func (c *Client) SendMessage(channelID string, content string) (*revolt.Message, error)

SendMessage sends a text message.

func (*Client) SendMessageComplex

func (c *Client) SendMessageComplex(channelID string, data SendMessageData) (*revolt.Message, error)

SendMessageComplex sends a message to the target channel. Returns a message object on success.

func (*Client) User

func (c *Client) User(id string) (*revolt.User, error)

User returns the given user.

type MessageReply

type MessageReply struct {
	// The message ID to reply to.
	ID string `json:"id"`
	// Whether or not this reply will mention the replied-to user.
	Mention bool `json:"mention"`
}

MessageReply ...

type QueryNodeFeatures

type QueryNodeFeatures struct {
	Registration bool `json:"registration"`

	Captcha QueryNodeFeaturesCaptcha `json:"captcha"`

	Email      bool `json:"email"`
	InviteOnly bool `json:"invite_only"`

	Autumn  QueryNodeFeaturesService `json:"autumn"`
	January QueryNodeFeaturesService `json:"january"`
	Voso    QueryNodeFeaturesService `json:"voso"`
}

QueryNodeFeatures ...

type QueryNodeFeaturesCaptcha

type QueryNodeFeaturesCaptcha struct {
	Enabled bool   `json:"enabled"`
	Key     string `json:"key"`
}

QueryNodeFeaturesCaptcha ...

type QueryNodeFeaturesService

type QueryNodeFeaturesService struct {
	Enabled bool   `json:"enabled"`
	URL     string `json:"url"`
	WS      string `json:"ws,omitempty"`
}

QueryNodeFeaturesService ...

type QueryNodeResponse

type QueryNodeResponse struct {
	Version   string `json:"revolt"`
	Websocket string `json:"ws"`
	App       string `json:"app"`
	Vapid     string `json:"vapid"`
	Features  QueryNodeFeatures
}

QueryNodeResponse ...

type SendMessageData

type SendMessageData struct {
	Content     string         `json:"content"`
	Attachments []string       `json:"attachments,omitempty"`
	Replies     []MessageReply `json:"replies,omitempty"`

	// If not set, will be set to a random UUID.
	Nonce string `json:"nonce"`
}

SendMessageData is the data used in c.SendMessage

Jump to

Keyboard shortcuts

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