+1
app/config.rb
+1
app/config.rb
+48
app/feeds/build_in_public_feed.rb
+48
app/feeds/build_in_public_feed.rb
···
1
+
require_relative 'feed'
2
+
require 'rainbow'
3
+
4
+
class BuildInPublicFeed < Feed
5
+
REGEXPS = [/\bbuild\s?in\s?public\b/i]
6
+
7
+
def feed_id
8
+
3
9
+
end
10
+
11
+
def display_name
12
+
"#buildinpublic"
13
+
end
14
+
15
+
def description
16
+
"Indie hackers and entrepreneurs building things in public - use #buildinpublic hashtag"
17
+
end
18
+
19
+
def post_matches?(post)
20
+
all_text = matched_text(post)
21
+
22
+
REGEXPS.any? { |x| all_text =~ x }
23
+
end
24
+
25
+
def matched_text(post)
26
+
lines = [post.text]
27
+
28
+
if embed = post.record['embed']
29
+
if images = (embed['images'] || embed['media'] && embed['media']['images'])
30
+
lines += images.map { |i| i['alt'] }.compact
31
+
end
32
+
33
+
if link = embed['external']
34
+
lines += [link['uri'], link['title'], link['description']].compact
35
+
end
36
+
end
37
+
38
+
lines.join("\n")
39
+
end
40
+
41
+
def colored_text(t)
42
+
text = t.dup
43
+
44
+
REGEXPS.each { |r| text.gsub!(r) { |s| Rainbow(s).green }}
45
+
46
+
text
47
+
end
48
+
end