stream_all_posts.rb
Example: print the date and text of every new post made on the network as they appear. Pass a hostname of a single PDS as the argument to only stream new posts from that PDS.
rb
require 'skyfall'
$firehose_host = ARGV[0] || 'bsky.network'
sky = Skyfall::Firehose.new($firehose_host, :subscribe_repos)
sky.on_message do |msg|
# we're only interested in repo commit messages
next if msg.type != :commit
msg.operations.each do |op|
# ignore any operations other than "create post"
next unless op.action == :create && op.type == :bsky_post
puts "#{op.repo} • #{msg.time.getlocal}"
puts op.raw_record['text']
puts
end
end
sky.on_connect { puts "Connected to #{$firehose_host}" }
sky.on_disconnect { puts "Disconnected" }
sky.on_reconnect { puts "Reconnecting..." }
sky.on_error { |e| puts "ERROR: #{e}" }
# close the connection cleanly on Ctrl+C
trap("SIGINT") { sky.disconnect }
sky.connect