From aac0efebee1a534bce27a5fd7183f1331edbb11c Mon Sep 17 00:00:00 2001 From: Jeremy Latt Date: Tue, 11 Feb 2014 14:32:17 -0800 Subject: [PATCH] send initial nick message to source client --- irc/channel.go | 4 ++-- irc/client.go | 4 ++-- irc/reply.go | 7 +++++-- irc/server.go | 6 ++++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/irc/channel.go b/irc/channel.go index 7a26e4a4..809a0df8 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -66,7 +66,7 @@ func (channel *Channel) Reply(reply Reply) error { func (channel *Channel) receiveCommands(commands <-chan ChannelCommand) { for command := range commands { if DEBUG_CHANNEL { - log.Printf("%s → %s : %s", command.Source(), channel, command) + log.Printf("%s → %s %s", command.Source(), channel, command) } command.HandleChannel(channel) } @@ -75,7 +75,7 @@ func (channel *Channel) receiveCommands(commands <-chan ChannelCommand) { func (channel *Channel) receiveReplies(replies <-chan Reply) { for reply := range replies { if DEBUG_CHANNEL { - log.Printf("%s ← %s : %s", channel, reply.Source(), reply) + log.Printf("%s ← %s %s", channel, reply.Source(), reply) } for client := range channel.members { if reply.Source() != Identifier(client) { diff --git a/irc/client.go b/irc/client.go index 309f3f6f..5ec2cdba 100644 --- a/irc/client.go +++ b/irc/client.go @@ -93,7 +93,7 @@ func (c *Client) readConn(recv <-chan string) { func (c *Client) writeConn(write chan<- string, replies <-chan Reply) { for reply := range replies { if DEBUG_CLIENT { - log.Printf("%s ← %s : %s", c, reply.Source(), reply) + log.Printf("%s ← %s %s", c, reply.Source(), reply) } reply.Format(c, write) } @@ -136,7 +136,7 @@ func (client *Client) InterestedClients() ClientSet { clients := make(ClientSet) for channel := range client.channels { for member := range channel.members { - clients[member] = true + clients.Add(member) } } return clients diff --git a/irc/reply.go b/irc/reply.go index 51f1008e..a1cf54f8 100644 --- a/irc/reply.go +++ b/irc/reply.go @@ -33,8 +33,11 @@ func NewStringReply(source Identifier, code string, message := fmt.Sprintf(format, args...) fullMessage := fmt.Sprintf(":%s %s %s", source.Id(), code, message) return &StringReply{ - BaseReply: &BaseReply{source, fullMessage}, - code: code, + BaseReply: &BaseReply{ + source: source, + message: fullMessage, + }, + code: code, } } diff --git a/irc/server.go b/irc/server.go index 576a8008..ae19faa1 100644 --- a/irc/server.go +++ b/irc/server.go @@ -48,7 +48,7 @@ func NewServer(config *Config) *Server { func (server *Server) receiveCommands(commands <-chan Command) { for command := range commands { if DEBUG_SERVER { - log.Printf("%s → %s : %s", command.Client(), server, command) + log.Printf("%s → %s %s", command.Client(), server, command) } client := command.Client() client.Touch() @@ -205,7 +205,9 @@ func (m *NickCommand) HandleServer(s *Server) { c.nick = m.nickname } reply := RplNick(c, m.nickname) - for iclient := range c.InterestedClients() { + iclients := c.InterestedClients() + iclients.Add(c) + for iclient := range iclients { iclient.Reply(reply) }