tomlconf

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package tomlconf is an implementation of GGGBs config system that works with a toml library rather than XML. Right now its a toy

Index

Constants

View Source
const (
	MESSAGE = iota
	JOIN
	PART
	NICK
	QUIT
	KICK
	EXTERNAL
)

Indices into a FormatSet

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	BridgedChannel string `toml:"bridged_channel" comment:"The channel to bridge chat between"`
	// string ptr to check for null
	ImportFormat *string `toml:"import_format"`
	Formats      FormatSet

	BridgeChat    bool `toml:"bridge_chat" default:"true" comment:"Should this game bridge its chat (default true)"`
	DumpStdout    bool `toml:"dump_stdout" comment:"Dump stdout to the bridged channel (This is a spammy debug option)"`
	DumpStderr    bool `toml:"dump_stderr" comment:"Dump stdout to the bridged channel (This is a spammy debug option)"`
	AllowForwards bool `toml:"allow_forwards" default:"true" comment:"Allow messages from other games (default true)"`

	Transformer *ConfigHolder `comment:"How to transform messages to and from this game. (leave out for StripTransformer)"`
}

Chat is a config for game.Chat

type Command

type Command struct {
	Format        string `comment:"go template based formatter"`
	Help          string `comment:"help for the command"`
	RequiresAdmin int    `toml:"requires_admin" comment:"the admin level required to execute this command (0 for none)"`
}

Command holds commands that can be executed by users

type Config

type Config struct {
	OriginalPath string `toml:"-"`
	Connection   ConfigHolder

	FormatTemplates  map[string]FormatSet          `toml:"format_templates"`
	RegexpTemplates  map[string][]Regexp           `toml:"regexp_templates"`
	CommandTemplates map[string]map[string]Command `toml:"command_templates"`
	Games            []*Game                       `toml:"game"`
}

Config is the main config struct

func GetConfig

func GetConfig(path string) (*Config, error)

GetConfig fetches the config located at the given path

type ConfigHolder

type ConfigHolder struct {
	Type     string     `toml:"type"`
	RealConf *toml.Tree `toml:"config"`
}

ConfigHolder holds a config that is unknown at parse time

type FormatSet

type FormatSet struct {
	// string ptr to allow to check for null
	Message  *string
	Join     *string
	Part     *string
	Nick     *string
	Quit     *string
	Kick     *string
	External *string

	Extra map[string]string
}

FormatSet holds a set of formatters to be converted to a format.Format

type Game

type Game struct {
	Name        string
	AutoStart   bool   `toml:"auto_start"`
	AutoRestart int    `toml:"auto_restart"`
	Comment     string `comment:"A message to be added to the status line of this Game"`

	Transport ConfigHolder

	PreRoll struct {
		Regexp  string
		Replace string
	} `comment:"regex to be applied to all outgoing lines before\n they are parsed by the below regexps"`

	Chat Chat `comment:"Configuration for how this game will interact with chat"`

	CommandImports []string           `toml:"import_commands"`
	Commands       map[string]Command `comment:"Commands that can be executed on the chat side"`

	RegexpImports []string `toml:"import_regexps"`
	Regexps       []Regexp `toml:"regexp"`
}

Game holds the config for a Game instance

type Regexp

type Regexp struct {
	Name   string
	Regexp string
	// TODO: maybe do a string pointer here, then checking in game will be easier when it comes to regexps
	// TODO: designed to eat things
	Format   string
	Priority int `toml:",omitempty"`

	Eat          bool `default:"true" comment:"Stop processing regexps after this is matched. (default true)"`
	SendToChan   bool `toml:"send_to_chan" default:"true" comment:"Send the formatted message to the bridged channel (default true)"`   //nolint:lll // Cant shorten them
	SendToOthers bool `toml:"send_to_others" default:"true" comment:"Send the formatted message to other running games (default true)"` //nolint:lll // Cant shorten them
	SendToLocal  bool `toml:"send_to_local" comment:"Send the formatted message to the game it came from (default false)"`
}

Regexp is a representation of a game regexp

Jump to

Keyboard shortcuts

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