mirror of https://github.com/velour/catbase.git
Compare commits
2 Commits
789409e159
...
fed1951e66
Author | SHA1 | Date |
---|---|---|
Chris Sexton | fed1951e66 | |
Chris Sexton | ac3d037fa4 |
|
@ -170,13 +170,13 @@ func (p *MemePlugin) sendMeme(c bot.Connector, channel, channelName, msgID strin
|
||||||
allConfigs := p.c.GetMap("meme.memeconfigs", map[string]string{})
|
allConfigs := p.c.GetMap("meme.memeconfigs", map[string]string{})
|
||||||
configtxt, ok := allConfigs[format]
|
configtxt, ok := allConfigs[format]
|
||||||
if !ok {
|
if !ok {
|
||||||
config = defaultFormatConfig
|
config = defaultFormatConfig()
|
||||||
log.Debug().Msgf("Did not find %s in %+v", format, allConfigs)
|
log.Debug().Msgf("Did not find %s in %+v", format, allConfigs)
|
||||||
} else {
|
} else {
|
||||||
err = json.Unmarshal([]byte(configtxt), &config)
|
err = json.Unmarshal([]byte(configtxt), &config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msgf("Could not parse config for %s:\n%s", format, configtxt)
|
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
|
return fontSize
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultFormatConfig = []memeText{
|
func defaultFormatConfig() []memeText {
|
||||||
{XPerc: 0.5, YPerc: 0.05},
|
return []memeText{
|
||||||
{XPerc: 0.5, YPerc: 0.95},
|
{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) {
|
func (p *MemePlugin) genMeme(meme string, bully image.Image, config []memeText) (string, int, int, error) {
|
||||||
|
@ -344,7 +346,9 @@ func (p *MemePlugin) genMeme(meme string, bully image.Image, config []memeText)
|
||||||
u, err := url.Parse(imgName)
|
u, err := url.Parse(imgName)
|
||||||
if err != nil || u.Scheme == "" {
|
if err != nil || u.Scheme == "" {
|
||||||
log.Debug().Err(err).Str("imgName", imgName).Msgf("url not detected")
|
log.Debug().Err(err).Str("imgName", imgName).Msgf("url not detected")
|
||||||
u, _ = url.Parse("https://imgflip.com/s/meme/" + imgName)
|
if u, err = url.Parse("https://imgflip.com/s/meme/" + imgName); err != nil {
|
||||||
|
return "", 0, 0, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().Msgf("Attempting to download url: %s", u.String())
|
log.Debug().Msgf("Attempting to download url: %s", u.String())
|
||||||
|
|
Loading…
Reference in New Issue