setup

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package setup is `tinio new`: it raises an agent from one of the characters in characters/, in their own database. Nothing is written until every answer is in; then .env holds only where they live (DATABASE_URL) and the key to their secrets (TINIO_KEY).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetEnv

func SetEnv(text, key, value string) string

SetEnv keeps everything else in text, comments too. The line is written by godotenv, so it reads back exactly.

func Stopped

func Stopped(err error) bool

Types

type BotName

type BotName func(ctx context.Context, token string) (string, error)

type Database

type Database func(ctx context.Context, url string) (whose string, err error)

Database says whose memory a database holds ("" if no one's).

type FirstMessage

type FirstMessage func(ctx context.Context, token string, wait time.Duration) (int64, string, error)

FirstMessage returns the sender's user ID and first name, and marks the message read so the person doesn't answer it later.

type LocalPostgres

type LocalPostgres func(ctx context.Context, name string) (string, error)

type Prompter

type Prompter interface {
	// Input asks for text; current is offered (masked when secret) and kept
	// on an empty answer. There must be an answer.
	Input(title, current string, secret bool) (string, error)
	Select(title string, options []string) (int, error)
	Confirm(title string, def bool) (bool, error)
}

type Result

type Result struct {
	Name string
	Env  map[string]string // all of .env now
	// Dropped are what the .env before had besides: no longer theirs.
	Dropped []string
	Start   bool
}

type Save

type Save func(ctx context.Context, url, key string, files map[string][]byte, secrets map[string]string) error

Save makes the database at url theirs: files are their sections by file name, secrets sealed with key.

type Setup

type Setup struct {
	Ask Prompter
	Out io.Writer

	// Files has Characters, the folder of characters to start from, and
	// Example, what a new .env is written from. Env is on disk.
	Files      fs.FS
	Characters string
	Example    string
	Env        string

	BotName      BotName
	FirstMessage FirstMessage
	Database     Database
	Postgres     LocalPostgres // nil: none offered
	Save         Save
	Now          func() time.Time
}

func (*Setup) Run

func (s *Setup) Run(ctx context.Context) (Result, error)

type Terminal

type Terminal struct{}

func (Terminal) Confirm

func (Terminal) Confirm(title string, def bool) (bool, error)

func (Terminal) Input

func (Terminal) Input(title, current string, secret bool) (string, error)

func (Terminal) Select

func (Terminal) Select(title string, options []string) (int, error)

Jump to

Keyboard shortcuts

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