diff --git a/client.go b/client.go index 8089a27..ca83b05 100644 --- a/client.go +++ b/client.go @@ -157,6 +157,8 @@ var ErrNotConnected = errors.New("client is not connected to server") // ErrAlreadyConnecting implies that a connection attempt is already happening. var ErrAlreadyConnecting = errors.New("a connection attempt is already occurring") +// ErrDisconnected is called when Config.Retries is less than 1, and we +// non-intentionally disconnected from the server. var ErrDisconnected = errors.New("unexpectedly disconnected") // ErrInvalidTarget should be returned if the target which you are @@ -282,8 +284,8 @@ func (c *Client) connectMessages() (events []*Event) { return events } -// reconnect checks to make sure we want to, and then attempts to reconnect -// to the server. +// reconnect is the internal wrapper for reconnecting to the IRC server (if +// requested.) func (c *Client) reconnect(remoteInvoked bool) (err error) { if c.reconnecting { return ErrDisconnected @@ -323,7 +325,7 @@ func (c *Client) reconnect(remoteInvoked bool) (err error) { return err } -// reconnect checks to make sure we want to, and then attempts to reconnect +// Reconnect checks to make sure we want to, and then attempts to reconnect // to the server. This will ignore the reconnect delay. func (c *Client) Reconnect() error { return c.reconnect(true) @@ -370,7 +372,7 @@ func (c *Client) Quit() { c.quit(true) } -// Quit disconnects from the server with a given message. +// QuitWithMessage disconnects from the server with a given message. func (c *Client) QuitWithMessage(message string) { c.Send(&Event{Command: QUIT, Trailing: message}) c.quit(false) @@ -802,7 +804,7 @@ func (c *Client) Who(target string) error { return c.Send(&Event{Command: WHO, Params: []string{target, "%tcuhnr,2"}}) } -// Whois sends a WHOIS query to the server, targetted at a specific user. +// Whois sends a WHOIS query to the server, targeted at a specific user. // as WHOIS is a bit slower, you may want to use WHO for brief user info. func (c *Client) Whois(nick string) error { if !IsValidNick(nick) { @@ -879,7 +881,7 @@ func (c *Client) Back() error { return c.Send(&Event{Command: AWAY}) } -// LIST sends a LIST query to the server, which will list channels and topics. +// List sends a LIST query to the server, which will list channels and topics. // Supports multiple channels at once, in hopes it will reduce extensive // LIST queries to the server. Supply no channels to run a list against the // entire server (warning, that may mean LOTS of channels!) diff --git a/event.go b/event.go index ecf5020..0dc335b 100644 --- a/event.go +++ b/event.go @@ -124,6 +124,9 @@ func ParseEvent(raw string) (e *Event) { return e } +// Copy makes a deep copy of a given event, for use with allowing untrusted +// functions/handlers edit the event without causing potential issues with +// other handlers. func (e *Event) Copy() *Event { newEvent := &Event{} diff --git a/handler.go b/handler.go index 9966d67..ad9c27f 100644 --- a/handler.go +++ b/handler.go @@ -389,9 +389,9 @@ type HandlerError struct { func (e *HandlerError) Error() string { if e.callOk { return fmt.Sprintf("panic during handler [%s] execution in %s (line %d): %s", e.ID, e.File, e.Line, e.Panic) - } else { - return fmt.Sprintf("panic during handler [%s] execution in unknown: %s", e.ID, e.Panic) } + + return fmt.Sprintf("panic during handler [%s] execution in unknown: %s", e.ID, e.Panic) } // String returns the error that panic returned, as well as the entire call diff --git a/modes.go b/modes.go index 2eed7d3..ac4d187 100644 --- a/modes.go +++ b/modes.go @@ -383,7 +383,7 @@ type UserPerms struct { // ability to kick, without giving them greater abilities to ban all users. HalfOp bool // Voice indicates the user has voice permissions, commonly given to known - // users, wih very light trust, or to indicate a user is active. + // users, with very light trust, or to indicate a user is active. Voice bool } @@ -397,7 +397,7 @@ func (m UserPerms) IsAdmin() bool { return false } -// IsAdmin indicates that the user at least has modes set upon them, higher +// IsTrusted indicates that the user at least has modes set upon them, higher // than a regular joining user. func (m UserPerms) IsTrusted() bool { if m.IsAdmin() || m.HalfOp || m.Voice {