From 33b1e6c5827a26e9113534a3d412a96fa6cfc85d Mon Sep 17 00:00:00 2001 From: Jeremy Latt Date: Fri, 14 Feb 2014 19:35:25 -0800 Subject: [PATCH] simplify Replier --- irc/channel.go | 6 ++---- irc/client.go | 14 ++++++-------- irc/server.go | 9 ++++----- irc/types.go | 2 +- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/irc/channel.go b/irc/channel.go index 7fd9c1cd..55241f41 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -64,10 +64,8 @@ func (channel *Channel) Command(command ChannelCommand) { channel.commands <- command } -func (channel *Channel) Reply(replies ...Reply) { - for _, reply := range replies { - channel.replies <- reply - } +func (channel *Channel) Reply(reply Reply) { + channel.replies <- reply } func (channel *Channel) receiveCommands(commands <-chan ChannelCommand) { diff --git a/irc/client.go b/irc/client.go index 92886fa6..04b5bc1a 100644 --- a/irc/client.go +++ b/irc/client.go @@ -181,16 +181,14 @@ func (client *Client) Destroy() { } } -func (client *Client) Reply(replies ...Reply) { - for _, reply := range replies { - if client.replies == nil { - if DEBUG_CLIENT { - log.Printf("%s dropped %s", client, reply) - } - continue +func (client *Client) Reply(reply Reply) { + if client.replies == nil { + if DEBUG_CLIENT { + log.Printf("%s dropped %s", client, reply) } - client.replies <- reply + return } + client.replies <- reply } func (client *Client) HasNick() bool { diff --git a/irc/server.go b/irc/server.go index 04c54454..d6fe95f0 100644 --- a/irc/server.go +++ b/irc/server.go @@ -171,11 +171,10 @@ func (s *Server) tryRegister(c *Client) { if c.HasNick() && c.HasUsername() { c.phase = Normal c.loginTimer.Stop() - c.Reply( - RplWelcome(s, c), - RplYourHost(s), - RplCreated(s), - RplMyInfo(s)) + c.Reply(RplWelcome(s, c)) + c.Reply(RplYourHost(s)) + c.Reply(RplCreated(s)) + c.Reply(RplMyInfo(s)) s.MOTD(c) } } diff --git a/irc/types.go b/irc/types.go index 3f96dda1..ee45c137 100644 --- a/irc/types.go +++ b/irc/types.go @@ -125,7 +125,7 @@ type Identifier interface { } type Replier interface { - Reply(...Reply) + Reply(Reply) } type Reply interface {