rbxfetch

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 18 Imported by: 0

README

GoDoc

rbxfetch

The rbxfetch package retrieves information about Roblox builds.

Documentation

Overview

The rbxfetch package retrieves information about Roblox builds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFilterFile

func NewFilterFile(params iofl.Params, r io.ReadCloser) (f iofl.Filter, err error)

NewFilterFile is an iofl.NewFilter that returns a FilterFile.

func NewFilterIconScan

func NewFilterIconScan(params iofl.Params, r io.ReadCloser) (f iofl.Filter, err error)

NewFilterIconScan is an iofl.NewFilter that returns a FilterIconScan.

func NewFilterURL

func NewFilterURL(params iofl.Params, r io.ReadCloser) (f iofl.Filter, err error)

NewFilterURL is an iofl.NewFilter that returns a FilterURL.

func NewFilterZip

func NewFilterZip(params iofl.Params, r io.ReadCloser) (f iofl.Filter, err error)

NewFilterZip is an iofl.NewFilter that returns a FilterZip.

Types

type Build

type Build struct {
	Type    string
	GUID    string
	Date    time.Time
	Version Version
}

Build represents information about a single Roblox build.

func (*Build) UnmarshalJSON

func (b *Build) UnmarshalJSON(p []byte) (err error)

type CacheMode

type CacheMode int

CacheMode specifies how data is cached between calls.

const (
	// Data is never cached.
	CacheNone CacheMode = iota
	// Data is cached in the temporary directory.
	CacheTemp
	// Data is cached in the user cache directory. If unavailable, the
	// temporary directory is used instead.
	CachePerm
	// Data is cached to a custom directory specified by CacheLocation.
	CacheCustom
)

type Client

type Client struct {
	// CacheMode specifies how to cache files.
	CacheMode CacheMode
	// CacheLocation specifies the path to store cached files, when CacheMode
	// is CacheCustom.
	CacheLocation string
	// Client is the HTTP client that performs requests.
	Client *http.Client
	// contains filtered or unexported fields
}

Client is used to perform the fetching of information. It controls where data is retrieved from, and how the data is cached.

func NewClient

func NewClient() *Client

NewClient returns a client with a default configuration and temporary caching. The Client is initialized with the following filters:

  • url: FilterURL
  • file: FilterFile
  • zip: FilterZip
  • iconscan: FilterIconScan

Using these filters, the following chains are specified:

  • Latest: Fetches the GUID of the latest build.
  • Live: Fetches the GUID of the latest live 32-bit Studio build.
  • Live64: Fetches the GUID of the latest live 64-bit Studio build.
  • Builds: Fetches a list of builds.
  • APIDump: Fetches the API dump of a given GUID.
  • ReflectionMetadata: Fetches the reflection metadata of a given GUID.
  • ClassImages: Fetches the class icons of a given GUID.
  • ExplorerIcons: Fetches the class icons of a given GUID, scanned from the Studio executable.

Finally, the following methods are specified:

  • Builds: Builds
  • Latest: Latest
  • APIDump: APIDump
  • ReflectionMetadata: ReflectionMetadata
  • ClassImages: ClassImages, ExplorerIcons
  • Live: Live64, Live

func (*Client) APIDump

func (client *Client) APIDump(guid string) (rc io.ReadCloser, err error)

APIDump returns the API dump of the given GUID. Returns nil if no "APIDump" method is configured.

func (*Client) Builds

func (client *Client) Builds() (builds []Build, err error)

Builds returns a list of available builds. Returns nil if no "Builds" method is configured.

The content of a chain is expected to be a histlog stream.

func (*Client) ClassImages

func (client *Client) ClassImages(guid string) (rc io.ReadCloser, err error)

ClassImages returns the class explorer icons for the given GUID. Returns nil if no "ClassImages" method is configured.

func (*Client) Config

func (client *Client) Config() Config

Config returns a copy of the configuration used by the client.

func (*Client) Latest

func (client *Client) Latest() (guid string, err error)

Latest returns the GUID of the latest build, which can be passed to other methods to fetch data corresponding to the latest version. Latest uses the result of the first chain that does not error. Returns an empty string if no "Latest" method is configured.

The content of a chain is expected to be a raw GUID.

func (*Client) Live

func (client *Client) Live() (guids []string, err error)

Live returns the GUIDs of the current live builds, which can be passed to other methods to fetch data corresponding to current live versions. Live visits every configured chain, returning a list of GUIDs, or the first error that occurs. Returns an empty slice if no "Live" method is configured.

The content of a chain is expected to be a JSON string containing the GUID.

func (*Client) Method added in v0.4.0

func (client *Client) Method(method, guid string) (rc io.ReadCloser, err error)

Method runs the configured method for the given GUID. Returns nil if no such method is configured.

func (*Client) ReflectionMetadata

func (client *Client) ReflectionMetadata(guid string) (rc io.ReadCloser, err error)

ReflectionMetadata returns the reflection metadata for the given GUID. Returns nil if no "ReflectionMetadata" method is configured.

func (*Client) SetConfig

func (client *Client) SetConfig(config Config) error

SetConfig uses config to configure the client.

type Config

type Config struct {
	// Methods specifies the list of chains to be used consecutively for each
	// client method. The result of each chain in the list may be used, or the
	// result of the first chain that doesn't error.
	Methods map[string][]string
	iofl.Config
}

Config is used to configure a Client.

type FilterFile

type FilterFile struct {
	Path string
	GUID string
	// contains filtered or unexported fields
}

FilterFile is an iofl.Filter that fetches from a file.

func (*FilterFile) Close

func (f *FilterFile) Close() error

func (*FilterFile) Read

func (f *FilterFile) Read(p []byte) (n int, err error)

func (*FilterFile) SetGUID

func (f *FilterFile) SetGUID(guid string)

func (*FilterFile) Source

func (f *FilterFile) Source() io.ReadCloser

type FilterIconScan

type FilterIconScan struct {
	Size int
	// contains filtered or unexported fields
}

FilterIconScan is an iofl.Filter that scans for an icon sheet image from the source.

Because the source may contain multiple images, the following heuristic is used: the format of the image is PNG, the height of the image is Size, the width is a multiple of Size, and is the first widest such image.

func (*FilterIconScan) Close

func (f *FilterIconScan) Close() error

func (*FilterIconScan) Read

func (f *FilterIconScan) Read(p []byte) (n int, err error)

func (*FilterIconScan) Source

func (f *FilterIconScan) Source() io.ReadCloser

type FilterURL

type FilterURL struct {
	URL           string
	GUID          string
	Client        *http.Client
	CacheMode     CacheMode
	CacheLocation string
	// contains filtered or unexported fields
}

FilterURL is an iofl.Filter that fetches from a URL.

func (*FilterURL) Close

func (f *FilterURL) Close() error

func (*FilterURL) Read

func (f *FilterURL) Read(p []byte) (n int, err error)

func (*FilterURL) SetCache

func (f *FilterURL) SetCache(mode CacheMode, loc string)

func (*FilterURL) SetClient

func (f *FilterURL) SetClient(client *http.Client)

func (*FilterURL) SetGUID

func (f *FilterURL) SetGUID(guid string)

func (*FilterURL) Source

func (f *FilterURL) Source() io.ReadCloser

type FilterZip

type FilterZip struct {
	File string
	// contains filtered or unexported fields
}

FilterZip is an iofl.Filter that reads a file within a zip source.

func (*FilterZip) Close

func (f *FilterZip) Close() error

func (*FilterZip) Read

func (f *FilterZip) Read(p []byte) (n int, err error)

func (*FilterZip) Source

func (f *FilterZip) Source() io.ReadCloser

type Version

type Version = histlog.Version

Version represents a Roblox version number.

Jump to

Keyboard shortcuts

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