filter on image desc too

This commit is contained in:
Ted Unangst 2019-09-21 10:24:38 -04:00
parent d21f39d0e5
commit d97d815dae
1 changed files with 16 additions and 2 deletions

18
fun.go
View File

@ -71,7 +71,7 @@ func reverbolate(userid int64, honks []*Honk) {
h.Precis = unpucker(h.Precis)
h.Noise = unpucker(h.Noise)
h.Open = "open"
if badword := unsee(zilences, h.Precis, h.Noise); badword != "" {
if badword := unsee(zilences, h.Precis, h.Noise, h.Donks); badword != "" {
if h.Precis == "" {
h.Precis = badword
}
@ -142,7 +142,7 @@ func translate(honk *Honk) {
honk.Onts = oneofakind(ontologies(honk.Noise))
}
func unsee(zilences []*regexp.Regexp, precis string, noise string) string {
func unsee(zilences []*regexp.Regexp, precis string, noise string, donks []*Donk) string {
for _, z := range zilences {
if z.MatchString(precis) || z.MatchString(noise) {
if precis == "" {
@ -151,6 +151,15 @@ func unsee(zilences []*regexp.Regexp, precis string, noise string) string {
}
return precis
}
for _, d := range donks {
if z.MatchString(d.Desc) {
if precis == "" {
w := z.String()
return w[6 : len(w)-3]
}
return precis
}
}
}
return ""
}
@ -164,6 +173,11 @@ outer:
if z.MatchString(h.Precis) || z.MatchString(h.Noise) {
continue outer
}
for _, d := range h.Donks {
if z.MatchString(d.Desc) {
continue outer
}
}
}
honks[j] = h
j++