app

package
v0.0.0-...-f5ab1f4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package app provides a base of the bot application. App handles command line arguments and manages mmbot.Robot.

Index

Constants

This section is empty.

Variables

View Source
var NewConfigTemplate = `` /* 1400-byte string literal not displayed */

NewConfigTemplate is a template for configuration file. You can change it content by adding your extra configuration entries. {{.Name}} is replaced with the application name.

Functions

This section is empty.

Types

type App

type App struct {
	*cli.App
	Config       *Config
	ConfigLoader func(file string) (*Config, error)
	InitRobot    func(*mmbot.Robot) error
}

App is a bot application.

func NewApp

func NewApp() *App

NewApp creates new App.

func (*App) LoadConfig

func (app *App) LoadConfig(c *cli.Context) error

LoadConfig loads configuration file and store it into app.Config.

type CommonConfig

type CommonConfig struct {
	Log     string `toml:"log"`
	PIDFile string `toml:"pidfile"`
	// contains filtered or unexported fields
}

CommonConfig is the configration of common category.

type Config

type Config struct {
	Common     CommonConfig     `toml:"common"`
	Mattermost MattermostConfig `toml:"mattermost"`
	Server     ServerConfig     `toml:"server"`
}

Config is the configuration of the application.

func LoadConfigFile

func LoadConfigFile(filename string) (*Config, error)

LoadConfigFile loads configuration file and returns Config.

func (*Config) AdapterConfig

func (c *Config) AdapterConfig() *adapter.Config

AdapterConfig returns mmhook.Config.

func (*Config) RobotConfig

func (c *Config) RobotConfig() *mmbot.Config

RobotConfig returns mmbot.Config.

func (*Config) Validate

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

Validate validates configuration values.

func (*Config) ValidateAndExitOnError

func (c *Config) ValidateAndExitOnError()

ValidateAndExitOnError validates configuration values. Print log and exit if errors exist.

type Logger

type Logger struct {
	*log.Logger
	// contains filtered or unexported fields
}

Logger is a logger that has *os.File.

func NewLogger

func NewLogger(logfile string) (*Logger, error)

func NewNullLogger

func NewNullLogger() (*Logger, error)

func (*Logger) Close

func (l *Logger) Close() error

Close close the log file when it is not nil.

type MattermostConfig

type MattermostConfig struct {
	OutgoingURL        string   `toml:"outgoing_url"`
	IncomingPath       string   `toml:"incoming_path"`
	Tokens             []string `toml:"tokens"`
	UserName           string   `toml:"username"`
	OverrideUserName   string   `toml:"override_username"`
	IconURL            string   `toml:"icon_url"`
	InsecureSkipVerify bool     `toml:"insecure_skip_verify"`
}

MattermostConfig is the configuration for mattermost.

type PIDFile

type PIDFile string

func NewPIDFile

func NewPIDFile(pidfile string) (PIDFile, error)

func (PIDFile) Create

func (p PIDFile) Create() error

func (PIDFile) Exists

func (p PIDFile) Exists() bool

func (PIDFile) Remove

func (p PIDFile) Remove() error

type ServerConfig

type ServerConfig struct {
	Enable      bool   `toml:"enable"`
	BindAddress string `toml:"bind_address"`
	Port        int    `toml:"port"`
}

ServerConfig is the configration for the bot HTTP server.

Jump to

Keyboard shortcuts

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