From e1c4c8e8ccf7f1d5cda0928e4d5ef19fd06cba38 Mon Sep 17 00:00:00 2001 From: Jeremy Latt Date: Thu, 20 Feb 2014 20:08:32 -0800 Subject: [PATCH] don't send prefix on server-originated string coded replies --- irc/client.go | 4 ++-- irc/reply.go | 18 ++++++++---------- irc/server.go | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/irc/client.go b/irc/client.go index 2d7a5d0f..07c161f3 100644 --- a/irc/client.go +++ b/irc/client.go @@ -175,7 +175,7 @@ func (client *Client) Touch() { } func (client *Client) Idle() { - client.replies <- RplPing(client.server, client) + client.replies <- RplPing(client) if client.quitTimer == nil { client.quitTimer = time.AfterFunc(QUIT_TIMEOUT, client.connectionTimeout) @@ -304,7 +304,7 @@ func (client *Client) Quit(message string) { return } - client.replies <- RplError(client.server, "connection closed") + client.replies <- RplError("connection closed") client.replies <- EOF client.hasQuit = true diff --git a/irc/reply.go b/irc/reply.go index d315cb54..3d9a9d3a 100644 --- a/irc/reply.go +++ b/irc/reply.go @@ -9,11 +9,9 @@ import ( func NewStringReply(source Identifier, code StringCode, format string, args ...interface{}) string { var header string - switch source.(type) { - case *Server: - // TODO only omit prefix for local server + if source == nil { header = fmt.Sprintf("%s ", code) - default: + } else { header = fmt.Sprintf(":%s %s ", source, code) } message := fmt.Sprintf(format, args...) @@ -104,20 +102,20 @@ func RplTopicMsg(source Identifier, channel *Channel) string { return NewStringReply(source, TOPIC, "%s :%s", channel, channel.topic) } -func RplPing(server *Server, target Identifier) string { - return NewStringReply(server, PING, ":%s", target.Nick()) +func RplPing(target Identifier) string { + return NewStringReply(nil, PING, ":%s", target.Nick()) } -func RplPong(server *Server, client *Client) string { - return NewStringReply(server, PONG, client.Nick()) +func RplPong(client *Client) string { + return NewStringReply(nil, PONG, client.Nick()) } func RplQuit(client *Client, message string) string { return NewStringReply(client, QUIT, ":%s", message) } -func RplError(server *Server, message string) string { - return NewStringReply(server, ERROR, ":%s", message) +func RplError(message string) string { + return NewStringReply(nil, ERROR, ":%s", message) } func RplInviteMsg(channel *Channel, inviter *Client) string { diff --git a/irc/server.go b/irc/server.go index 05c1fb8f..0a7a8674 100644 --- a/irc/server.go +++ b/irc/server.go @@ -351,7 +351,7 @@ func (m *PassCommand) HandleServer(s *Server) { } func (m *PingCommand) HandleServer(s *Server) { - m.Client().replies <- RplPong(s, m.Client()) + m.Client().replies <- RplPong(m.Client()) } func (m *PongCommand) HandleServer(s *Server) {