Something went wrong. Try again.
Documentation website about Ruby gems for ATProto ruby.sdk.blue
atprotocol bluesky ruby atproto
Something went wrong. Try again.
972 B · 35 lines
Ruby
at master
123456789101112131415161718192021222324252627282930313233343536#!/usr/bin/env ruby
# 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.
require 'bundler/setup'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 endend
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+Ctrap("SIGINT") { sky.disconnect }
sky.connect