diff --git a/plugins/meme/meme.go b/plugins/meme/meme.go index 9b8eff1..6b39bd9 100644 --- a/plugins/meme/meme.go +++ b/plugins/meme/meme.go @@ -41,7 +41,7 @@ type cachedImage struct { type memeText struct { XPerc float64 `json:"x"` YPerc float64 `json:"y"` - Text string `json:"t"` + Text string `json:"t",omitempty` Caps bool `json:"c"` } @@ -335,6 +335,11 @@ func defaultFormatConfig() []memeText { } } +func defaultFormatConfigJSON() string { + c, _ := json.Marshal(defaultFormatConfig()) + return string(c) +} + func (p *MemePlugin) genMeme(meme string, bully image.Image, config []memeText) (string, int, int, error) { fontSizes := []float64{48, 36, 24, 16, 12} formats := p.c.GetMap("meme.memes", defaultFormats) diff --git a/plugins/meme/webHandlers.go b/plugins/meme/webHandlers.go index 94e7df3..faa222e 100644 --- a/plugins/meme/webHandlers.go +++ b/plugins/meme/webHandlers.go @@ -122,6 +122,10 @@ func (p *MemePlugin) addMeme(w http.ResponseWriter, r *http.Request) { formats[values.Name] = values.URL err = p.c.SetMap("meme.memes", formats) checkError(err) + + if values.Config == "" { + values.Config = defaultFormatConfigJSON() + } configs := p.c.GetMap("meme.memeconfigs", map[string]string{}) configs[values.Name] = values.Config err = p.c.SetMap("meme.memeconfigs", configs)