Template of a custom feed generator service for the Bluesky network in Ruby
1require_relative 'feed'
2
3class StarWarsFeed < Feed
4 REGEXPS = [
5 /star ?wars/i, /mandalorian/i, /\bandor\b/i, /boba fett/i, /obi[ \-]?wan/i, /\bahsoka\b/, /\bjedi\b/i,
6 /\bsith\b/i, /\byoda\b/i, /Empire Strikes Back/, /chewbacca/i, /Han Solo/, /darth vader/i, /skywalker/i,
7 /lightsab(er|re)/i, /clone wars/i
8 ]
9
10 def feed_id
11 1
12 end
13
14 def display_name
15 "Star Wars"
16 end
17
18 def description
19 "Feed with posts mentioning Star Wars movies and TV shows and various SW characters"
20 end
21
22 def avatar_file
23 "images/babyyoda.jpg"
24 end
25
26 def post_matches?(post)
27 REGEXPS.any? { |r| post.text =~ r }
28 end
29
30 def colored_text(t)
31 text = t.dup
32
33 REGEXPS.each { |r| text.gsub!(r) { |s| Rainbow(s).green }}
34
35 text
36 end
37end