From 304c645043ae049260853634cb4d486167baef12 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Sun, 20 Jan 2019 20:29:31 +0100 Subject: [PATCH] handler: Fixed issue caused by trying to post empty post. Root cause is not found, but offending posts will be ignored. --- internal/bot/handler.go | 6 ++++++ internal/util/npc_test.go | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/internal/bot/handler.go b/internal/bot/handler.go index f357c00..e2f3408 100644 --- a/internal/bot/handler.go +++ b/internal/bot/handler.go @@ -96,6 +96,12 @@ func handler(event *irc.Event, client *irc.Client) { text = util.RemoveNPCAttribution(event.Text) } + // Do not dispatch empty messages. + if len(text) < 1 || len(nick) < 1 || len(kind) < 1 { + log.Println("Ignoring empty message from:", event.Nick) + break + } + // Dispatch it. bot.handlePost(channel.Name(), ChannelPost{ Account: account, diff --git a/internal/util/npc_test.go b/internal/util/npc_test.go index 1190f95..0aa1324 100644 --- a/internal/util/npc_test.go +++ b/internal/util/npc_test.go @@ -28,6 +28,10 @@ func TestRemoveNPCAttribution(t *testing.T) { Input: "((*Correction))", Output: "((*Correction))", }, + { + Input: "((Remove :01 goofs!*))", + Output: "((Remove :01 goofs!*))", + }, } for i, row := range table {