Add support for gif emus
This commit is contained in:
parent
093eb20aee
commit
cbeb18b3e7
|
@ -1166,7 +1166,7 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
|
|||
t["name"] = e.Name
|
||||
i := junk.New()
|
||||
i["type"] = "Image"
|
||||
i["mediaType"] = "image/png"
|
||||
i["mediaType"] = e.Type
|
||||
i["url"] = e.ID
|
||||
t["icon"] = i
|
||||
tags = append(tags, t)
|
||||
|
@ -1339,7 +1339,7 @@ func chonkifymsg(user *WhatAbout, ch *Chonk) []byte {
|
|||
t["name"] = e.Name
|
||||
i := junk.New()
|
||||
i["type"] = "Image"
|
||||
i["mediaType"] = "image/png"
|
||||
i["mediaType"] = e.Type
|
||||
i["url"] = e.ID
|
||||
t["icon"] = i
|
||||
tags = append(tags, t)
|
||||
|
|
|
@ -102,7 +102,7 @@ Image and video files are supported.
|
|||
Add custom emus (emoji) to the
|
||||
.Pa emus
|
||||
data directory.
|
||||
PNG files are supported.
|
||||
PNG and GIF files are supported.
|
||||
.Pp
|
||||
Site CSS may be overridden by creating a
|
||||
.Pa views/local.css
|
||||
|
|
13
fun.go
13
fun.go
|
@ -378,18 +378,23 @@ func bunchofgrapes(m []string) []Mention {
|
|||
type Emu struct {
|
||||
ID string
|
||||
Name string
|
||||
Type string
|
||||
}
|
||||
|
||||
var re_emus = regexp.MustCompile(`:[[:alnum:]_-]+:`)
|
||||
|
||||
var emucache = cache.New(cache.Options{Filler: func(ename string) (Emu, bool) {
|
||||
fname := ename[1 : len(ename)-1]
|
||||
_, err := os.Stat(dataDir + "/emus/" + fname + ".png")
|
||||
exts := []string{".png", ".gif"}
|
||||
for _, ext := range exts {
|
||||
_, err := os.Stat(dataDir + "/emus/" + fname + ext)
|
||||
if err != nil {
|
||||
return Emu{Name: ename, ID: ""}, true
|
||||
continue
|
||||
}
|
||||
url := fmt.Sprintf("https://%s/emu/%s.png", serverName, fname)
|
||||
return Emu{ID: url, Name: ename}, true
|
||||
url := fmt.Sprintf("https://%s/emu/%s%s", serverName, fname, ext)
|
||||
return Emu{ID: url, Name: ename, Type: "image/" + ext[1:]}, true
|
||||
}
|
||||
return Emu{Name: ename, ID: "", Type: "image/png"}, true
|
||||
}, Duration: 10 * time.Second})
|
||||
|
||||
func herdofemus(noise string) []Emu {
|
||||
|
|
Loading…
Reference in New Issue