From 42d8dc3619ada5efc4627227f44b4b6e4f7039a0 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 17 Jan 2021 19:05:57 -0500 Subject: [PATCH] i tried parsing regex and now i have three problems. just fix the hashtag case instead of thinking. --- docs/changelog.txt | 2 +- hfcs.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 07608bd..cea14ca 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -4,7 +4,7 @@ changelog + Fix mastodon import. -+ Better regex for filters. ++ Filters work better with hashtags. + Fix hoot to work with Twitter's latest crap. diff --git a/hfcs.go b/hfcs.go index 6d631e1..5584d19 100644 --- a/hfcs.go +++ b/hfcs.go @@ -21,7 +21,6 @@ import ( "regexp" "sort" "time" - "unicode" "humungus.tedunangst.com/r/webs/cache" ) @@ -110,8 +109,8 @@ func filtcachefiller(userid int64) (afiltermap, bool) { } } if t := filt.Text; t != "" { - wordfront := unicode.IsLetter(rune(t[0])) - wordtail := unicode.IsLetter(rune(t[len(t)-1])) + wordfront := t[0] != '#' + wordtail := true t = "(?i:" + t + ")" if wordfront { t = "\\b" + t @@ -126,8 +125,8 @@ func filtcachefiller(userid int64) (afiltermap, bool) { } } if t := filt.Rewrite; t != "" { - wordfront := unicode.IsLetter(rune(t[0])) - wordtail := unicode.IsLetter(rune(t[len(t)-1])) + wordfront := t[0] != '#' + wordtail := true t = "(?i:" + t + ")" if wordfront { t = "\\b" + t