From 02da8c739afa1c03305830c5d64ae4e56da35476 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sat, 13 Apr 2019 12:32:24 -0400 Subject: [PATCH] better herding of emus --- activity.go | 3 +++ honk.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/activity.go b/activity.go index 52fba2b..3abad20 100644 --- a/activity.go +++ b/activity.go @@ -575,6 +575,9 @@ func jonkjonk(user *WhatAbout, h *Honk) (map[string]interface{}, map[string]inte } var atts []interface{} for _, d := range h.Donks { + if re_emus.MatchString(d.Name) { + continue + } jd := NewJunk() jd["mediaType"] = d.Media jd["name"] = d.Name diff --git a/honk.go b/honk.go index cec4be4..c265b60 100644 --- a/honk.go +++ b/honk.go @@ -170,7 +170,9 @@ func reverbolate(honks []*Honk) { h.HTML = template.HTML(re_emus.ReplaceAllStringFunc(string(h.HTML), emuxifier)) for i := 0; i < len(h.Donks); i++ { if zap[h.Donks[i]] { - h.Donks = append(h.Donks[0:i], h.Donks[i+1:]...) + copy(h.Donks[i:], h.Donks[i+1:]) + h.Donks = h.Donks[:len(h.Donks)-1] + i-- } } } @@ -824,6 +826,7 @@ var re_emus = regexp.MustCompile(`:[[:alnum:]_]+:`) func herdofemus(noise string) []Emu { m := re_emus.FindAllString(noise, -1) + m = oneofakind(m) var emus []Emu for _, e := range m { fname := e[1 : len(e)-1]