config

package
v0.0.0-...-b5fa7f3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = func() Config {
	var cfg Config
	json.NewDecoder(strings.NewReader(os.Getenv("cfg"))).Decode(&cfg)
	def := Config{
		AudioDelay:    Dur{D: 250 * time.Millisecond},
		AudioLimit:    Dur{D: 3 * time.Second},
		AudioLimitTTS: Dur{D: 3 * time.Second},
		TextLimit:     64,
		Netcon: ConnInfo{
			Host: "127.0.0.1",
			Port: 31173,
		},
		TnetPort:         31173,
		FirstVoice:       "jenny",
		RateLimit:        Dur{D: 5 * time.Second},
		ServerListMaxAge: Dur{1 * time.Hour},
		ServerInfoMaxAge: Dur{1 * time.Minute},
	}
	cfg, _ = def.Merge(cfg)
	return cfg
}()
View Source
var DefaultPaths = MustNewPaths("", "")

Functions

func Write

func Write(fn string, cfg Config) error

Types

type Config

type Config struct {
	Netcon           ConnInfo        `json:"netcon"`
	Rcon             ConnInfo        `json:"rcon"`
	AudioDelay       Dur             `json:"audioDelay"`
	AudioLimit       Dur             `json:"audioLimit"`
	AudioLimitTTS    Dur             `json:"audioLimitTTS"`
	TextLimit        int             `json:"textLimit"`
	IncludeUsernames map[string]bool `json:"includeUsernames"`
	ExcludeUsernames map[string]bool `json:"excludeUsernames"`
	Hosts            map[string]bool `json:"hosts"`
	FirstVoice       string          `json:"firstVoice"`
	LogLevel         string          `json:"logLevel"`
	RateLimit        Dur             `json:"rateLimit"`
	ServerListMaxAge Dur             `json:"serverListMaxAge"`
	ServerInfoMaxAge Dur             `json:"serverInfoMaxAge"`

	Minimized *bool `json:"minimized"`
	Demo      *bool `json:"demo"`

	// deprecated: use netcon
	TnetPort int `json:"tnetPort"`
}

func Read

func Read(fn string) (config Config, err error)

func TryRead

func TryRead(fn string) Config

func (Config) Merge

func (c Config) Merge(p Config) (cfg Config, changed bool)

func (Config) StartMinimized

func (c Config) StartMinimized() bool

type ConnInfo

type ConnInfo struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Password string `json:"password"`
}

func (ConnInfo) Addr

func (c ConnInfo) Addr() string

func (ConnInfo) Merge

func (c ConnInfo) Merge(p ConnInfo) (ci ConnInfo, changed bool)

type Dur

type Dur struct{ D time.Duration }

func (Dur) MarshalText

func (d Dur) MarshalText() ([]byte, error)

func (Dur) String

func (d Dur) String() string

func (*Dur) UnmarshalText

func (d *Dur) UnmarshalText(p []byte) error

type Paths

type Paths struct {
	ConfigDir      string
	ConfigFn       string
	DataDir        string
	WebviewDataDir string
	DBDir          string
	LogsFn         string
}

func MustNewPaths

func MustNewPaths(configDir, dataDir string) *Paths

func NewPaths

func NewPaths(configDir, dataDir string) (*Paths, error)

Jump to

Keyboard shortcuts

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