+16
-1
app/feeds/linux_feed.rb
+16
-1
app/feeds/linux_feed.rb
···
13
13
/the linux of/i, /linux (bros|nerds)/i, /ubuntu tv/i
14
14
]
15
15
16
+
LINK_EXCLUDES = [
17
+
/\bamzn\.to\b/i, /\bwww\.amazon\.com\b/i, /\bmercadolivre\.com\b/i,
18
+
]
19
+
16
20
MUTED_PROFILES = [
17
21
'did:plc:35c6qworuvguvwnpjwfq3b5p', # Linux Kernel Releases
18
22
'did:plc:ppuqidjyabv5iwzeoxt4fq5o', # GitHub Trending JS/TS
···
40
44
def post_matches?(post)
41
45
return false if MUTED_PROFILES.include?(post.repo)
42
46
43
-
REGEXPS.any? { |r| post.text =~ r } && !(EXCLUDE.any? { |r| post.text =~ r })
47
+
REGEXPS.any? { |r| post.text =~ r } && !(EXCLUDE.any? { |r| post.text =~ r }) && !has_forbidden_links?(post)
48
+
end
49
+
50
+
def has_forbidden_links?(post)
51
+
if embed = post.record['embed']
52
+
if link = (embed['external'] || embed['media'] && embed['media']['external'])
53
+
return true if LINK_EXCLUDES.any? { |r| r =~ link['uri'] }
54
+
end
55
+
end
56
+
57
+
return false
44
58
end
45
59
46
60
def colored_text(t)
47
61
text = t.dup
48
62
49
63
EXCLUDE.each { |r| text.gsub!(r) { |s| Rainbow(s).red }}
64
+
LINK_EXCLUDES.each { |r| text.gsub!(r) { |s| Rainbow(s).red }}
50
65
REGEXPS.each { |r| text.gsub!(r) { |s| Rainbow(s).green }}
51
66
52
67
text