lib

package
v0.0.0-...-192a649 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

2019 Daniel Oaks <daniel@danieloaks.net> released under the MIT license

2019 Daniel Oaks <daniel@danieloaks.net> released under the MIT license

2019 Daniel Oaks <daniel@danieloaks.net> released under the MIT license

2019 Daniel Oaks <daniel@danieloaks.net> released under the MIT license

Index

Constants

View Source
const (
	// ResultIRCMessage is a regular IRC message.
	ResultIRCMessage ScriptResultLineType = iota
	// ResultDisconnected is a client being disconnected from the server.
	ResultDisconnected = iota
	// ResultDisconnectedExpected is a client being disconnecting from the server (which we expect).
	ResultDisconnectedExpected = iota
	// ResultActionSync is a note that an 'action' has just been processed, used to sync
	//  results between servers.
	ResultActionSync = iota
)

Variables

View Source
var (
	// ErrorDisconnected indicates that this socket is disconnected.
	ErrorDisconnected = errors.New("Socket is disconnected")
)

Functions

func HTMLFromResults

func HTMLFromResults(script *Script, serverConfigs map[string]ServerConfig, scriptResults map[string]*ScriptResults) string

HTMLFromResults takes a set of results and outputs an HTML representation of those results.

Types

type Config

type Config struct {
	Output  OutputConfig
	Servers map[string]ServerConfig
}

func LoadConfig

func LoadConfig(data string) (*Config, error)

func LoadConfigFromFile

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

type OutputConfig

type OutputConfig struct{}

type Script

type Script struct {
	// metadata
	Name             string
	ShortDescription string

	// actual data
	Clients map[string]bool
	Actions []ScriptAction
}

Script is a series of actions to perform on a server.

func ReadScript

func ReadScript(t string) (*Script, error)

ReadScript creates a Script from a given script file.

func (*Script) String

func (s *Script) String() string

String is a text representation of the script's actions.

type ScriptAction

type ScriptAction struct {
	// client this action applies to
	Client string
	// line that this client should send
	LineToSend string
	// list of messages to wait for after sending the given line (if one is given)
	WaitAfterFor map[string]bool
	// special action type
	SpecialActionType SpecialActionType
}

ScriptAction is an action to perform on the server, with the given client.

func NewScriptAction

func NewScriptAction() ScriptAction

NewScriptAction returns a new ScriptAction.

type ScriptResultLine

type ScriptResultLine struct {
	// required
	Type   ScriptResultLineType
	Client string

	// optional
	RawLine string
}

ScriptResultLine is a return IRC line or other action from the server.

type ScriptResultLineType

type ScriptResultLineType int

ScriptResultLineType is a type of result line from running a script.

type ScriptResults

type ScriptResults struct {
	Clients map[string]bool
	Lines   []ScriptResultLine
}

ScriptResults is the output from running a Script on a server.

func NewScriptResults

func NewScriptResults() *ScriptResults

NewScriptResults returns a new ScriptResults

type ServerConfig

type ServerConfig struct {
	DisplayName   string `yaml:"name"`
	Address       string
	UseTLS        bool `yaml:"tls"`
	TLSSkipVerify bool `yaml:"tls-skip-verify"`

	SanitisedReplacements map[string]string `yaml:"sanitised"`
}

type Socket

type Socket struct {
	// contains filtered or unexported fields
}

Socket appropriately buffers IRC lines.

func ConnectSocket

func ConnectSocket(address string, useTLS bool, tlsConfig *tls.Config) (*Socket, error)

ConnectSocket connects to the given host/port and starts our receivers if appropriate.

func MakeSocket

func MakeSocket(conn net.Conn) *Socket

MakeSocket makes a socket from the given connection.

func (*Socket) Connected

func (s *Socket) Connected() bool

Connected returns true if we're still connected

func (*Socket) Disconnect

func (s *Socket) Disconnect()

Disconnect severs our connection to the server.

func (*Socket) GetLine

func (s *Socket) GetLine() (string, error)

GetLine returns a single IRC line from the socket.

func (*Socket) Send

func (s *Socket) Send(tags map[string]string, prefix string, command string, params ...string) error

Send the given message.

func (*Socket) SendLine

func (s *Socket) SendLine(line string) error

SendLine sends a single IRC line to the socket

type SpecialActionType

type SpecialActionType int

SpecialActionType is a special type of script action.

const (
	// NoSpecialAction means no special action is performed.
	NoSpecialAction SpecialActionType = iota
	// WaitForDisconnect means process messages until we're disconnected.
	WaitForDisconnect = iota
)

Jump to

Keyboard shortcuts

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