stimmtausch: Index | Files

package config

import ""

Package config contains various structs and utilities meant to hold and deal with configuration for Stimmtausch.


Package Files

client.go config.go default.go doc.go server.go trigger.go util.go world.go


const DefaultConfig string = "" /* 3411 byte string literal not displayed */


var (
    HomeDir    string
    ConfigDir  string
    WorkingDir string
    LogDir     string

func InitDirs Uses

func InitDirs()

InitDirs initializes the directories used by Stimmtausch.

type Client Uses

type Client struct {
    Syslog  Syslog
    Profile Profile
    Logging Logging
    UI      UI

Client holds information regarding how Stimmtausch runs.

type Config Uses

type Config struct {
    // Version of the configuration structure.
    Version int

    // A list of server types (MUCK, MUD, etc), dictating how to connect.
    ServerTypes map[string]ServerType `yaml:"server_types" toml:"server_types"`

    // A list of servers.
    Servers map[string]Server

    // A list of worlds (characters/users/accounts/etc) tying login information
    // to servers.
    Worlds map[string]World

    // A list of triggers to match on input.
    Triggers []Trigger

    // References to compiled triggers.
    CompiledTriggers []*Trigger `yaml:"-" toml:"-"`

    Client Client

    HomeDir    string `yaml:"-" toml:"-"`
    ConfigDir  string `yaml:"-" toml:"-"`
    WorkingDir string `yaml:"-" toml:"-"`
    LogDir     string `yaml:"-" toml:"-"`

Config holds all the configuration for Stimmtausch. For information about what the settings are used for and how they should appear, see the files in _conf

func New Uses

func New() (*Config, error)

New returns a new config object all loaded and validated.

func (*Config) Dump Uses

func (c *Config) Dump() string

func (*Config) FinalizeAndValidate Uses

func (c *Config) FinalizeAndValidate() []error

func (*Config) Reload Uses

func (c *Config) Reload() error

Reload loads config into a new object and then copies over its internals into the old object.

type Logging Uses

type Logging struct {

    // The time format to use when logging times.
    // TODO validate
    TimeString string `yaml:"time_string" toml:"time_string"`

    // Whether or not to log timestamps.
    LogTimestamps bool `yaml:"log_timestamps" toml"log_timestamps"`

    // Whether or not to keep logs of the connection after disconnect.
    LogWorld bool `yaml:"log_world" toml:"log_world"`

Logging holds information regarding logging from connections.

type Profile Uses

type Profile struct {

    // Whether or not to profile memory usage.
    Mem bool

    // Whether or not to profile CPU usage.
    CPU bool `yaml:"cpu" toml:"cpu"`

Profile holds information regarding profiling resources in development.

type Server Uses

type Server struct {
    // The key for the server in the configuration file.
    Name string

    // The hostname for the server.
    Host string

    // The port to connect to.
    Port uint

    // Whether or not to use SSL.
    SSL bool

    // Whether or not self-signed certs should be trusted.
    Insecure bool

    // The type of server (MUCK, MUSH, etc...) this is.
    ServerType string `yaml:"type" toml:"type"`

Server represents information required to connect to a remote server.

func NewServer Uses

func NewServer(name, host string, port uint, ssl, insecure bool, srvType string) *Server

NewServer returns a new server object for the given values.

type ServerType Uses

type ServerType struct {
    Name             string
    ConnectString    string `yaml:"connect_string" toml:"connect_string"`
    DisconnectString string `yaml:"disconnect_string" toml:"disconnect_string"`

ServerType represents a type of server (MUCK, MUSH, etc...), which mostly boils down to things such as how to connect to it, etc.

func NewServerType Uses

func NewServerType(name, connectString, disconnectString string) *ServerType

NewServerType returns a new serverType object for the given values.

type Syslog Uses

type Syslog struct {

    // Whether or not to show the system log in a pane in the UI.
    ShowSyslog bool `yaml:"show_syslog" toml:"log_level"`

    // Lowest log level to show by default. Options are:
    LogLevel string `yaml:"log_level" toml:"log_level"`

Syslog holds nformation regarding the logging generated by the program (as opposed to the connections).

type Trigger Uses

type Trigger struct {
    // The name of the trigger.
    Name string

    // The type of trigger: hilite, gag, script, macro.
    Type string

    // The world to which this trigger applies (if blank, applies to all).
    World string

    // A regexp to match against.
    Match string

    // A list of regexps to match against.
    Matches []string

    // A list of attributes used in hilite (color, style, etc).
    Attributes string

    // For gags, whether or not to log the gagged string anyway.
    LogAnyway bool `yaml:"log_anyway" toml:"log_anyway"`

    // The path of a script to run.
    Script string

    // Whether or not to send the output of the script or macro to the world.
    // If false, the user will be shown the output
    OutputToWorld string `yaml:"output_to_world" toml:"output_to_world"`

    // The name of a macro to run.
    Macro string
    // contains filtered or unexported fields

func (Trigger) Compile Uses

func (t Trigger) Compile() (*Trigger, error)

Compile returns a pointer to the compiled trigger.

func (*Trigger) Run Uses

func (t *Trigger) Run(world, input string, cfg *Config) (bool, string, []error)

Run takes the provided byte-slice from the world and, if it matches, runs the action specified in the trigger based on the type (hilite, gag, script macro) if the world matches the one specified in the trigger (if none is specified, it matches all worlds). It returns the (potentially modified) input, whether or not the trigger matched, and any errors it encountered along the way.

type UI Uses

type UI struct {

    // How many lines of scrollback (data received) to keep in memory.
    Scrollback int

    // How many lines of history (data sent) to keep in memory.
    History int

    // Whether or not to use a unified history buffer for all
    // connections, or one per.
    // TODO
    UnifiedHistoryBuffer bool `yaml:"unified_history_buffer" toml:"unified_history_buffer"`

    // Whether or not to use Vim-style key bindings
    // TODO
    VimKeybindings bool `yaml:"vim_keybindings" toml:"vim_keybindings"`

    // Indentation of wrapped lines.
    IndentFirst      int `yaml:"indent_first" toml:"indent_first"`
    IndentSubsequent int `yaml:"indent_subsequent" toml:"indent_subsequent"`

    // Whether or not to support mouse events
    // TODO
    Mouse bool

    // Colors in the UI
    Colors struct {
        // The colors for the input buffer titles in ansigo specifications.
        SendTitle struct {
            Active             string
            ActiveMore         string `yaml:"active_more" toml:"active_more"` // TODO
            Inactive           string
            InactiveMore       string `yaml:"inactive_more" toml:"inactive_more"` // TODO
            Disconnected       string
            DisconnectedMore   string `yaml:"disconnected_more" toml:"disconnected_more"`     // TODO
            DisconnectedActive string `yaml:"disconnected_active" toml:"disconnected_active"` // TODO
        }   `yaml:"send_title" toml:"send_title"`
        ModalTitle string `yaml:"modal_title" toml:"modal_title"`

UI holds information regarding the user interface.

type World Uses

type World struct {
    // The key for the world in the configuration file.
    Name string

    // A free-form display name for the world.
    DisplayName string `yaml:"display_name" toml:"display_name"`

    // The server to which this world belongs.
    Server string

    // The username and password to connect with.
    Username, Password string

    // Whether or not to maintain a rotated log of each connection to this world.
    Log bool

World represents the union between a server and a character.

func NewWorld Uses

func NewWorld(name, displayName, srv, username, password string, logByDefault bool) *World

NewWorld returns a new world object for the given values.

Package config imports 10 packages (graph) and is imported by 6 packages. Updated 2020-08-14. Refresh now. Tools for package owners.