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