lib

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: ISC Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InitialBufferSize = 1024
	MaxBufferSize     = 1024 * 1024
)
View Source
const (
	// SemVer is the semantic version of this program
	SemVer = "0.5.2"
)

Variables

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

Functions

func IRCLineToAnsi added in v0.4.0

func IRCLineToAnsi(line string, colorLevel ColorLevel, outputItalics bool) string

func IRCMessageToAnsi added in v0.4.0

func IRCMessageToAnsi(message string, colorLevel ColorLevel, outputItalics bool) string

func ReadScript added in v0.5.0

func ReadScript(filename string) (commands []string, err error)

func ReplaceControlCodes added in v0.3.0

func ReplaceControlCodes(line string) string

ReplaceControlCodes applies our control code replacements to the line.

Types

type ColorLevel added in v0.4.0

type ColorLevel int

ColorLevel represents the ANSI color level supported by the terminal.

const (
	// None represents a terminal that does not support color at all.
	ColorLevelNone ColorLevel = 0
	// Basic represents a terminal with basic 16 color support.
	ColorLevelBasic ColorLevel = 1
	// Ansi256 represents a terminal with 256 color support.
	ColorLevelAnsi256 ColorLevel = 2
	// Ansi16m represents a terminal with full true color support.
	ColorLevelAnsi16m ColorLevel = 3
)

type ConnectionConfig

type ConnectionConfig struct {
	// host-port pair for IRC over a normal stream transport
	Host string
	Port int
	// wss:// or ws:// URL for IRC over WebSocket
	WebsocketURL string
	TLS          bool
	TLSConfig    *tls.Config
	// Origin header for websockets
	Origin string
}

type IRCConnection added in v0.4.0

type IRCConnection interface {
	// SendLine sends an IRC protocol line, given without \r\n
	SendLine(string) error
	// GetLine reads and returns an IRC protocol line, stripping the \r\n
	GetLine() (string, error)
	// Disconnect closes the connection, interrupting GetLine(); it must be
	// concurrency-safe and idempotent.
	Disconnect()
	RemoteAddr() net.Addr
}

IRCConnection is an abstract IRC connection.

func NewConnection

func NewConnection(config ConnectionConfig) (conn IRCConnection, err error)

func NewIRCWebSocket added in v0.4.0

func NewIRCWebSocket(wsUrl, origin string, tlsConfig *tls.Config) (IRCConnection, error)

type IRCWebSocket added in v0.4.0

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

func (*IRCWebSocket) Disconnect added in v0.4.0

func (w *IRCWebSocket) Disconnect()

func (*IRCWebSocket) GetLine added in v0.4.0

func (w *IRCWebSocket) GetLine() (string, error)

func (*IRCWebSocket) RemoteAddr added in v0.4.0

func (w *IRCWebSocket) RemoteAddr() net.Addr

func (*IRCWebSocket) SendLine added in v0.4.0

func (w *IRCWebSocket) SendLine(line string) error

type Socket

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

Socket appropriately buffers IRC lines.

func ConnectSocket

func ConnectSocket(host string, port int, useTLS bool, tlsConfig *tls.Config) (*Socket, error)

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

func MakeSocket added in v0.2.0

func MakeSocket(conn net.Conn) *Socket

MakeSocket makes a socket from the given connection.

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) RemoteAddr added in v0.4.0

func (s *Socket) RemoteAddr() net.Addr

func (*Socket) SendLine

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

SendLine sends a single IRC line to the socket

type Transcript added in v0.4.0

type Transcript struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewTranscript added in v0.4.0

func NewTranscript(filename string) (result *Transcript, err error)

func (*Transcript) Close added in v0.4.0

func (t *Transcript) Close() error

func (*Transcript) WriteLine added in v0.4.0

func (t *Transcript) WriteLine(line string, isClient bool) (err error)

Jump to

Keyboard shortcuts

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