tangled
alpha
login
or
join now
mackuba.eu
/
skyfall
6
fork
atom
A Ruby gem for streaming data from the Bluesky/ATProto firehose
6
fork
atom
overview
issues
pulls
pipelines
added example script
mackuba.eu
2 years ago
c9c27ec0
4296819a
+30
-1
3 changed files
expand all
collapse all
unified
split
README.md
example
firehose.rb
skyfall.gemspec
+2
README.md
···
83
83
end
84
84
```
85
85
86
86
+
See complete example in [example/firehose.rb](https://github.com/mackuba/skyfall/blob/master/example/firehose.rb).
87
87
+
86
88
87
89
## Credits
88
90
+27
example/firehose.rb
···
1
1
+
#!/usr/bin/env ruby
2
2
+
3
3
+
lib = File.expand_path('../../lib', __FILE__)
4
4
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
+
6
6
+
require 'skyfall'
7
7
+
8
8
+
sky = Skyfall::Stream.new('bsky.social', :subscribe_repos)
9
9
+
10
10
+
sky.on_message do |m|
11
11
+
next if m.type != :commit
12
12
+
13
13
+
m.operations.each do |op|
14
14
+
next unless op.action == :create && op.type == :bsky_post
15
15
+
16
16
+
puts "#{op.repo}:"
17
17
+
puts op.raw_record['text']
18
18
+
puts
19
19
+
end
20
20
+
end
21
21
+
22
22
+
sky.on_connect { puts "Connected" }
23
23
+
sky.on_disconnect { puts "Disconnected" }
24
24
+
sky.on_error { |e| puts "ERROR: #{e}" }
25
25
+
26
26
+
sky.connect
27
27
+
sleep
+1
-1
skyfall.gemspec
···
28
28
}
29
29
30
30
spec.files = Dir.chdir(__dir__) do
31
31
-
Dir['*.md'] + Dir['*.txt'] + Dir['lib/**/*'] + Dir['sig/**/*']
31
31
+
Dir['*.md'] + Dir['*.txt'] + Dir['example/**/*'] + Dir['lib/**/*'] + Dir['sig/**/*']
32
32
end
33
33
34
34
spec.require_paths = ["lib"]