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 ¶
- Variables
- type Address
- type AuthHandler
- type ConnImpl
- func (c *ConnImpl) Action(channel, msg string)
- func (c *ConnImpl) AddAuth(auth AuthHandler)
- func (c *ConnImpl) AddHandler(code string, handler Handler) int
- func (c *ConnImpl) AddStdHandlers()
- func (c *ConnImpl) Away(msg string)
- func (c *ConnImpl) Connect() error
- func (c *ConnImpl) Connected() bool
- func (c *ConnImpl) Debug(parts ...interface{})
- func (c *ConnImpl) Debugf(msg string, args ...interface{})
- func (c *ConnImpl) Debugfln(msg string, args ...interface{})
- func (c *ConnImpl) Debugln(parts ...interface{})
- func (c *ConnImpl) Disconnect()
- func (c *ConnImpl) Errors() chan error
- func (c *ConnImpl) GetHandlers(code string) (handlers []Handler, ok bool)
- func (c *ConnImpl) GetNick() string
- func (c *ConnImpl) GetPreferredNick() string
- func (c *ConnImpl) Invite(user, ch string)
- func (c *ConnImpl) Join(chs string, keys string)
- func (c *ConnImpl) Kick(ch, user, msg string)
- func (c *ConnImpl) List()
- func (c *ConnImpl) LocalAddr() net.Addr
- func (c *ConnImpl) Loop()
- func (c *ConnImpl) Mode(target, flags, args string)
- func (c *ConnImpl) Notice(channel, msg string)
- func (c *ConnImpl) Oper(username, password string)
- func (c *ConnImpl) Part(ch, msg string)
- func (c *ConnImpl) Ping()
- func (c *ConnImpl) Pong(msg string)
- func (c *ConnImpl) Privmsg(channel, msg string)
- func (c *ConnImpl) Quit()
- func (c *ConnImpl) RemoveAway()
- func (c *ConnImpl) RemoveHandler(code string, index int)
- func (c *ConnImpl) RunHandlers(evt *irc.Message)
- func (c *ConnImpl) Send(msg *irc.Message)
- func (c *ConnImpl) SendUser()
- func (c *ConnImpl) SetAddress(addr Address)
- func (c *ConnImpl) SetDebugWriter(writer io.Writer)
- func (c *ConnImpl) SetNick(nick string)
- func (c *ConnImpl) SetQuitMessage(msg string)
- func (c *ConnImpl) SetRealName(realname string)
- func (c *ConnImpl) SetUseTLS(tls bool)
- func (c *ConnImpl) SetVersion(version string)
- func (c *ConnImpl) Topic(ch, topic string)
- func (c *ConnImpl) Who(name string, op bool)
- func (c *ConnImpl) Whois(name string)
- func (c *ConnImpl) Whowas(name string)
- type Connectable
- type Connection
- type ConnectionError
- type Data
- type Debugger
- type ErrorStream
- type Handler
- type HandlerHandler
- type IPv4Address
- type IPv6Address
- type NickServAuth
- type PasswordAuth
- type PreConnError
- type Tunnel
Constants ¶
This section is empty.
Variables ¶
var ErrDisconnected = errors.New("Disconnected")
ErrDisconnected is given when the client disconnects
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) AddAuth ¶
func (c *ConnImpl) AddAuth(auth AuthHandler)
AddAuth - see Data interface docs
func (*ConnImpl) AddHandler ¶
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) Debug ¶
func (c *ConnImpl) Debug(parts ...interface{})
Debug - 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) GetHandlers ¶
GetHandlers gets all handlers with the given code.
func (*ConnImpl) GetPreferredNick ¶
GetPreferredNick - see Data interface docs
func (*ConnImpl) Ping ¶
func (c *ConnImpl) Ping()
Ping the IRC server Ping - See Tunnel interface docs
func (*ConnImpl) RemoveAway ¶
func (c *ConnImpl) RemoveAway()
RemoveAway - See Tunnel interface docs
func (*ConnImpl) RemoveHandler ¶
RemoveHandler removes the handler with the given index.
func (*ConnImpl) RunHandlers ¶
RunHandlers runs handlers for the given irc message.
func (*ConnImpl) SendUser ¶
func (c *ConnImpl) SendUser()
SendUser sends the USER message to the server SendUser - See Tunnel interface docs
func (*ConnImpl) SetAddress ¶
SetAddress - see Data interface docs
func (*ConnImpl) SetDebugWriter ¶
SetDebugWriter - see Debugger interface docs
func (*ConnImpl) SetQuitMessage ¶
SetQuitMessage - see Data interface docs
func (*ConnImpl) SetRealName ¶
SetRealName - see Data interface docs
func (*ConnImpl) SetVersion ¶
SetVersion - see Data 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 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 ¶
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 ¶
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