tetrio

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 16 Imported by: 0

README

tetrio

Go Reference

TETR.IO API client library in Go.

Not all endpoints are implemented as I don't use most of them.


This is an unofficial project! not affiliated with osk or TETR.IO.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAmbiguousRecord = errors.New("tetrio: record has no winner or loser")
View Source
var ErrNonMultiRecord = errors.New("tetrio: not a multiplayer record")
View Source
var Upstream = "https://ch.tetr.io/api"

Functions

func UnmarshalResponse

func UnmarshalResponse(resp *types.Response, v any) error

Types

type Error

type Error string // The API returns string errors so... not much can be done.

func (Error) Error

func (e Error) Error() string

type LeaguePlayer

type LeaguePlayer struct {
	User         types.PartialUser
	Wins         int
	Inputs       int
	PiecesPlaced int
	Handling     types.Handling
	Stats        types.VersusStats
	RoundStats   []types.VersusStats
}

type LeagueRecord

type LeagueRecord struct {
	ReplayID  string
	TS        time.Time
	IsForfeit bool
	Winner    LeaguePlayer
	Loser     LeaguePlayer
}

func (*LeagueRecord) UnmarshalJSON

func (g *LeagueRecord) UnmarshalJSON(data []byte) error

type NoUserError

type NoUserError struct {
	UID string
	// contains filtered or unexported fields
}

func (NoUserError) Error

func (e NoUserError) Error() string

func (NoUserError) Unwrap

func (e NoUserError) Unwrap() error

type RankRange

type RankRange struct {
	Rank       string
	Percentile float64
	Top        *types.LeagueUser
	Bottom     *types.LeagueUser
}

func Cutoffs

func Cutoffs(lb []types.LeagueUser) ([]RankRange, error)

func (RankRange) Includes

func (r RankRange) Includes(TR float64) bool

Includes returns wheter TR is in range (Bottom, Top]

type SearchError

type SearchError uint64

func (SearchError) Error

func (e SearchError) Error() string

type Session

type Session struct {
	ID string
	// contains filtered or unexported fields
}

func New

func New() Session

func (Session) GetLeagueLB

func (s Session) GetLeagueLB(ctx context.Context, country string) ([]types.LeagueUser, error)

func (Session) GetLeagueLBGlobal

func (s Session) GetLeagueLBGlobal(ctx context.Context) ([]types.LeagueUser, error)

func (Session) GetMatches

func (s Session) GetMatches(ctx context.Context, userID string) ([]LeagueRecord, error)

func (Session) GetUser

func (s Session) GetUser(ctx context.Context, name string) (*types.FullUser, error)

func (Session) SearchUser

func (s Session) SearchUser(ctx context.Context, discordID uint64) (types.PartialUser, error)

func (Session) Send

func (s Session) Send(ctx context.Context, path string) (*types.Response, error)

Send sends a GET request to the specified path rooted from Upstream, it sets the X-Session-ID header and checks the status code.

type StatusError

type StatusError struct {
	Code    int
	Content []byte
}

func (StatusError) Error

func (e StatusError) Error() string

Directories

Path Synopsis
Package tlhist is an API client for @p1nkl0bst3r's https://api.p1nkl0bst3r.xyz/tlhist/ TETRA LEAGUE history API.
Package tlhist is an API client for @p1nkl0bst3r's https://api.p1nkl0bst3r.xyz/tlhist/ TETRA LEAGUE history API.

Jump to

Keyboard shortcuts

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