all repos — honk @ 79d3e5e0dba858ca533d38976328017a00dcfc57

my fork of honk

try another variation to find mentions
Ted Unangst tedu@tedunangst.com
Tue, 31 May 2022 01:07:27 -0400
commit

79d3e5e0dba858ca533d38976328017a00dcfc57

parent

7106d9354915c211967b578c3bdde8c31677f078

2 files changed, 8 insertions(+), 8 deletions(-)

jump to
M fun.gofun.go

@@ -124,7 +124,7 @@ h.Precis = demoji(h.Precis)

h.Noise = demoji(h.Noise) h.Open = "open" for _, m := range h.Mentions { - if !strings.Contains(h.Noise, m.Nick()) { + if !m.IsPresent(h.Noise) { h.Noise = "(" + m.Who + ")" + h.Noise } }
M honk.gohonk.go

@@ -23,7 +23,6 @@ golog "log"

"log/syslog" notrand "math/rand" "os" - "regexp" "strconv" "strings" "time"

@@ -136,13 +135,14 @@ Who string

Where string } -var re_firstname = regexp.MustCompile("@[[:alnum:]]+") - -func (mention *Mention) Nick() string { - if m := re_firstname.FindString(mention.Who); m != "" { - return m +func (mention *Mention) IsPresent(noise string) bool { + nick := strings.TrimLeft(mention.Who, "@") + idx := strings.IndexByte(nick, '@') + if idx != -1 { + nick = nick[:idx] } - return mention.Who + nick += "<" + return strings.Contains(noise, ">@"+nick) || strings.Contains(noise, "@<span>"+nick) } type OldRevision struct {