From ac3d037fa403206c639ffcfac876ca821362a4d0 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Fri, 23 Oct 2020 09:51:08 -0400 Subject: [PATCH] meme: fix default config --- plugins/meme/meme.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/meme/meme.go b/plugins/meme/meme.go index c0572fa..7cfa102 100644 --- a/plugins/meme/meme.go +++ b/plugins/meme/meme.go @@ -170,13 +170,13 @@ func (p *MemePlugin) sendMeme(c bot.Connector, channel, channelName, msgID strin allConfigs := p.c.GetMap("meme.memeconfigs", map[string]string{}) configtxt, ok := allConfigs[format] if !ok { - config = defaultFormatConfig + config = defaultFormatConfig() log.Debug().Msgf("Did not find %s in %+v", format, allConfigs) } else { err = json.Unmarshal([]byte(configtxt), &config) if err != nil { log.Error().Err(err).Msgf("Could not parse config for %s:\n%s", format, configtxt) - config = defaultFormatConfig + config = defaultFormatConfig() } } @@ -325,9 +325,11 @@ func (p *MemePlugin) findFontSize(config []memeText, w, h int, sizes []float64) return fontSize } -var defaultFormatConfig = []memeText{ - {XPerc: 0.5, YPerc: 0.05}, - {XPerc: 0.5, YPerc: 0.95}, +func defaultFormatConfig() []memeText { + return []memeText{ + {XPerc: 0.5, YPerc: 0.05}, + {XPerc: 0.5, YPerc: 0.95}, + } } func (p *MemePlugin) genMeme(meme string, bully image.Image, config []memeText) (string, int, int, error) {