bskyrb 0.5 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bskyrb/codegen.rb +1 -0
- data/lib/bskyrb/error.rb +10 -0
- data/lib/bskyrb/firehose.rb +19 -21
- data/lib/bskyrb/generated_classes.rb +711 -4
- data/lib/bskyrb/records.rb +50 -91
- data/lib/bskyrb/session.rb +40 -30
- data/lib/bskyrb/version.rb +2 -1
- data/lib/bskyrb/xrpc.rb +24 -0
- data/lib/bskyrb.rb +3 -0
- metadata +4 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acb1d587977217b5e0e2e373c422fe69702364524c29d96ddf6b3cf5c537eed5
|
4
|
+
data.tar.gz: 7094841141b05f7b24024c6ebd5df494486f125202ce2ceb79e06ef29b9512dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 012464fcc4bf3c84ada9a11b0f9bc7b13d7bcbff3378cc9724822474daa11eeb37b718589498f15885b9efc4694b0e46b8884d00af3e2a7126dcead4ff3d2fd0
|
7
|
+
data.tar.gz: 26cea956181b0d593a7e164de63b8d48293c94308d2bba3c53461add0d5254f229bb9072198fa661f4f6c2df526ab9429bf7804b3c1672512f11419a1ccea279
|
data/lib/bskyrb/codegen.rb
CHANGED
data/lib/bskyrb/error.rb
ADDED
data/lib/bskyrb/firehose.rb
CHANGED
@@ -1,39 +1,37 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# typed: false
|
2
|
+
require "faye/websocket"
|
3
|
+
require "eventmachine"
|
4
|
+
require "cbor"
|
5
|
+
require "json"
|
5
6
|
|
6
7
|
EM.run {
|
7
|
-
ws = Faye::WebSocket::Client.new(
|
8
|
+
ws = Faye::WebSocket::Client.new("wss://bsky.social/xrpc/com.atproto.sync.subscribeRepos")
|
8
9
|
|
9
10
|
ws.on :open do |event|
|
10
11
|
p [:open]
|
11
|
-
ws.send(
|
12
|
+
ws.send("Hello, world!")
|
12
13
|
end
|
13
14
|
|
14
15
|
ws.on :message do |event|
|
15
16
|
msg_bytes = event.data
|
16
|
-
unpacker = CBOR::Unpacker.new(StringIO.new(msg_bytes.pack(
|
17
|
-
header, payload = unpacker.each.to_a
|
18
|
-
|
17
|
+
unpacker = CBOR::Unpacker.new(StringIO.new(msg_bytes.pack("C*")))
|
18
|
+
header, payload = unpacker.each.to_a
|
19
|
+
|
19
20
|
# decoder = CBOR::Decoding.new(StringIO.new(msg_bytes.pack('C*')))
|
20
21
|
# while item = decoder.read
|
21
22
|
# puts item
|
22
23
|
# end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
decoded = CBOR.decode(payload)
|
25
|
+
if payload["ops"].first["path"].include? "app.bsky.feed.post"
|
26
|
+
# payload#["blocks"].length
|
27
|
+
decoded = CBOR.decode(payload)
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
# Print the JSON object
|
33
|
-
puts json
|
34
|
-
end
|
35
|
-
end
|
29
|
+
# Convert the decoded object to JSON
|
30
|
+
json = decoded.to_json
|
36
31
|
|
32
|
+
# Print the JSON object
|
33
|
+
puts json
|
34
|
+
end
|
37
35
|
end
|
38
|
-
}
|
36
|
+
}
|
39
37
|
# end
|