diff --git a/bridge/discord.go b/bridge/discord.go index 9debefc..950cd15 100644 --- a/bridge/discord.go +++ b/bridge/discord.go @@ -89,6 +89,10 @@ func userToMention(u *discordgo.User) (mention string) { return } +// For spoiler colouring: +var spoilerPattern = regexp.MustCompile(`\|\|(.*?)\|\|`) +var colorCode = string(rune(3)) + func (d *discordBot) publishMessage(s *discordgo.Session, m *discordgo.Message, wasEdit bool) { // Fix crash if these fields don't exist if m.Author == nil || s.State.User == nil { @@ -148,6 +152,10 @@ func (d *discordBot) publishMessage(s *discordgo.Session, m *discordgo.Message, content = "[edit] " + content } + if strings.Count(content, "||") >= 2 { + content = spoilerPattern.ReplaceAllString(content, colorCode+"1,1$1"+colorCode) + } + pmTarget := "" // Blank guild means that it's a PM if m.GuildID == "" { diff --git a/bridge/irc_listener.go b/bridge/irc_listener.go index 329cfa9..13cbbb6 100644 --- a/bridge/irc_listener.go +++ b/bridge/irc_listener.go @@ -262,7 +262,7 @@ func (i *ircListener) OnPrivateMessage(e *irc.Event) { msg = "_" + msg + "_" } - msg = ircf.BlocksToMarkdown(ircf.Parse(ircf.StripColor(msg))) + msg = ircf.BlocksToMarkdown(ircf.Parse(msg)) go func(e *irc.Event) { i.bridge.discordMessagesChan <- IRCMessage{