try another variation to find mentions
This commit is contained in:
parent
808925a449
commit
34cc516aa9
2
fun.go
2
fun.go
|
@ -124,7 +124,7 @@ func reverbolate(userid int64, honks []*Honk) {
|
||||||
h.Noise = demoji(h.Noise)
|
h.Noise = demoji(h.Noise)
|
||||||
h.Open = "open"
|
h.Open = "open"
|
||||||
for _, m := range h.Mentions {
|
for _, m := range h.Mentions {
|
||||||
if !strings.Contains(h.Noise, m.Nick()) {
|
if !m.IsPresent(h.Noise) {
|
||||||
h.Noise = "(" + m.Who + ")" + h.Noise
|
h.Noise = "(" + m.Who + ")" + h.Noise
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
honk.go
14
honk.go
|
@ -23,7 +23,6 @@ import (
|
||||||
"log/syslog"
|
"log/syslog"
|
||||||
notrand "math/rand"
|
notrand "math/rand"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -136,13 +135,14 @@ type Mention struct {
|
||||||
Where string
|
Where string
|
||||||
}
|
}
|
||||||
|
|
||||||
var re_firstname = regexp.MustCompile("@[[:alnum:]]+")
|
func (mention *Mention) IsPresent(noise string) bool {
|
||||||
|
nick := strings.TrimLeft(mention.Who, "@")
|
||||||
func (mention *Mention) Nick() string {
|
idx := strings.IndexByte(nick, '@')
|
||||||
if m := re_firstname.FindString(mention.Who); m != "" {
|
if idx != -1 {
|
||||||
return m
|
nick = nick[:idx]
|
||||||
}
|
}
|
||||||
return mention.Who
|
nick += "<"
|
||||||
|
return strings.Contains(noise, ">@"+nick) || strings.Contains(noise, "@<span>"+nick)
|
||||||
}
|
}
|
||||||
|
|
||||||
type OldRevision struct {
|
type OldRevision struct {
|
||||||
|
|
Loading…
Reference in New Issue