Documentation ¶
Index ¶
- Constants
- func NewHandler(f Handler) event.Handler
- type Conn
- func (conn *Conn) Action(t, msg string)
- func (conn *Conn) AddHandler(name string, f Handler) event.Handler
- func (conn *Conn) Away(message ...string)
- func (conn *Conn) Connect(host string, pass ...string) error
- func (conn *Conn) Ctcp(t, ctcp string, arg ...string)
- func (conn *Conn) CtcpReply(t, ctcp string, arg ...string)
- func (conn *Conn) DisableStateTracking()
- func (conn *Conn) EnableStateTracking()
- func (conn *Conn) Invite(nick, channel string)
- func (conn *Conn) Join(channel string)
- func (conn *Conn) Kick(channel, nick string, message ...string)
- func (conn *Conn) Mode(t string, modestring ...string)
- func (conn *Conn) Nick(nick string)
- func (conn *Conn) Notice(t, msg string)
- func (conn *Conn) Oper(user, pass string)
- func (conn *Conn) Part(channel string, message ...string)
- func (conn *Conn) Pass(password string)
- func (conn *Conn) Privmsg(t, msg string)
- func (conn *Conn) Quit(message ...string)
- func (conn *Conn) Raw(rawline string)
- func (conn *Conn) String() string
- func (conn *Conn) Topic(channel string, topic ...string)
- func (conn *Conn) User(ident, name string)
- func (conn *Conn) Version(t string)
- func (conn *Conn) Who(nick string)
- func (conn *Conn) Whois(nick string)
- type Handler
- type Line
Constants ¶
const ( INIT = "init" CONNECTED = "connected" DISCONNECTED = "disconnected" )
Consts for unnamed events.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
type Conn struct { // Connection Hostname and Nickname Host string Me *state.Nick Network string // Replaceable function to customise the 433 handler's new nick NewNick func(string) string // Event handler registry and dispatcher ER event.EventRegistry ED event.EventDispatcher // State tracker for nicks and channels ST state.StateTracker // Use the State field to store external state that handlers might need. // Remember ... you might need locking for this ;-) State interface{} Connected bool // Misc knobs to tweak client behaviour: // Are we connecting via SSL? Do we care about certificate validity? SSL bool SSLConfig *tls.Config // Client->server ping frequency, in seconds. Defaults to 3m. PingFreq time.Duration // Set this to true to disable flood protection and false to re-enable Flood bool // contains filtered or unexported fields }
An IRC connection is represented by this struct.
func SimpleClient ¶
Creates a new IRC connection object, but doesn't connect to anything so that you can add event handlers to it. See AddHandler() for details.
func (*Conn) AddHandler ¶
AddHandler() adds an event handler for a specific IRC command.
Handlers are triggered on incoming Lines from the server, with the handler "name" being equivalent to Line.Cmd. Read the RFCs for details on what replies could come from the server. They'll generally be things like "PRIVMSG", "JOIN", etc. but all the numeric replies are left as ascii strings of digits like "332" (mainly because I really didn't feel like putting massive constant tables in).
func (*Conn) Away ¶
Away() sends an AWAY command to the server
Away() resets away status Away(message) sets away with the given message
func (*Conn) Connect ¶
Connect the IRC connection object to "host[:port]" which should be either a hostname or an IP address, with an optional port. To enable explicit SSL on the connection to the IRC server, set Conn.SSL to true before calling Connect(). The port will default to 6697 if ssl is enabled, and 6667 otherwise. You can also provide an optional connect password.
func (*Conn) CtcpReply ¶
CtcpReply() sends a generic CTCP reply to the target t with an optional argument
func (*Conn) DisableStateTracking ¶
func (conn *Conn) DisableStateTracking()
func (*Conn) EnableStateTracking ¶
func (conn *Conn) EnableStateTracking()
func (*Conn) Mode ¶
Mode() sends a MODE command to the server. This one can get complicated if we try to be too clever, so it's deliberately simple:
Mode(t) retrieves the user or channel modes for target t Mode(t, "modestring") sets user or channel modes for target t, where... modestring == e.g. "+o <nick>" or "+ntk <key>" or "-is"
This means you'll need to do your own mode work. It may be linked in with the state tracking and ChanMode/NickMode/ChanPrivs objects later...
func (*Conn) Raw ¶
Raw() sends a raw line to the server, should really only be used for debugging purposes but may well come in handy.
func (*Conn) String ¶
Dumps a load of information about the current state of the connection to a string for debugging state tracking and other such things.
func (*Conn) Topic ¶
Topic() sends a TOPIC command to the channel
Topic(channel) retrieves the current channel topic (see "332" handler) Topic(channel, topic) sets the topic for the channel