Add support for specifying a quit message.

This commit is contained in:
Luke Evers 2015-10-28 08:58:41 -04:00
parent 988aaaacd9
commit f0c83dc012
2 changed files with 9 additions and 1 deletions

9
irc.go
View File

@ -209,7 +209,13 @@ func (irc *Connection) Loop() {
// Quit the current connection and disconnect from the server // Quit the current connection and disconnect from the server
// RFC 1459 details: https://tools.ietf.org/html/rfc1459#section-4.1.6 // RFC 1459 details: https://tools.ietf.org/html/rfc1459#section-4.1.6
func (irc *Connection) Quit() { 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 irc.stopped = true
} }
@ -463,6 +469,7 @@ func IRC(nick, user string) *Connection {
KeepAlive: 4 * time.Minute, KeepAlive: 4 * time.Minute,
Timeout: 1 * time.Minute, Timeout: 1 * time.Minute,
PingFreq: 15 * time.Minute, PingFreq: 15 * time.Minute,
QuitMessage: "",
} }
irc.setupCallbacks() irc.setupCallbacks()
return irc return irc

View File

@ -35,6 +35,7 @@ type Connection struct {
registered bool registered bool
events map[string]map[string]func(*Event) events map[string]map[string]func(*Event)
QuitMessage string
lastMessage time.Time lastMessage time.Time
VerboseCallbackHandler bool VerboseCallbackHandler bool