From c91fdcdf29581f89642add0755ee0c5368cfa7d9 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Wed, 2 Aug 2023 16:52:11 -0400 Subject: [PATCH] bot: add spoiler message type --- bot/interfaces.go | 2 ++ bot/mock.go | 3 +++ connectors/discord/discord.go | 3 +++ plugins/talker/talker.go | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bot/interfaces.go b/bot/interfaces.go index c574212..c238409 100644 --- a/bot/interfaces.go +++ b/bot/interfaces.go @@ -26,6 +26,8 @@ const ( Reply // Action any /me action Action + // Spoiler is for commented out messages + Spoiler // Reaction Icon reaction if service supports it Reaction // Edit message ref'd new message to replace diff --git a/bot/mock.go b/bot/mock.go index b1d7ae2..cab54c9 100644 --- a/bot/mock.go +++ b/bot/mock.go @@ -37,6 +37,9 @@ func (mb *MockBot) GetPassword() string { return "12345" } func (mb *MockBot) SetQuiet(bool) {} func (mb *MockBot) Send(c Connector, kind Kind, args ...any) (string, error) { switch kind { + case Spoiler: + mb.Messages = append(mb.Messages, "||"+args[1].(string)+"||") + return fmt.Sprintf("m-%d", len(mb.Actions)-1), nil case Message: mb.Messages = append(mb.Messages, args[1].(string)) return fmt.Sprintf("m-%d", len(mb.Actions)-1), nil diff --git a/connectors/discord/discord.go b/connectors/discord/discord.go index 8f1b3a1..66834a6 100644 --- a/connectors/discord/discord.go +++ b/connectors/discord/discord.go @@ -74,6 +74,9 @@ func (d Discord) Send(kind bot.Kind, args ...any) (string, error) { return d.sendMessage(args[0].(string), args[2].(string), false, args...) case bot.Message: return d.sendMessage(args[0].(string), args[1].(string), false, args...) + case bot.Spoiler: + outgoing := "||" + args[1].(string) + "||" + return d.sendMessage(args[0].(string), outgoing, false, args...) case bot.Action: return d.sendMessage(args[0].(string), args[1].(string), true, args...) case bot.Edit: diff --git a/plugins/talker/talker.go b/plugins/talker/talker.go index 5cba8a1..618e078 100644 --- a/plugins/talker/talker.go +++ b/plugins/talker/talker.go @@ -104,7 +104,7 @@ func (p *TalkerPlugin) message(c bot.Connector, kind bot.Kind, message msg.Messa line = strings.Replace(line, "{nick}", nick, 1) output += line + "\n" } - p.bot.Send(c, bot.Message, channel, output) + p.bot.Send(c, bot.Spoiler, channel, output) return true }