Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterServer(initFunc InitFunc)
- type IRCServer
- type IRCServerConfig
- type InitFunc
- type Manager
- type MatrixServer
- type MatrixServerConfig
- type MatrixServerLogger
- type Server
- type ServerBase
- type Target
- type TargetMapping
- type TargetMappings
- type TargetMessage
- type TargetMessagePayload
Constants ¶
const ( EventWelcome = "001" // RPL_WELCOME EventPrivMsg = "PRIVMSG" )
Variables ¶
var Debug bool
Debug specifies debug logging should be enabled
Functions ¶
func RegisterServer ¶
func RegisterServer(initFunc InitFunc)
RegisterServer registers provided initFunc with relay
Types ¶
type IRCServer ¶
type IRCServer struct { *ServerBase // contains filtered or unexported fields }
func NewIRCServer ¶
func NewIRCServer(name string, config IRCServerConfig) *IRCServer
NewIRCServer returns a pointer to an initialised IRCServer struct
func (*IRCServer) Read ¶
func (s *IRCServer) Read(ctx context.Context, readChan chan *TargetMessage) error
Read starts reading from the IRC server rooms
func (*IRCServer) SetTargets ¶
SetTargets sets IRC server targets and joins corresponding IRC rooms
func (*IRCServer) Write ¶
func (s *IRCServer) Write(msg *TargetMessage) error
Write writes TargetMessage msg to target destination
type IRCServerConfig ¶
type IRCServerConfig struct { Host string `mapstructure:"host"` UseTLS bool `mapstructure:"use_tls"` SkipTLSVerify bool `mapstructure:"skip_tls_verify"` Username string `mapstructure:"username"` Password string `mapstructure:"password"` Nick string `mapstructure:"nick"` }
IRCServerConfig represents the configuration of an IRC server
type InitFunc ¶
type InitFunc func() []Server
InitFunc represents a function which when called returns a slice of servers
type Manager ¶
type Manager struct { Servers []Server Mappings TargetMappings }
func NewManager ¶
func NewManager(mappings TargetMappings) *Manager
NewManager returns a new instance of Manager, hydrated with provided mappings and servers
type MatrixServer ¶
type MatrixServer struct { *ServerBase // contains filtered or unexported fields }
func NewMatrixServer ¶
func NewMatrixServer(name string, config MatrixServerConfig) *MatrixServer
NewMatrixServer returns a pointer to an initialised MatrixServer struct
func (*MatrixServer) Connect ¶
func (s *MatrixServer) Connect() error
Connect connects to the configured Matrix homeserver
func (*MatrixServer) Read ¶
func (s *MatrixServer) Read(ctx context.Context, readChan chan *TargetMessage) error
Read starts reading from the Matrix server rooms
func (*MatrixServer) SetTargets ¶
func (s *MatrixServer) SetTargets(targets []Target) error
SetTargets sets Matrix server targets and joins corresponding IRC rooms
func (*MatrixServer) Write ¶
func (s *MatrixServer) Write(msg *TargetMessage) error
Write writes TargetMessage msg to target destination
type MatrixServerConfig ¶
type MatrixServerConfig struct { Homeserver string `mapstructure:"homeserver"` Username string `mapstructure:"username"` Password string `mapstructure:"password"` DisplayName string `mapstructure:"display_name"` }
MatrixServerConfig represents the configuration of a Matrix server
type MatrixServerLogger ¶
type MatrixServerLogger struct{}
func (*MatrixServerLogger) Debugfln ¶
func (l *MatrixServerLogger) Debugfln(message string, args ...interface{})
type Server ¶
type Server interface { Connect() error SetTargets(targets []Target) error Read(context.Context, chan *TargetMessage) error Name() string Write(*TargetMessage) error }
type ServerBase ¶
type ServerBase struct { Targets []Target // contains filtered or unexported fields }
ServerBase provides common methods for use with implementations of Server
func NewServerBase ¶
func NewServerBase(name string) *ServerBase
NewServerBase returns a pointer to an initialised ServerBase
type TargetMapping ¶
TargetMapping represents a one-to-one mapping of targets
type TargetMappings ¶
type TargetMappings []TargetMapping
TargetMappings represents a slice of TargetMapping structs
func (*TargetMappings) WhereDestinationServer ¶
func (t *TargetMappings) WhereDestinationServer(server string) []TargetMapping
WhereDestinationServer returns a slice of TargetMappings which reference specified server as a destination within configured target mappings
func (*TargetMappings) WhereMessageSource ¶
func (t *TargetMappings) WhereMessageSource(msg *TargetMessage) []TargetMapping
WhereMessageSource returns a slice of TargetMappings which reference source in specified message msg
func (*TargetMappings) WhereSourceServer ¶
func (t *TargetMappings) WhereSourceServer(server string) []TargetMapping
WhereSourceServer returns a slice of TargetMappings which reference specified server as a source within configured target mappings
type TargetMessage ¶
type TargetMessage struct { Source Target Destination Target Payload TargetMessagePayload }
TargetMessage represents a message between Source and Destination
func NewTargetMessage ¶
func NewTargetMessage(source Target, destination Target, payload TargetMessagePayload) *TargetMessage
NewTargetMessage returns a pointer to an intialised TargetMessage
func (*TargetMessage) GetMessage ¶
func (m *TargetMessage) GetMessage() string
GetMessage returns a formatted string representation of TargetMessage
type TargetMessagePayload ¶
TargetMessagePayload represents the payload of a TargetMessage