From a17c816540536e84c1646c9d0383f8461649c1e0 Mon Sep 17 00:00:00 2001 From: "." <.@.> Date: Thu, 5 May 2016 19:57:31 +1200 Subject: [PATCH] don't double-echo our own messages --HG-- branch : nmdc-ircfrontend --- server.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index e42143e..f26ca42 100644 --- a/server.go +++ b/server.go @@ -38,6 +38,8 @@ type Server struct { upstreamLauncher libnmdc.HubConnectionOptions upstreamCloser chan struct{} upstream *libnmdc.HubConnection + + lastMessage string // FIXME racey } func NewServer(name string, upstream libnmdc.HubAddress, conn net.Conn) *Server { @@ -142,7 +144,11 @@ func (s *Server) upstreamWorker() { s.reply(rplMsg, s.upstreamLauncher.Self.Nick, hubEvent.Nick, hubEvent.Message) case libnmdc.EVENT_PUBLIC: - s.reply(rplMsg, s.upstreamLauncher.Self.Nick, BLESSED_CHANNEL, hubEvent.Message) + if hubEvent.Nick == s.upstreamLauncher.Self.Nick && hubEvent.Message == s.lastMessage { + s.lastMessage = "" // irc doesn't echo our own pubchat + } else { + s.reply(rplMsg, hubEvent.Nick, BLESSED_CHANNEL, hubEvent.Message) + } case libnmdc.EVENT_SYSTEM_MESSAGE_FROM_CONN, libnmdc.EVENT_SYSTEM_MESSAGE_FROM_HUB: s.sendClientGlobalMessage(hubEvent.Message) @@ -256,7 +262,8 @@ func (s *Server) handleRegisteredCommand(command string, args []string) { // channel name, but not really for user nicks if strings.ToLower(args[0]) == BLESSED_CHANNEL { - s.upstream.SayPublic(message) + s.lastMessage = message + s.upstream.SayPublic(s.lastMessage) } else if _, clientExists := s.upstream.Users[args[0]]; clientExists { s.upstream.SayPrivate(args[0], message)