all repos — honk @ 95a9708de43dfd6cf3f303512d360d8fb1a2a116

my fork of honk

mixed case hashtag complicates things a bit
Ted Unangst tedu@tedunangst.com
Sun, 30 Jul 2023 21:01:45 -0400
commit

95a9708de43dfd6cf3f303512d360d8fb1a2a116

parent

bb2858566ad9131d76f9e0bc3048df3b72def8b6

1 files changed, 23 insertions(+), 2 deletions(-)

jump to
M honk.gohonk.go

@@ -145,8 +145,29 @@ return strings.Contains(noise, ">@"+nick) || strings.Contains(noise, "@<span>"+nick)

} func OntIsPresent(ont, noise string) bool { - ont = ont[1:] - return strings.Contains(noise, ">#"+ont) || strings.Contains(noise, "#<span>"+ont) + ont = strings.ToLower(ont[1:] + "<") + idx := strings.IndexByte(noise, '#') + for idx >= 0 { + if strings.HasPrefix(noise[idx:], "#<span>") { + idx += 5 + } else { + idx += 1 + } + if idx + len(ont) + 1 > len(noise) { + return false + } + test := noise[idx:idx+len(ont)] + test = strings.ToLower(test) + if test == ont { + return true + } + newidx := strings.IndexByte(noise[idx:], '#') + if newidx == -1 { + return false + } + idx += newidx + } + return false } type OldRevision struct {