Template of a custom feed generator service for the Bluesky network in Ruby
1#!/usr/bin/env ruby
2
3require 'bundler/setup'
4require_relative 'app/firehose_stream'
5
6$stdout.sync = true
7
8ActiveRecord::Base.logger = nil
9
10def print_help
11 puts "Usage: #{$0} [options...]"
12 puts "Options:"
13 puts
14 puts " * Showing progress: [default: show in development]"
15 puts " -p = show progress dots for each received message"
16 puts " -np = don't show progress dots"
17 puts
18 puts " * Logging status changes: [default: log in any mode]"
19 puts " -ns = don't log status changes"
20 puts
21 puts " * Logging post text: [default: -lm in development, -nl in production]"
22 puts " -lm = log text of matching posts"
23 puts " -la = log text of every post"
24 puts " -nl = don't log posts"
25 puts
26 puts " * Saving posts to db: [default: -da in development, -dm in production]"
27 puts " -da = save all posts to database"
28 puts " -dm = save only matching posts to database"
29 puts " -nd = don't save any posts"
30end
31
32firehose = FirehoseStream.new
33
34ARGV.each do |arg|
35 case arg
36 when '-p'
37 firehose.show_progress = true
38 when '-np'
39 firehose.show_progress = false
40 when '-ns'
41 firehose.log_status = false
42 when '-lm'
43 firehose.log_posts = :matching
44 when '-la'
45 firehose.log_posts = :all
46 when '-nl'
47 firehose.log_posts = false
48 when '-dm'
49 firehose.save_posts = :matching
50 when '-da'
51 firehose.save_posts = :all
52 when '-nd'
53 firehose.save_posts = false
54 when '-h', '--help'
55 print_help
56 exit 0
57 else
58 puts "Unrecognized option: #{arg}"
59 print_help
60 exit 1
61 end
62end
63
64firehose.start
65sleep