From f0c83dc012b0a5e3dcedd54f3bf87f3cdd19948f Mon Sep 17 00:00:00 2001 From: Luke Evers Date: Wed, 28 Oct 2015 08:58:41 -0400 Subject: [PATCH] Add support for specifying a quit message. --- irc.go | 9 ++++++++- irc_struct.go | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/irc.go b/irc.go index 2218a39..652f327 100644 --- a/irc.go +++ b/irc.go @@ -209,7 +209,13 @@ func (irc *Connection) Loop() { // Quit the current connection and disconnect from the server // RFC 1459 details: https://tools.ietf.org/html/rfc1459#section-4.1.6 func (irc *Connection) Quit() { - irc.SendRaw("QUIT") + quit := "QUIT" + + if irc.QuitMessage != "" { + quit = fmt.Sprintf("QUIT :%s", irc.QuitMessage) + } + + irc.SendRaw(quit) irc.stopped = true } @@ -463,6 +469,7 @@ func IRC(nick, user string) *Connection { KeepAlive: 4 * time.Minute, Timeout: 1 * time.Minute, PingFreq: 15 * time.Minute, + QuitMessage: "", } irc.setupCallbacks() return irc diff --git a/irc_struct.go b/irc_struct.go index e29f377..fbba0ce 100644 --- a/irc_struct.go +++ b/irc_struct.go @@ -35,6 +35,7 @@ type Connection struct { registered bool events map[string]map[string]func(*Event) + QuitMessage string lastMessage time.Time VerboseCallbackHandler bool