v0.0.0-...-a510a1c Latest Latest

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

Go to latest
Published: Jan 1, 2024 License: Apache-2.0 Imports: 19 Imported by: 0



Package aoc implements a simple client for the AoC website.



View Source
const AoCWebsite = ""

AoCWebsite is the default website of Advent of Code.


This section is empty.


This section is empty.


type Cache

type Cache interface {
	// Get the value associated with key.
	Get(ctx context.Context, key string) ([]byte, error)
	// Set the value associated with key to val.
	Set(ctx context.Context, key string, val []byte) error

Cache stores temporary data.

type Client

type Client struct {
	// SessionCookie to use. Must be set to access user data.
	SessionCookie string

	// BaseURL of the AoC website. Defaults to AoCWebsite.
	BaseURL string

	// Event to use, where needed. Defaults to current year.
	Event string

	// Cache for temporary data. If nil, no cache is used.
	Cache Cache

	Jar http.CookieJar
	// contains filtered or unexported fields

Client to the AoC Website. The zero value is valid and uses sensible defaults.

func (*Client) Input

func (c *Client) Input(ctx context.Context, day int, w io.Writer) error

Input fetches the input for the given day and writes it to w. If day is 0, it defaults to the most recent day.

func (*Client) Leaderboard

func (c *Client) Leaderboard(ctx context.Context, id int) (*Leaderboard, error)

Leaderboard fetches the private leaderboard with the given id.

type DirCache

type DirCache string

DirCache stores data in a directory. If empty, defaults to filepath.Join(os.UserCacheDir(), "aoc", "cache")

func (DirCache) Get

func (c DirCache) Get(ctx context.Context, key string) ([]byte, error)

Get implements Cache.

func (DirCache) Purge

func (c DirCache) Purge(ctx context.Context) error

Purge the cache.

func (DirCache) Set

func (c DirCache) Set(ctx context.Context, key string, val []byte) error

Set implements Cache.

type Leaderboard

type Leaderboard struct {
	Owner   int
	Event   string
	Members []LeaderboardMember

Leaderboard is the data for a private leaderboard.

func (*Leaderboard) UnmarshalJSON

func (b *Leaderboard) UnmarshalJSON(buf []byte) error

UnmarshalJSON implements json.Unmarshaler.

type LeaderboardMember

type LeaderboardMember struct {
	ID          int
	Name        string
	Stars       int
	LastStar    time.Time
	LocalScore  int
	GlobalScore int
	Days        []LeaderboardMemberDay

LeaderboardMember is the data for the member of a private leaderboard.

type LeaderboardMemberDay

type LeaderboardMemberDay struct {
	Day   int
	Part1 *LeaderboardStar
	Part2 *LeaderboardStar

LeaderboardMemberDay represents the stars a given LeaderboardMember got on a given day.

type LeaderboardStar

type LeaderboardStar struct {
	Index int
	Got   time.Time

LeaderboardStar represents a star gotten by a LeaderboardMember on a LeaderboardMemberDay.

Jump to

Keyboard shortcuts

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