Documentation ¶
Index ¶
- Constants
- type Config
- type Conn
- func (conn *Conn) Action(t, msg string)
- func (conn *Conn) Away(message ...string)
- func (conn *Conn) Config() *Config
- func (conn *Conn) Connect() error
- func (conn *Conn) ConnectTo(host string, pass ...string) error
- func (conn *Conn) Connected() bool
- 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) Handle(name string, h Handler) Remover
- func (conn *Conn) HandleBG(name string, h Handler) Remover
- func (conn *Conn) HandleFunc(name string, hf HandlerFunc) Remover
- func (conn *Conn) Invite(nick, channel string)
- func (conn *Conn) Join(channel string, key ...string)
- func (conn *Conn) Kick(channel, nick string, message ...string)
- func (conn *Conn) LogPanic(line *Line)
- func (conn *Conn) Me() *state.Nick
- 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) Ping(message string)
- func (conn *Conn) Pong(message string)
- func (conn *Conn) Privmsg(t, msg string)
- func (conn *Conn) Quit(message ...string)
- func (conn *Conn) Raw(rawline string)
- func (conn *Conn) StateTracker() state.Tracker
- func (conn *Conn) String() string
- func (conn *Conn) Topic(channel string, topic ...string)
- func (conn *Conn) User(ident, name string)
- func (conn *Conn) VHost(user, pass string)
- func (conn *Conn) Version(t string)
- func (conn *Conn) Who(nick string)
- func (conn *Conn) Whois(nick string)
- type Handler
- type HandlerFunc
- type Line
- type Remover
Constants ¶
const ( REGISTER = "REGISTER" CONNECTED = "CONNECTED" DISCONNECTED = "DISCONNECTED" ACTION = "ACTION" AWAY = "AWAY" CTCP = "CTCP" CTCPREPLY = "CTCPREPLY" INVITE = "INVITE" JOIN = "JOIN" KICK = "KICK" MODE = "MODE" NICK = "NICK" NOTICE = "NOTICE" OPER = "OPER" PART = "PART" PASS = "PASS" PING = "PING" PONG = "PONG" PRIVMSG = "PRIVMSG" QUIT = "QUIT" TOPIC = "TOPIC" USER = "USER" VERSION = "VERSION" VHOST = "VHOST" WHO = "WHO" WHOIS = "WHOIS" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Set this to provide the Nick, Ident and Name for the client to use. Me *state.Nick // Hostname to connect to and optional connect password. Server, Pass string // Are we connecting via SSL? Do we care about certificate validity? SSL bool SSLConfig *tls.Config // Local address to connect to the server. LocalAddr string // Replaceable function to customise the 433 handler's new nick NewNick func(string) string // 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 // Sent as the reply to a CTCP VERSION message Version string // Sent as the QUIT message. QuitMessage string // Configurable panic recovery for all handlers. Recover func(*Conn, *Line) // Split PRIVMSGs, NOTICEs and CTCPs longer than // SplitLen characters over multiple lines. SplitLen int // Timeout, The amount of time in seconds until a timeout is triggered. Timeout time.Duration }
Misc knobs to tweak client behaviour go in here
type Conn ¶
type Conn struct {
// 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) Away ¶
Away() sends an AWAY command to the server
Away() resets away status Away(message) sets away with the given message
func (*Conn) ConnectTo ¶
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) Handle ¶
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) HandleFunc ¶
func (conn *Conn) HandleFunc(name string, hf HandlerFunc) Remover
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) Ping ¶
Ping() sends a PING command to the server A PONG response is to be expected afterwards
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) StateTracker ¶
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
type HandlerFunc ¶
A HandlerFunc implements Handler.
func (HandlerFunc) Handle ¶
func (hf HandlerFunc) Handle(conn *Conn, line *Line)
type Line ¶
We parse an incoming line into this struct. Line.Cmd is used as the trigger name for incoming event handlers, see *Conn.recv() for details.
Raw =~ ":nick!user@host cmd args[] :text" Src == "nick!user@host" Cmd == e.g. PRIVMSG, 332