Documentation ¶
Index ¶
- type IRC
- func (i *IRC) Auth() error
- func (i *IRC) Connect() error
- func (i *IRC) Handshake() error
- func (i *IRC) ID() error
- func (i *IRC) Join(channel, pass string) error
- func (i *IRC) PrintfLine(f string, args ...interface{}) error
- func (i *IRC) Privmsg(msg, target string) error
- func (i *IRC) PrivmsgSize(target string) int
- func (i *IRC) Quit(msg string) error
- func (i *IRC) SNick() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IRC ¶
type IRC struct { C <-chan string /* Messages from the server are sent here */ E <-chan error /* Receives an error before close(C) */ S net.Conn /* Represents the connection to the server */ Msglen int /* Size of an IRC message */ Default string /* Default target for privmsgs */ /* Configs and defauls. These may be changed at any time. */ Host string /* Host to which to connect */ Port uint16 /* Port to which to connect */ Ssl bool /* True to use SSL/TLS */ Hostname string /* Hostname to verify on server's certificate */ Nick string /* For NICK */ Username string /* For USER */ Realname string /* For USER */ IdNick string /* To auth to NickServ */ IdPass string /* To auth to NickServ */ Channel string /* For JOIN */ Chanpass string /* For JOIN */ Txp string /* Prefix for logging sent messages */ Rxp string /* Prefix for logging received messages */ Pongs bool /* Automatic ping responses */ RandomNumbers bool /* Append random numbers to the nick */ QuitMessage string /* Message to send when the client QUITs */ // contains filtered or unexported fields }
IRC represents a connection to an IRC server via OpenSSL
func New ¶
New allocates, initializes, and returns a pointer to a new IRC struct. hostname will be ignored if ssl is false, or assumed to be the same as host if it is the empty string and ssl is true.
func (*IRC) Auth ¶
Auth authenticates to NickServ with the values in i. If either i.IdNick or i.IdPass are the empty string, this is a no-op.
func (*IRC) Connect ¶
Connect connects to the server, and calls Handshake(). After connect returns, messages sent by the IRC server will be available on i.C. If i.Rxp is set, received messages from the server will be logged via log.Printf prefixed by i.Rxp, separated by a space. If an error is encountered reading messages from the IRC server, i.C will be closed and the error will be sent on i.E. i.S represents the connection to the server.
func (*IRC) Handshake ¶
Handshake is a shorthand for ID, Auth, and Join, in that order, using the values in i.
func (*IRC) ID ¶
ID sets the nick and user from the values in i, and sends a NICK command without any parameters (to get an easy-to-parse response with the nick as the server knows it). If i.Nick, i.Username or i.Realname are the empty string, this is a no-op.
func (*IRC) Join ¶
Join joins the channel with the optional password (which may be the empty string). If the channel is the empty string, the value from i.Channel and i.Chanpass will be used. If channel and i.Channel are both the empty string, this is a no-op.
func (*IRC) PrintfLine ¶
PrintfLine sends the formatted string to the IRC server. The message should be a raw IRC protocol message (like WHOIS or CAP). It is not wrapped in PRIVMSG or anything else. For PRIVMSGs, see Privmsg .If i.Txp is not the empty string, successfully sent lines will be logged via log.Printf() prefixed by i.Txp, separated by a space. Note that all the functions used to send protocol messages use PrintfLine.
func (*IRC) Privmsg ¶
Privmsg sends a PRIVMSG to the target, which may be a nick or a channel. If the target is an empty string, the message will be sent to i.Target, unless that is also an empty string, in which case nothing is sent.
func (*IRC) PrivmsgSize ¶
PrivmsgSize returns the length of the message that can be shoved into a PRIVMSG to the target. i.Msglen may be changed to override the default size of an IRC message (467 bytes, determined experimentally on freenode, 510 should be it, though). See Privmsg for the meaning of target.
func (*IRC) Quit ¶
Quit sends a QUIT command to the IRC server, with the optional msg as the quit message and closes the connection if the send succeeds. If msg is the empty string, i.QuitMessage will be used, unless it's also the empty string, in which case no message is sent with the QUIT command.
func (*IRC) SNick ¶
Nick returns a guess as to what the server thinks the nick is. This is handy for servers that truncate nicks when RandomNumbers is true. This is, however, only a guess (albiet a good one). It should be called after setting the nick with Nick() or Handshake(). Note this is based on passive inspection of received messagess, which requires reading due to the read channel being unbuffered. */