Fix discord formatting

Signed-off-by: jolheiser <john.olheiser@gmail.com>
master
jolheiser 2022-01-20 12:01:01 -06:00
parent 2a9cb41ec6
commit 6bc0967a65
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
1 changed files with 7 additions and 1 deletions

View File

@ -18,6 +18,12 @@ import (
"time" "time"
) )
var discordFmt = strings.NewReplacer(
"_", `\_`,
"*", `\*`,
"~", `\~`,
)
type Client struct { type Client struct {
discord *discordgo.Session discord *discordgo.Session
channelID string channelID string
@ -80,7 +86,7 @@ func (c *Client) sendChat(msg string) {
func (c *Client) onChatMsg(msg chat.Message, _ byte, _ uuid.UUID) error { func (c *Client) onChatMsg(msg chat.Message, _ byte, _ uuid.UUID) error {
if c.discord != nil { if c.discord != nil {
_, err := c.discord.ChannelMessageSend(c.channelID, msg.ClearString()) _, err := c.discord.ChannelMessageSend(c.channelID, discordFmt.Replace(msg.ClearString()))
return err return err
} }
log.Info().Msg(msg.String()) log.Info().Msg(msg.String())