config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2015 License: Unlicense Imports: 6 Imported by: 0

Documentation

Overview

Package config manages the configuration for macarena.

The following is an example configuration file:

{
        "networks": [
                {
                        "name": "ShadowNET",
                        "host": "127.0.0.1",
                        "port": 5335,
                        "ssl":  false,
                        "pass": "foobang"
                },
                {
                        "name": "ShadowNET-2",
                        "host": "127.0.0.1",
                        "port": 5336,
                        "ssl":  false,
                        "pass": "foobang"
                }
        ],
       "myinfo": {
                "nick": "Foobang",
                "user": "bar",
                "real": "fake info"
        },
        "channels": ["#test", "#spam"]
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Networks []Network `json:"networks"` // Networks to connect to
	MyInfo   Info      `json:"myinfo"`   // Information about the bot
	Channels []string  `json:"channels"` // Channels to relay
}

Config manages the configuration for macarena. It is a container for the various data users may want to configure.

func Load

func Load(fin io.Reader) (cfg Config, err error)

Load returns a Config based on the given io.Reader or an error.

func LoadFile

func LoadFile(path string) (cfg Config, err error)

LoadFile wraps Load with opening and closing a file.

type Info

type Info struct {
	Nick  string `json:"nick"` // Nickname of bot
	User  string `json:"user"` // Username of bot
	Gecos string `json:"real"` // Realname of bot
}

Info is info about the bot.

func (Info) Validate

func (i Info) Validate() bool

Validate validates information about an Info.

type Network

type Network struct {
	Name         string `json:"name"` // Name of network for logging
	Host         string `json:"host"` // Hostname of server to connect to
	Port         int    `json:"port"` // Port of server to connect to
	UseSSL       bool   `json:"ssl"`  // Use SSL?
	ServicesPass string `json:"pass"` // Services password (/ns IDENTIFY)
}

Network is a container representing an IRC network.

func (Network) Validate

func (n Network) Validate() bool

Validate validates information about a Network.

type Validator

type Validator interface {
	Validate() (correct bool)
}

Validator is an interface to see if a configuration element is valid.

Jump to

Keyboard shortcuts

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