From 4f7b3d1c84d0f13c5b6054de4120418590c8a159 Mon Sep 17 00:00:00 2001 From: Julian Daube Date: Sat, 20 Jun 2015 22:21:27 +0200 Subject: [PATCH 1/2] fixed a small bug which marks the connection alive to early --- irc.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/irc.go b/irc.go index 487a274..229fe61 100644 --- a/irc.go +++ b/irc.go @@ -326,7 +326,8 @@ func (irc *Connection) Reconnect() error { // RFC 1459 details: https://tools.ietf.org/html/rfc1459#section-4.1 func (irc *Connection) Connect(server string) error { irc.Server = server - irc.stopped = false + // mark Server as stopped since there can be an error during connect + irc.stopped = true // make sure everything is ready for connection if len(irc.Server) == 0 { @@ -369,6 +370,8 @@ func (irc *Connection) Connect(server string) error { if err != nil { return err } + + irc.stopped = false irc.Log.Printf("Connected to %s (%s)\n", irc.Server, irc.socket.RemoteAddr()) irc.pwrite = make(chan string, 10) From f9d88d1af185e520993b8a94edbb0ede9fc34226 Mon Sep 17 00:00:00 2001 From: Julian Daube Date: Sat, 20 Jun 2015 22:24:25 +0200 Subject: [PATCH 2/2] initialized .nickcurrent with .nick fixes empty return of Nick() directly after initialising --- irc.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/irc.go b/irc.go index 229fe61..56d7c07 100644 --- a/irc.go +++ b/irc.go @@ -401,14 +401,15 @@ func IRC(nick, user string) *Connection { } irc := &Connection{ - nick: nick, - user: user, - Log: log.New(os.Stdout, "", log.LstdFlags), - end: make(chan struct{}), - Version: VERSION, - KeepAlive: 4 * time.Minute, - Timeout: 1 * time.Minute, - PingFreq: 15 * time.Minute, + nick: nick, + nickcurrent: nick, + user: user, + Log: log.New(os.Stdout, "", log.LstdFlags), + end: make(chan struct{}), + Version: VERSION, + KeepAlive: 4 * time.Minute, + Timeout: 1 * time.Minute, + PingFreq: 15 * time.Minute, } irc.setupCallbacks() return irc