From 470109461ba79cd37e16f364d31c937fa6d8004d Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Sun, 4 Feb 2018 21:34:44 +1000 Subject: [PATCH] responsebuffer: Handle sending early properly --- irc/responsebuffer.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/irc/responsebuffer.go b/irc/responsebuffer.go index 29de865b..d877a797 100644 --- a/irc/responsebuffer.go +++ b/irc/responsebuffer.go @@ -75,6 +75,11 @@ func (rb *ResponseBuffer) AddSplitMessageFromClient(msgid string, from *Client, // Send sends the message to our target client. func (rb *ResponseBuffer) Send() error { + // fall out if no messages to send + if len(rb.messages) == 0 { + return + } + // make batch and all if required var batch *Batch useLabel := rb.target.capabilities.Has(caps.LabeledResponse) && rb.Label != "" @@ -116,5 +121,8 @@ func (rb *ResponseBuffer) Send() error { batch.End(rb.target) } + // clear out any existing messages + rb.messages = []ircmsg.IrcMessage{} + return nil }