e621stream 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/e621stream/client.rb +7 -2
- data/lib/e621stream/event.rb +7 -0
- data/lib/e621stream/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0b273776fc1b808a7544474ea58ffc49d3ba07147bbb99d458c749ff26ea875
|
|
4
|
+
data.tar.gz: 8df64f093a820b05bbd334c189f25dd23eb1194445a219dceddcb260ca6515ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d94db80a321cd2e0ced4abd6fa43be23e10a6a67b8758c6095d8b88ffa3a939841f1036bfcaea620623b31f4cff3733a8303d4cf5340e7634f428055206b3779
|
|
7
|
+
data.tar.gz: 5f7497b80e5b911302a286c7bc5935bc775906baf32bd56b0d5fec685f61df084f29cf69c25bd1ca7705ec264fbcd3259645600352bd0d21e8862f13ec2edf16
|
data/README.md
CHANGED
|
@@ -26,7 +26,9 @@ Instead of `username:` & `api_key:`, you can pass `token:` with a token from [/a
|
|
|
26
26
|
|
|
27
27
|
`run` blocks, unless you're already in a reactor, then it runs as a task and `client.close` stops it.
|
|
28
28
|
|
|
29
|
-
`on("post.create")` listens for one type, `on(:dispatch)` for everything. Events have `id`, `type`, `time` and `data` (the record as the api returns it), see [Events](https://e621.stream/events/). There's also `:ready`, `:replay_complete`, `:subscribed`, `:reconnecting`, `:close` and `:error`.
|
|
29
|
+
`on("post.create")` listens for one type, `on(:dispatch)` for everything. Events have `id`, `type`, `time` and `data` (the record as the api returns it), see [Events](https://e621.stream/events/). There's also `:ready`, `:replay_complete`, `:subscribed`, `:recovery`, `:reconnecting`, `:close` and `:error`.
|
|
30
|
+
|
|
31
|
+
If the server missed events and goes back for them (a [recovery](https://e621.stream/replaying/#recoveries)), `:recovery` gets the details when it starts and finishes, and the events it sends are `recovered?`. They can be hours old, so don't assume `time` only goes up.
|
|
30
32
|
|
|
31
33
|
It reconnects when the connection drops (`reconnect: false` turns that off), and picks up from `client.cursor`. Pass `cursor:` to replay from an event id or ms timestamp. `url:` is the site (`https://e621.stream`), the websocket url comes from its `/info`, or pass a `ws://`/`wss://` url to connect to it directly. `client.subscribe([...])` changes subscriptions. Private events like `dmail.create` have to be subscribed to by name.
|
|
32
34
|
|
data/lib/e621stream/client.rb
CHANGED
|
@@ -92,7 +92,7 @@ module E621Stream
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
# Listens for an event type (like "post.create"), or one of :dispatch (every event), :ready, :replay_complete,
|
|
95
|
-
# :subscribed, :error, :close and :reconnecting.
|
|
95
|
+
# :subscribed, :recovery, :error, :close and :reconnecting.
|
|
96
96
|
sig { params(name: T.any(String, Symbol), block: Listener).returns(T.self_type) }
|
|
97
97
|
def on(name, &block)
|
|
98
98
|
T.must(@listeners[name.to_s]) << block
|
|
@@ -213,10 +213,15 @@ module E621Stream
|
|
|
213
213
|
@ready = true
|
|
214
214
|
emit("ready", data)
|
|
215
215
|
when "dispatch"
|
|
216
|
-
event = Event.new(id: message["id"], type: message["type"], time: message["time"], data: message["data"],
|
|
216
|
+
event = Event.new(id: message["id"], type: message["type"], time: message["time"], data: message["data"],
|
|
217
|
+
private: message["private"] == true, recovered: message["recovered"] == true)
|
|
217
218
|
@cursor = event.id unless event.private?
|
|
218
219
|
emit("dispatch", event)
|
|
219
220
|
emit(event.type, event)
|
|
221
|
+
when "recovery"
|
|
222
|
+
# these are on the stream too, so they move the cursor
|
|
223
|
+
@cursor = message["id"] if message["id"]
|
|
224
|
+
emit("recovery", data)
|
|
220
225
|
when "replay_complete"
|
|
221
226
|
emit("replay_complete", data)
|
|
222
227
|
when "subscribed"
|
data/lib/e621stream/event.rb
CHANGED
|
@@ -15,10 +15,17 @@ module E621Stream
|
|
|
15
15
|
const(:data, T::Hash[String, T.untyped])
|
|
16
16
|
# Only for private events, which are polled with your own credentials and never stored.
|
|
17
17
|
const(:private, T::Boolean, default: false)
|
|
18
|
+
# Sent late by a recovery, so it's out of order with the rest. See https://e621.stream/replaying/#recoveries
|
|
19
|
+
const(:recovered, T::Boolean, default: false)
|
|
18
20
|
|
|
19
21
|
sig { returns(T::Boolean) }
|
|
20
22
|
def private?
|
|
21
23
|
private
|
|
22
24
|
end
|
|
25
|
+
|
|
26
|
+
sig { returns(T::Boolean) }
|
|
27
|
+
def recovered?
|
|
28
|
+
recovered
|
|
29
|
+
end
|
|
23
30
|
end
|
|
24
31
|
end
|
data/lib/e621stream/version.rb
CHANGED