e621stream 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79a697f56acf9e01824147dd6b02d6d895945b1eaba99c769073c8df09c967d1
4
- data.tar.gz: de0b37eb1a37fc5a7c54d48dcee613ddfac51b0068b771479ebe3fc2077c252c
3
+ metadata.gz: d4064e95c8ea6d3b7aa436c24ec278287051618b025678d476aea6519e860f5d
4
+ data.tar.gz: b4181668e8a25736738d8be21f79d0630a6831a850ea3b9f15c5b10a23701d65
5
5
  SHA512:
6
- metadata.gz: db78caee15dc50614bf21bb73e2e65f5bd8d500a2f5eeb5ab1113767c0ef35fb622d57edac84c28289cbc295d8c751f098c4dcd6c9d2e9b78ab54d25a4f14ae5
7
- data.tar.gz: 8a21d51542f7b11cec640c98b86bc89a2537ca18f9d43a370736923d39791a1c91008c8714fd6f61bde1c7a5d2ff0749b9852f5bc2b58387c255a3ec0d534d9b
6
+ metadata.gz: 33e35c106e35e5938c8754ae9527c215e58453d13432cce093fbe46ae81f395e9d8c2f44db4b2a648201788fbc7c8303c84f467243e49650000005cf343d57b2
7
+ data.tar.gz: 505a8eff8f5e523efe99b46814cdb3481fbff4112da70afa6766719136b25c88a0bb8d200d922a87c85f67592fe422f5730739a3478a1a8c1fb08b35888c7967
data/README.md CHANGED
@@ -25,10 +25,12 @@ Make a token on [your tokens page](https://e621.stream/user), or pass `username:
25
25
 
26
26
  `run` blocks, unless you're already in a reactor, then it runs as a task and `client.close` stops it.
27
27
 
28
- `on("post.create")` listens for one type, `on(:dispatch)` for everything. Events have `id`, `type`, `time`, `data` (the record as the api returns it) and `context` (what the record doesn't say itself, like who made the change, or nil), see [Events](https://e621.stream/events). There's also `:ready`, `:replay_complete`, `:subscribed`, `:recovery`, `:slow_mode`, `:reconnecting`, `:close` and `:error`.
28
+ `on("post.create")` listens for one type, `on(:dispatch)` for everything. Events have `id`, `type`, `time`, `data` (the record as the api returns it) and `context` (what the record doesn't say itself, like who made the change, or nil), see [Events](https://e621.stream/events). There's also `:ready`, `:replay_complete`, `:subscribed`, `:recovery`, `:slow_mode`, `:advisory`, `:reconnecting`, `:close` and `:error`.
29
29
 
30
30
  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.
31
31
 
32
+ `:advisory` is something you should know about a change, like an event type that's been replaced, see [Advisories](https://e621.stream/#advisories). You get each once, as a hash with `id`, `level`, `audience`, `message`, `url` and `sunset`. If nothing listens for them they're printed with `warn`.
33
+
32
34
  The server can poll e621 slower for a while when it's responding slowly. `:slow_mode` gets `enabled`, `scale` and `since` when that's turned on or off, and `ready`'s `slow_mode` has it if it's already on. Events just arrive later than usual, nothing's missed.
33
35
 
34
36
  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, and need an api key or a token with private events turned on.
@@ -77,6 +77,7 @@ module E621Stream
77
77
  @last_message = T.let(0.0, Float)
78
78
  @last_error = T.let(nil, T.nilable(StreamError))
79
79
  @ready = T.let(false, T::Boolean)
80
+ @advised = T.let([], T::Array[String])
80
81
  @nonce = T.let(0, Integer)
81
82
  @pending_snapshots = T.let({}, T::Hash[String, [SnapshotCallback, Snapshots]])
82
83
  end
@@ -193,6 +194,7 @@ module E621Stream
193
194
  end
194
195
  identify[:client] = options.client if options.client
195
196
  identify[:cursor] = @cursor if @cursor
197
+ identify[:library] = { name: LIBRARY, version: VERSION }
196
198
  send_message({ op: "identify", d: identify })
197
199
  when "ready"
198
200
  @attempt = 0
@@ -216,6 +218,16 @@ module E621Stream
216
218
  emit("replay_complete", data)
217
219
  when "subscribed"
218
220
  emit("subscribed", data["subscriptions"])
221
+ # sent again on every connection, they're only passed on once
222
+ when "advisory"
223
+ return if @advised.include?(data["id"])
224
+
225
+ @advised << data["id"]
226
+ if T.must(@listeners["advisory"]).empty?
227
+ warn("[e621stream] #{data['message']}#{" (#{data['url']})" if data['url']}")
228
+ else
229
+ emit("advisory", data)
230
+ end
219
231
  when "snapshot"
220
232
  pending = @pending_snapshots[data["nonce"]]
221
233
  return unless pending
@@ -18,11 +18,11 @@ module E621Stream
18
18
  help_page.destroy help_page.update mod_action.create news_update.create news_update.destroy news_update.update
19
19
  note.create note.delete note.undelete note.update note_version.create pool.add_posts pool.create pool.destroy
20
20
  pool.remove_posts pool.update pool_version.create post.create post.destroy post.stats post.update
21
- post_approval.create post_approval.destroy post_event.create post_flag.create post_flag.update
22
- post_replacement.create post_replacement.destroy post_replacement.update post_set.add_posts post_set.create
23
- post_set.destroy post_set.remove_posts post_set.update post_version.create post_version.hide post_version.unhide
24
- tag.create tag.destroy tag.update tag_type_version.create tag_alias.create tag_alias.update
25
- tag_implication.create tag_implication.update takedown.create takedown.destroy takedown.update
21
+ post_approval.create post_approval.destroy post_deletion.create post_deletion.update post_event.create
22
+ post_flag.create post_flag.update post_replacement.create post_replacement.destroy post_replacement.update
23
+ post_set.add_posts post_set.create post_set.destroy post_set.remove_posts post_set.update post_version.create
24
+ post_version.hide post_version.unhide tag.create tag.destroy tag.update tag_type_version.create tag_alias.create
25
+ tag_alias.update tag_implication.create tag_implication.update takedown.create takedown.destroy takedown.update
26
26
  upload_karma_event.create upload_url_rule.create upload_url_rule.destroy upload_url_rule.update
27
27
  upload_whitelist.create upload_whitelist.destroy upload_whitelist.update user.create user.destroy user.update
28
28
  user_feedback.create user_feedback.delete user_feedback.destroy user_feedback.undelete user_feedback.update
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module E621Stream
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
+ # sent in identify as <registry>:<package> with the version, so advisories can be aimed at versions with a problem
6
+ LIBRARY = "rubygems:e621stream"
5
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e621stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donovan_DMC