sync

package
v0.0.0-...-51943a4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VoiceRoomEventDescription = "🤖 Event managed by Huntbot"
	VoiceRoomPlaceholderTitle = "🫥 Placeholder Event"
)

Variables

This section is empty.

Functions

func PuzzleSort

func PuzzleSort(a, b PuzzleSortFields) int

func RoundSort

func RoundSort(a, b RoundSortFields) int

Types

type AblyKind

type AblyKind string
const (
	AblyKindUpsert AblyKind = "upsert"
	AblyKindDelete AblyKind = "delete"
)

type AblyMessage

type AblyMessage struct {
	ChangeID    int64         `json:"change_id"`
	Kind        AblyKind      `json:"kind"`
	Puzzle      *state.Puzzle `json:"puzzle,omitempty"`
	Round       *state.Round  `json:"round,omitempty"`
	ReminderFix string        `json:"reminder_fix,omitempty"`
}

type Client

type Client struct {
	RestartDiscovery chan bool
	// contains filtered or unexported fields
}

func New

func New(ably *ably.Realtime, discord *discord.Client, drive *drive.Client,
	state *state.Client) *Client

func (*Client) CheckDiscordPuzzle

func (c *Client) CheckDiscordPuzzle(ctx context.Context, puzzle state.Puzzle)

func (*Client) CheckDiscordRound

func (c *Client) CheckDiscordRound(ctx context.Context, round state.Round)

func (*Client) CreateDiscordCategory

func (c *Client) CreateDiscordCategory(ctx context.Context, round state.Round) (string, error)

CreateDiscordCategory creates a new Discord category and returns its ID.

func (*Client) CreateDiscordChannel

func (c *Client) CreateDiscordChannel(ctx context.Context, puzzle state.RawPuzzle,
	round state.Round) (string, error)

CreateDiscordChannel creates a new Discord channel and returns its ID.

func (*Client) CreateDriveFolder

func (c *Client) CreateDriveFolder(ctx context.Context, round state.Round) (string, error)

CreateDriveFolder creates a new Google Drive folder and returns its ID.

func (*Client) CreateSpreadsheet

func (c *Client) CreateSpreadsheet(ctx context.Context, puzzle state.RawPuzzle) (string, error)

CreateSpreadsheet creates a new Google Sheets spreadsheet and returns its ID.

func (*Client) NotifyNewPuzzle

func (c *Client) NotifyNewPuzzle(puzzle state.Puzzle) error

NotifyNewPuzzle sends the "New puzzle!" message to #more-eyes.

func (*Client) NotifyPuzzleWorking

func (c *Client) NotifyPuzzleWorking(puzzle state.Puzzle) error

NotifyPuzzleWorking sends the "Work started on puzzle" message to #more-eyes.

func (*Client) NotifySolveInHangingOut

func (c *Client) NotifySolveInHangingOut(puzzle state.Puzzle) error

NotifySolveInHangingOut sends the same message as above to #hanging-out. Unlike all of the other methods in this file, it does *not* require a puzzle channel to exist.

func (*Client) NotifySolveInPuzzleChannel

func (c *Client) NotifySolveInPuzzleChannel(puzzle state.Puzzle) error

NotifySolveInPuzzleChannel sends the "Puzzle solved!" (or "...backsolved!", etc.) message to the puzzle channel.

func (*Client) RestorePlaceholderEvent

func (c *Client) RestorePlaceholderEvent() error

func (*Client) RestoreSolvedCategories

func (c *Client) RestoreSolvedCategories() error

func (*Client) SortDiscordCategories

func (c *Client) SortDiscordCategories(ctx context.Context, round RoundSortFields) (int, error)

func (*Client) SortDiscordChannels

func (c *Client) SortDiscordChannels(ctx context.Context, puzzle PuzzleSortFields) (int, error)

func (*Client) SyncVoiceRooms

func (c *Client) SyncVoiceRooms(ctx context.Context) error

SyncVoiceRooms synchronizes all Discord scheduled events, creating and deleting events so that Discord matches the database state.

func (*Client) TriggerDiscoveryEnabled

func (c *Client) TriggerDiscoveryEnabled(ctx context.Context) error

func (*Client) TriggerPuzzle

func (c *Client) TriggerPuzzle(ctx context.Context, change state.PuzzleChange) error

func (*Client) TriggerRound

func (c *Client) TriggerRound(ctx context.Context, change state.RoundChange) error

func (*Client) UpdateDiscordCategory

func (c *Client) UpdateDiscordCategory(ctx context.Context, fields DiscordCategoryFields) error

UpdateDiscordCategory configures the name of the round category.

func (*Client) UpdateDiscordChannel

func (c *Client) UpdateDiscordChannel(ctx context.Context, fields DiscordChannelFields) error

UpdateDiscordChannel configures the name and category of the puzzle channel. Categories are either in a round-specific category (if unsolved) or one of a few "Solved" categories (for solved puzzles), and the channel name is prefixed with a check mark when the puzzle is solved.

func (*Client) UpdateDiscordPin

func (c *Client) UpdateDiscordPin(ctx context.Context, fields DiscordPinFields) error

UpdateDiscordPin creates or updates the pinned message at the top of the puzzle channel. This message contains information about the puzzle status as well as links to the puzzle and the spreadsheet.

func (*Client) UpdateDriveFolder

func (c *Client) UpdateDriveFolder(ctx context.Context, fields DriveFolderFields) error

UpdateDriveFolder sets the Google Drive folder name.

func (*Client) UpdateSpreadsheet

func (c *Client) UpdateSpreadsheet(ctx context.Context, fields SpreadsheetFields) error

UpdateSpreadsheet sets the spreadsheet's title and parent folder. The title is the name of the puzzle, plus a check mark if the puzzle has been solved. The folder is based on the round.

func (*Client) Watch

func (c *Client) Watch(ctx context.Context)

type DiscordCategoryFields

type DiscordCategoryFields struct {
	RoundName     string
	RoundCategory string
	RoundSortFields
}

func NewDiscordCategoryFields

func NewDiscordCategoryFields(round state.Round) DiscordCategoryFields

type DiscordChannelFields

type DiscordChannelFields struct {
	PuzzleName    string
	PuzzleChannel string
	RoundName     string
	RoundCategory string
	IsSolved      bool
	PuzzleSortFields
}

func NewDiscordChannelFields

func NewDiscordChannelFields(puzzle state.Puzzle) DiscordChannelFields

type DiscordPinFields

type DiscordPinFields struct {
	RoundName  string
	RoundEmoji string
	RoundHue   int64

	PuzzleName     string
	Status         status.Status
	Note           string
	Location       string
	PuzzleURL      string
	SpreadsheetID  string
	DiscordChannel string
	VoiceRoom      string
}

func NewDiscordPinFields

func NewDiscordPinFields(puzzle state.Puzzle) DiscordPinFields

type DriveFolderFields

type DriveFolderFields struct {
	RoundName        string
	RoundDriveFolder string
}

func NewDriveFolderFields

func NewDriveFolderFields(round state.Round) DriveFolderFields

type PuzzleSortFields

type PuzzleSortFields struct {
	ID             int64
	DiscordChannel string
	IsSolved       bool

	Name string
	Meta bool
	RoundSortFields
}

func NewPuzzleSortFields

func NewPuzzleSortFields(puzzle state.RawPuzzle, round state.Round) PuzzleSortFields

type RoundSortFields

type RoundSortFields struct {
	ID              int64
	DiscordCategory string

	Name    string
	Special bool
	Sort    int64
}

func NewRoundSortFields

func NewRoundSortFields(round state.Round) RoundSortFields

type SpreadsheetFields

type SpreadsheetFields struct {
	PuzzleName       string
	SpreadsheetID    string
	RoundDriveFolder string
	IsSolved         bool
}

func NewSpreadsheetFields

func NewSpreadsheetFields(puzzle state.Puzzle) SpreadsheetFields

type VoiceRoomFields

type VoiceRoomFields struct {
	VoiceRoom string
	Name      string // only if VoiceRoom is set
}

func NewVoiceRoomFields

func NewVoiceRoomFields(puzzle state.Puzzle) VoiceRoomFields

Jump to

Keyboard shortcuts

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