From 74dea681581622d0294ea501af899dc99bf5351e Mon Sep 17 00:00:00 2001 From: Chris Rhodes Date: Sun, 17 Feb 2013 22:28:22 -0800 Subject: [PATCH] Moved QUIT and VERSION messages into the config. --- client/commands.go | 2 +- client/connection.go | 8 ++++++++ client/handlers.go | 16 ++++++++-------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/client/commands.go b/client/commands.go index 870b6a1..a47c687 100644 --- a/client/commands.go +++ b/client/commands.go @@ -49,7 +49,7 @@ func (conn *Conn) Kick(channel, nick string, message ...string) { func (conn *Conn) Quit(message ...string) { msg := strings.Join(message, " ") if msg == "" { - msg = "GoBye!" + msg = conn.cfg.QuitMessage } conn.out <- "QUIT :" + msg } diff --git a/client/connection.go b/client/connection.go index 1e074a9..30be2b9 100644 --- a/client/connection.go +++ b/client/connection.go @@ -66,6 +66,12 @@ type Config struct { // Set this to true to disable flood protection and false to re-enable Flood bool + + // Sent as the reply to a CTCP VERSION message + Version string + + // Sent as the QUIT message. + QuitMessage string } func NewConfig(nick string, args ...string) *Config { @@ -82,6 +88,8 @@ func NewConfig(nick string, args ...string) *Config { if len(args) > 1 && args[1] != "" { cfg.Me.Name = args[1] } + cfg.Version = "Powered by GoIRC" + cfg.QuitMessage = "GoBye!" return cfg } diff --git a/client/handlers.go b/client/handlers.go index 2e0d816..4efea47 100644 --- a/client/handlers.go +++ b/client/handlers.go @@ -8,19 +8,19 @@ import ( ) const ( - REGISTER = "REGISTER" - CONNECTED = "CONNECTED" + REGISTER = "REGISTER" + CONNECTED = "CONNECTED" DISCONNECTED = "DISCONNECTED" ) // sets up the internal event handlers to do essential IRC protocol things var intHandlers = map[string]HandlerFunc{ REGISTER: (*Conn).h_REGISTER, - "001": (*Conn).h_001, - "433": (*Conn).h_433, - "CTCP": (*Conn).h_CTCP, - "NICK": (*Conn).h_NICK, - "PING": (*Conn).h_PING, + "001": (*Conn).h_001, + "433": (*Conn).h_433, + "CTCP": (*Conn).h_CTCP, + "NICK": (*Conn).h_NICK, + "PING": (*Conn).h_PING, } func (conn *Conn) addIntHandlers() { @@ -87,7 +87,7 @@ func (conn *Conn) h_433(line *Line) { // Handle VERSION requests and CTCP PING func (conn *Conn) h_CTCP(line *Line) { if line.Args[0] == "VERSION" { - conn.CtcpReply(line.Nick, "VERSION", "powered by goirc...") + conn.CtcpReply(line.Nick, "VERSION", conn.cfg.Version) } else if line.Args[0] == "PING" { conn.CtcpReply(line.Nick, "PING", line.Args[2]) }