libmauirc

package module
v0.0.0-...-91a2375 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2017 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package libmauirc is the main package of this library

Package libmauirc is the main package of this library

Package libmauirc is the main package of this library

Package libmauirc is the main package of this library

Package libmauirc is the main package of this library

Package libmauirc is the main package of this library

Package libmauirc is the main package of this library

Index

Constants

This section is empty.

Variables

View Source
var ErrDisconnected = errors.New("Disconnected")

ErrDisconnected is given when the client disconnects

View Source
var Version = "libmauirc 0.2"

Version is the IRC client version string

Functions

This section is empty.

Types

type Address

type Address interface {
	// String returns the address as a string
	String() string
}

Address is an interface with a function that returns a valid connection address.

type AuthHandler

type AuthHandler interface {
	// Do is called when necessary authentication tasks should be executed.
	Do(c *ConnImpl)
}

AuthHandler handles authentication to an IRC server

type ConnImpl

type ConnImpl struct {
	sync.Mutex
	sync.WaitGroup
	PingFreq             time.Duration
	KeepAlive            time.Duration
	Timeout              time.Duration
	AutoreconnectTimeout time.Duration

	Version       string
	PreferredNick string
	Nick          string
	User          string
	RealName      string
	QuitMsg       string
	Lag           int64

	Auth    []AuthHandler
	Address Address

	DebugWriter io.Writer

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

ConnImpl is the default implementation of Connection. The functions here don't have separate documentation. See the documentation of the interfaces Connection contains for documentation on ConnImpl's functions.

func (*ConnImpl) Action

func (c *ConnImpl) Action(channel, msg string)

Action - See Tunnel interface docs Action - See Tunnel interface docs

func (*ConnImpl) AddAuth

func (c *ConnImpl) AddAuth(auth AuthHandler)

AddAuth - see Data interface docs

func (*ConnImpl) AddHandler

func (c *ConnImpl) AddHandler(code string, handler Handler) int

AddHandler adds the given handler for all messages with the given code.

func (*ConnImpl) AddStdHandlers

func (c *ConnImpl) AddStdHandlers()

AddStdHandlers add standard IRC handlers for this connection The standard handlers include an IRC ERROR handler, ping and pong handler, CTCP version, userinfo, clientinfo, time and ping handlers and a nick change handler.

func (*ConnImpl) Away

func (c *ConnImpl) Away(msg string)

Away - See Tunnel interface docs

func (*ConnImpl) Connect

func (c *ConnImpl) Connect() error

Connect - see Connection interface docs

func (*ConnImpl) Connected

func (c *ConnImpl) Connected() bool

Connected - see Connection interface docs

func (*ConnImpl) Debug

func (c *ConnImpl) Debug(parts ...interface{})

Debug - see Debugger interface docs

func (*ConnImpl) Debugf

func (c *ConnImpl) Debugf(msg string, args ...interface{})

Debugf - see Debugger interface docs

func (*ConnImpl) Debugfln

func (c *ConnImpl) Debugfln(msg string, args ...interface{})

Debugfln - see Debugger interface docs

func (*ConnImpl) Debugln

func (c *ConnImpl) Debugln(parts ...interface{})

Debugln - see Debugger interface docs

func (*ConnImpl) Disconnect

func (c *ConnImpl) Disconnect()

Disconnect - see Connection interface docs

func (*ConnImpl) Errors

func (c *ConnImpl) Errors() chan error

Errors - see ErrorStream interface docs

func (*ConnImpl) GetHandlers

func (c *ConnImpl) GetHandlers(code string) (handlers []Handler, ok bool)

GetHandlers gets all handlers with the given code.

func (*ConnImpl) GetNick

func (c *ConnImpl) GetNick() string

GetNick - see Data interface docs

func (*ConnImpl) GetPreferredNick

func (c *ConnImpl) GetPreferredNick() string

GetPreferredNick - see Data interface docs

func (*ConnImpl) Invite

func (c *ConnImpl) Invite(user, ch string)

Invite - See Tunnel interface docs

func (*ConnImpl) Join

func (c *ConnImpl) Join(chs string, keys string)

Join - See Tunnel interface docs

func (*ConnImpl) Kick

func (c *ConnImpl) Kick(ch, user, msg string)

Kick - See Tunnel interface docs

func (*ConnImpl) List

func (c *ConnImpl) List()

List - See Tunnel interface docs

func (*ConnImpl) LocalAddr

func (c *ConnImpl) LocalAddr() net.Addr

LocalAddr - see Connection interface docs

func (*ConnImpl) Loop

func (c *ConnImpl) Loop()

Loop - see Connection interface docs

func (*ConnImpl) Mode

func (c *ConnImpl) Mode(target, flags, args string)

Mode - See Tunnel interface docs

func (*ConnImpl) Notice

func (c *ConnImpl) Notice(channel, msg string)

Notice - See Tunnel interface docs

func (*ConnImpl) Oper

func (c *ConnImpl) Oper(username, password string)

Oper - See Tunnel interface docs

func (*ConnImpl) Part

func (c *ConnImpl) Part(ch, msg string)

Part - See Tunnel interface docs

func (*ConnImpl) Ping

func (c *ConnImpl) Ping()

Ping the IRC server Ping - See Tunnel interface docs

func (*ConnImpl) Pong

func (c *ConnImpl) Pong(msg string)

Pong replies to a Ping

func (*ConnImpl) Privmsg

func (c *ConnImpl) Privmsg(channel, msg string)

Privmsg - See Tunnel interface docs Privmsg - See Tunnel interface docs

func (*ConnImpl) Quit

func (c *ConnImpl) Quit()

Quit - See Tunnel interface docs

func (*ConnImpl) RemoveAway

func (c *ConnImpl) RemoveAway()

RemoveAway - See Tunnel interface docs

func (*ConnImpl) RemoveHandler

func (c *ConnImpl) RemoveHandler(code string, index int)

RemoveHandler removes the handler with the given index.

func (*ConnImpl) RunHandlers

func (c *ConnImpl) RunHandlers(evt *irc.Message)

RunHandlers runs handlers for the given irc message.

func (*ConnImpl) Send

func (c *ConnImpl) Send(msg *irc.Message)

Send - See Tunnel interface docs

func (*ConnImpl) SendUser

func (c *ConnImpl) SendUser()

SendUser sends the USER message to the server SendUser - See Tunnel interface docs

func (*ConnImpl) SetAddress

func (c *ConnImpl) SetAddress(addr Address)

SetAddress - see Data interface docs

func (*ConnImpl) SetDebugWriter

func (c *ConnImpl) SetDebugWriter(writer io.Writer)

SetDebugWriter - see Debugger interface docs

func (*ConnImpl) SetNick

func (c *ConnImpl) SetNick(nick string)

SetNick - See Tunnel interface docs

func (*ConnImpl) SetQuitMessage

func (c *ConnImpl) SetQuitMessage(msg string)

SetQuitMessage - see Data interface docs

func (*ConnImpl) SetRealName

func (c *ConnImpl) SetRealName(realname string)

SetRealName - see Data interface docs

func (*ConnImpl) SetUseTLS

func (c *ConnImpl) SetUseTLS(tls bool)

SetUseTLS - see Data interface docs

func (*ConnImpl) SetVersion

func (c *ConnImpl) SetVersion(version string)

SetVersion - see Data interface docs

func (*ConnImpl) Topic

func (c *ConnImpl) Topic(ch, topic string)

Topic - See Tunnel interface docs

func (*ConnImpl) Who

func (c *ConnImpl) Who(name string, op bool)

Who - See Tunnel interface docs

func (*ConnImpl) Whois

func (c *ConnImpl) Whois(name string)

Whois - See Tunnel interface docs

func (*ConnImpl) Whowas

func (c *ConnImpl) Whowas(name string)

Whowas - See Tunnel interface docs

type Connectable

type Connectable interface {
	// Connect to the server.
	// An error will be returned if some settings are incorrect or if an error is received while connecting.
	Connect() error
	// Loop to automatically reconnect to the server.
	Loop()
	// Disconnect from the server.
	Disconnect()
	// Connected checks if the connection is active.
	Connected() bool
	// LocalAddr gets the local address of a connection
	LocalAddr() net.Addr
}

Connectable contains functions to connect and disconnect

type Connection

type Connection interface {
	Debugger
	HandlerHandler
	Tunnel
	Data
	Connectable
	ErrorStream
}

Connection contains all the necessary interfaces for an IRC connection. The default implementation is ConnImpl.

func Create

func Create(nick, user string, addr Address) Connection

Create an IRC connection with the given details. By default, RealName is set to the same value as user.

type ConnectionError

type ConnectionError struct {
	Cause error
}

ConnectionError is an error that happened while connecting to the server.

func (ConnectionError) Error

func (err ConnectionError) Error() string

type Data

type Data interface {
	GetNick() string
	GetPreferredNick() string
	SetQuitMessage(msg string)
	SetRealName(realname string)
	SetVersion(version string)
	SetUseTLS(tls bool)
	AddAuth(auth AuthHandler)
	SetAddress(addr Address)
}

Data has miscancellous functions to change IRC info.

type Debugger

type Debugger interface {
	// Debug prints a debug message with fmt.Fprint
	Debug(parts ...interface{})
	// Debugln prints a debug message with fmt.Fprintln
	Debugln(parts ...interface{})
	// Debugf prints a debug message with fmt.Fprintf
	Debugf(msg string, args ...interface{})
	// Debugfln prints a debug message with fmt.Fprintf and appends \n
	Debugfln(msg string, args ...interface{})
	// SetDebugWriter changes the io.Writer to which debug data should be written to
	SetDebugWriter(writer io.Writer)
}

Debugger is something to send debug messages to

type ErrorStream

type ErrorStream interface {
	Errors() chan error
}

ErrorStream contains a function that returns a channel of non-lethal errors.

type Handler

type Handler func(evt *irc.Message)

Handler is an IRC event handler

type HandlerHandler

type HandlerHandler interface {
	// AddHandler adds the given handler to the given code and returns the handler index
	AddHandler(code string, handler Handler) int
	// GetHandlers gets all the handlers for the given code
	GetHandlers(code string) (handlers []Handler, ok bool)
	// RunHandlers runs the handlers for the given code with the given event
	RunHandlers(evt *irc.Message)
}

HandlerHandler is a handler that handles handlers

type IPv4Address

type IPv4Address struct {
	IP   string
	Port uint16
}

IPv4Address implements AddressHandler for IPv4 addresses and domain names

func (IPv4Address) String

func (addr IPv4Address) String() string

String turns IPv4 addresses into ip:port format

type IPv6Address

type IPv6Address struct {
	IP   string
	Port uint16
}

IPv6Address implements AddressHandler for IPv6 addresses

func (IPv6Address) String

func (addr IPv6Address) String() string

String turns IPv6 addresses into [ip]:port format

type NickServAuth

type NickServAuth struct {
	Password string
}

NickServAuth is an AuthHandler that authenticates with NickServ

func (*NickServAuth) Do

func (auth *NickServAuth) Do(c *ConnImpl)

Do - See AuthHandler interface docs

type PasswordAuth

type PasswordAuth struct {
	Password string
}

PasswordAuth is an AuthHandler that authenticates using the IRC PASS command

func (*PasswordAuth) Do

func (auth *PasswordAuth) Do(c *ConnImpl)

Do - See AuthHandler interface docs

type PreConnError

type PreConnError error

PreConnError is an error that happened berfore connecting to the server

var (
	ErrInvalidAddress PreConnError = errors.New("No address given")
	ErrInvalidNick    PreConnError = errors.New("No nick given")
	ErrInvalidUser    PreConnError = errors.New("No user given")
)

Pre-connection errors

type Tunnel

type Tunnel interface {
	// Send the given irc.Message
	Send(msg *irc.Message)
	// Action sends the given message to the given channel as a CTCP action message
	Action(channel, msg string)
	// Privmsg sends the given message to the given channel
	Privmsg(channel, msg string)
	// Notice sends the given message to the given channel as a NOTICE
	Notice(channel, msg string)
	// Away sets the away message
	Away(msg string)
	// RemoveAway removes the away status
	RemoveAway()
	// Invite the given user to the given channel
	Invite(user, ch string)
	// Kick the given user from the given channel with the given message
	Kick(ch, user, msg string)
	// Mode changes channel and user modes
	Mode(target, flags, args string)
	// Oper authenticates the user as a server operator
	Oper(username, password string)
	// SetNick updates the nick locally and sends a nick change request to the server
	SetNick(nick string)
	// Join a channel
	Join(chs, keys string)
	// Part a channel
	Part(ch, msg string)
	// List requests the server for a list of channels
	List()
	// Topic sets the topic of the given channel
	Topic(ch, topic string)
	// Whois sends a WHOIS request on the given name
	Whois(name string)
	// Whowas sends a WHOWAS request on the given name
	Whowas(name string)
	// Who sends a WHO request with the given name
	Who(name string, op bool)
	// Quit from the server
	Quit()
}

Tunnel contains functions to wrap IRC commands

Directories

Path Synopsis
You should have received a copy of the GNU General Public License along with this program.
You should have received a copy of the GNU General Public License along with this program.

Jump to

Keyboard shortcuts

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