From 808925a4490d10b7a72324b9ac3f8c7e9c2f7c83 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 31 May 2022 00:24:02 -0400 Subject: [PATCH] readd invisible mentions --- fun.go | 5 +++++ honk.go | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/fun.go b/fun.go index d46d1c0..3dafe4b 100644 --- a/fun.go +++ b/fun.go @@ -123,6 +123,11 @@ func reverbolate(userid int64, honks []*Honk) { 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()) { + h.Noise = "(" + m.Who + ")" + h.Noise + } + } zap := make(map[string]bool) { diff --git a/honk.go b/honk.go index 67cb6b6..be40d57 100644 --- a/honk.go +++ b/honk.go @@ -23,6 +23,7 @@ import ( "log/syslog" notrand "math/rand" "os" + "regexp" "strconv" "strings" "time" @@ -135,6 +136,15 @@ type Mention struct { Where string } +var re_firstname = regexp.MustCompile("@[[:alnum:]]+") + +func (mention *Mention) Nick() string { + if m := re_firstname.FindString(mention.Who); m != "" { + return m + } + return mention.Who +} + type OldRevision struct { Precis string Noise string