state should never be nil

This commit is contained in:
Liam Stanley 2016-12-09 05:37:01 -05:00
parent 31f97aac8b
commit 2477ef33aa

11
main.go

@ -137,6 +137,9 @@ func New(config Config) *Client {
}
client.log = log.New(client.Config.Logger, "", log.Ldate|log.Ltime|log.Lshortfile)
// Give ourselves a new state.
client.state = newState()
// Register builtin helpers.
client.registerHelpers()
@ -153,10 +156,6 @@ func (c *Client) Quit(message string) {
c.Send(&Event{Command: QUIT, Trailing: message})
if c.state == nil {
return
}
if c.state.conn != nil {
c.state.conn.Close()
}
@ -358,10 +357,6 @@ func (c *Client) Reconnect() (err error) {
// IRC server. If there is an error, it calls Reconnect.
func (c *Client) readLoop() error {
for {
if c.state == nil {
return ErrNotConnected
}
if c.state.reconnecting || c.state.hasQuit {
return ErrNotConnected
}