ircproto – github.com/hlandau/ircproto Index | Files | Directories

package ircproto

import "github.com/hlandau/ircproto"

Package ircproto provides an auto-reconnecting IRC client library including support for IRCv3 capabilities, message tags and SASL.

Index

Variables

var ErrDisconnected = fmt.Errorf("not currently connected to IRC")

Returned when calling WriteMsg if not currently connected, or when calling either WriteMsg or ReadMsg after the client has been closed.

Types

type Client

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

Reconnecting IRC client.

func New

func New(cfg *Config) (*Client, error)

Create a new IRC client, which maintains a persistent connection to an IRC server and reconnects as necessary.

func (*Client) Close

func (c *Client) Close()

Tears down the current connection, if any. This is an abrupt connection close without sending e.g. a QUIT command; any messages which were queued for transmission which have yet to be processed by the server might be lost. For a clean shutdown, send a QUIT command and call Deprecate() instead.

func (*Client) Deprecate

func (c *Client) Deprecate()

Indicates that a new connection should not be made once the current connection fails. This should be used before sending QUIT in a clean shutdown sequence as otherwise the client would immediately reconnect upon losing its connection to the server.

func (*Client) NegotiateResult

func (c *Client) NegotiateResult() *ircneg.Result

If the client currently has an active connection, return the negotiation result data. Otherwise, returns nil.

func (*Client) ReadMsg

func (c *Client) ReadMsg(ctx context.Context) (*ircparse.Msg, error)

Reads a message from the current connection. If there is no current connection, blocks until a connection is available.

If an error occurs during read, the current connection is destroyed and the error which occurred is returned. Subsequent calls to this method will then block until a new connection is available. In other words, errors being returned indicate the connection has failed and that a new connection is being attempted, and you can then read from the new connection (whenever it is successfully created, which may be some time in the future) by calling ReadMsg() again.

func (*Client) WriteMsg

func (c *Client) WriteMsg(ctx context.Context, msg *ircparse.Msg) error

Writes a message to the current connection. If there is no current connection, returns ErrDisconnected and the message is not queued.

If an error occurs during transmission, the current connection is destroyed and the error which occurred is returned. Expect subsequent calls to WriteMsg() to return ErrDisconnected for a while.

type Config

type Config struct {
	// Should return a valid config. Called every time a new connection is
	// made.
	ConnConfigFunc func() (*ircconn.Config, error)
	// Should return a valid config. Called every time a new connection is made.
	NegConfigFunc func() (*ircneg.Config, error)
	// Return the URLs to connect to. Called every time a new connection is made.
	URLListFunc func() ([]string, error)
	// Backoff timer.
	Backoff unet.Backoff
}

Configuration for IRC clients.

func Simple

func Simple(ncfg *ircneg.Config, urls ...string) *Config

func (*Config) WithConn

func (cfg *Config) WithConn(ccfg *ircconn.Config) *Config

func (*Config) WithNeg

func (cfg *Config) WithNeg(ncfg *ircneg.Config) *Config

func (*Config) WithURLs

func (cfg *Config) WithURLs(urls ...string) *Config

Source Files

config.go ircproto.go

Directories

PathSynopsis
egobot
egobot/hdlautojoinPackage hdlautojoin provides a handler implementing channel autojoin functionality.
egobot/hdlctcpPackage hdlctcp provides CTCP VERSION responder functionality.
egobot/hdlhnPackage hdlhn provides Hacker News tailing functionality.
egobot/hdlnickPackage hdlnick provides a handler for maintaining an IRC bot's nickname.
egobot/hdltxbasePackage hdltxbase implements a base transmission driver for the "tx" service.
egobot/hnapiPackage hnapi provides basic functions for retrieving data from the Hacker News API.
egobot/hntailPackage hntail provides facilities for being alerted when new HN API events occur, and consuming those events like tailing a log.
egobot/ircregistryPackage ircregistry provides a service discovery and registration facility for IRC message handling modules.
ircconnPackage ircconn provides an IRC client protocol connection with the lifetime of a single transport-layer connection.
ircnegPackage ircneg provides functions for the initial handshaking of new IRC connections.
ircparsePackage ircparse provides an IRC message parser and serializer supporting RFC1459 and IRCv3 message tags.
ircsaslPackage ircsasl provides a basic SASL implementation for IRCv3 usage.
Version
v0.0.0-20240529044229-f1af42e426cd (latest)
Published
May 29, 2024
Platform
linux/amd64
Imports
9 packages
Last checked
1 month ago

Tools for package owners.