irc

package
v0.0.0-...-f0b9b21 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrBannedFromChannel       = Error("banned from channel")
	ErrInviteOnlyChannel       = Error("invite only channel")
	ErrChannelUserLimitReached = Error("channel user limit reached")
	ErrUnsupportedDialer       = Error("unsupported dialer")
)
View Source
const (
	// ErrPONGTimeout is thrown when the server doesn't receive the 'PONG' message before the
	// defined time-out.
	ErrPONGTimeout = Error("`PONG` timed out")
)

Variables

View Source
var DefaultTimeout = Timeout{
	Ping:       5 * time.Minute,
	Pong:       30 * time.Second,
	KeepAlive:  15 * time.Second,
	Connection: 1 * time.Minute,
	Ready:      10 * time.Second,
	Reconnect:  20 * time.Second,
}

Functions

This section is empty.

Types

type Clients

type Clients struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Clients is the stored which holds all the connected IRC clients.

func NewClients

func NewClients() Clients

NewClients retuns an initialized Clients.

func (*Clients) Add

func (c *Clients) Add(nickname string)

Add will add an entry to the clients store if it doesn't exist or is not empty.

func (*Clients) Clear

func (c *Clients) Clear()

Clear will empty the store, everything will be reset.

func (*Clients) Contains

func (c *Clients) Contains(nickname string) (ok bool)

Contains returns a bool which returns true or false if the user is stored.

func (*Clients) Get

func (c *Clients) Get(nickname string) (mode Mode, ok bool)

Get will return the mode and if the nickname exists in the clients store.

func (*Clients) Remove

func (c *Clients) Remove(nickname string)

Remove will remove the given nickname from the clients store.

func (*Clients) Sanitize

func (c *Clients) Sanitize(nickname string) (string, Mode)

Sanitize tries to determine the mode for a nickname, given it starts with one of the modes (example: '~', '+'... etc).

func (*Clients) Set

func (c *Clients) Set(nickname string, mode Mode)

Set will change the specified's nickname to the specified mode.

type Config

type Config struct {
	Hostname         string
	Port             int
	Nickname         string
	Channel          string
	UserAgent        string
	RemoveFormatting bool

	TLSConfig *tls.Config
	// contains filtered or unexported fields
}

func (Config) Address

func (c Config) Address() string

type Dialer

type Dialer interface {
	// Dial takes two arguments. Network, which should be similar to "tcp",
	// "tdp6", "udp", etc -- as well as address, which is the hostname or ip
	// of the network. Note that network can be ignored if your transport
	// doesn't take advantage of network types.
	Dial(network, address string) (net.Conn, error)
}

Dialer is an interface implementation of net.Dialer. Use this if you would like to implement your own dialer which the client will use when connecting.

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type ExprError

type ExprError struct {
	Expression *regexp.Regexp
	Message    string
	// contains filtered or unexported fields
}

func (*ExprError) Error

func (e *ExprError) Error() string

type IRC

type IRC struct {

	// Clients connected to the IRC host along with their modes.
	Clients Clients
	// contains filtered or unexported fields
}

IRC is our IRC connection which is being used as an XDCC client.

func NewIRC

func NewIRC(config Config) (irc *IRC)

func NewIRCWithDialer

func NewIRCWithDialer(dialer Dialer, config Config) (irc *IRC)

func (*IRC) Close

func (r *IRC) Close()

func (*IRC) Connect

func (r *IRC) Connect() (err error)

func (*IRC) Connected

func (r *IRC) Connected() bool

Connected return if the IRC connection is established.

func (*IRC) Context

func (r *IRC) Context() context.Context

func (*IRC) Join

func (r *IRC) Join()

func (*IRC) LastMessage

func (r *IRC) LastMessage() uint64

func (*IRC) OnConnect

func (r *IRC) OnConnect(fn OnConnect)

func (*IRC) OnDisconnect

func (r *IRC) OnDisconnect(fn OnDisconnect)

func (*IRC) OnError

func (r *IRC) OnError(fn OnError)

func (*IRC) OnReceive

func (r *IRC) OnReceive(fn OnReceive)

func (*IRC) OnReceiveExp

func (r *IRC) OnReceiveExp(exp *regexp.Regexp, cb OnReceiveExp)

func (*IRC) OnSend

func (r *IRC) OnSend(fn OnSend)

func (*IRC) Privmsg

func (r *IRC) Privmsg(to, msg string)

func (*IRC) Register

func (r *IRC) Register()

func (*IRC) SendRaw

func (r *IRC) SendRaw(message string)

SendRaw sends a out a raw message to the relay.

func (*IRC) SendRawf

func (r *IRC) SendRawf(format string, a ...any)

SendRawf sends out a formatted raw message to the relay.

type Mode

type Mode rune

Mode is a proxy type for rune

const (
	// ModeOwner represents nicknames which start with '~'.
	ModeOwner Mode = '~'
	// ModeAdmin represents nicknames which start with '&'.
	ModeAdmin Mode = '&'
	// ModeOper represents nicknames which start with '@'.
	ModeOper Mode = '@'
	// ModeHalfOp represents nicknames which starts with '%'.
	ModeHalfOp Mode = '%'
	// ModeVoice represents nicknames which start with '+'.
	ModeVoice Mode = '+'
	// ModeMember represents nicknames which don't start with anything.
	ModeMember
)

type OnConnect

type OnConnect func()

type OnDisconnect

type OnDisconnect func()

type OnError

type OnError func(err error)

type OnReceive

type OnReceive func(message string)

type OnReceiveExp

type OnReceiveExp func(ctx context.Context, message string) error

type OnSend

type OnSend func(message string)

type Timeout

type Timeout struct {
	Ping       time.Duration
	Pong       time.Duration
	KeepAlive  time.Duration
	Ready      time.Duration
	Connection time.Duration
	Reconnect  time.Duration
}

Jump to

Keyboard shortcuts

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