misskey 0.0.10 → 0.0.11

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: cc3ebfcb62899c4693af7869505f32f750a958b9278f5b271e2ce4d66d0bfa81
4
- data.tar.gz: 620aa2fdeb287a1090d8b488e3233049889e110e5779cca96bb188b2ee67d97c
3
+ metadata.gz: 9832d4c8e812be889dfae942ea351550bf40533f996d0ae3c75ddbb09b6cf1e9
4
+ data.tar.gz: 42a22f453bb249c1956a5a9d6af01b10c63b4a3be18f7b8d309d90ef6a00a4c5
5
5
  SHA512:
6
- metadata.gz: 1f77f251a84652e250e6509e35b692c86edae86eeea5e46c7a3b24fcb02c304738af53eafdee22f118d19b34e963759efa3f20f02096a904061554fc53049c9a
7
- data.tar.gz: f8e4adf0e7c318c4e16871b866e2cdae2e915a5612cfd98d408980693564a40961d2c8e800124b21a7e68cc90c1ef3a480c47ee49777334010d75cf53ea49836
6
+ metadata.gz: d3ad6217bc0f8ba6382f1c54e4f873b1786b2c190f09fa5655b11b109f7d954de58c43ed11ecd4c60b33614f5bf4ea9a220d832b349e5b4c5f7109f74fc6a81d
7
+ data.tar.gz: 3984dc334fb943dd13fce0d098e8751df2a45155a553e720e3d35a32f5b6eb495c166c5ae068f4aaf017e9484c2866a8fd590a4763421143fe108f7d23d74978
data/README.md CHANGED
@@ -94,7 +94,7 @@ Also pretty simple :neofox_floof_happy:
94
94
  #### `Misskey.notes.create`
95
95
  Creates a note.
96
96
 
97
- Order of arguments are as follows: `noteContent` also known as the body text (REQUIRED), `visibility`, `visibleUserIds`, `localonly`, `cw` also known as a content warning.
97
+ Order of arguments are as follows: `noteContent` also known as the body text (REQUIRED), `visibility`, `visibleUserIds`, `localonly`, `cw` also known as a content warning, `token` for when you want to send a post as a different user.
98
98
 
99
99
  Visibility options include: `public`, `home`, `followers`, and `specified`. `specified` is also known as a direct note or private message.
100
100
 
@@ -141,7 +141,7 @@ You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/n
141
141
  #### `Misskey.notes.reply`
142
142
  Very similar to `Misskey.notes.create` except it features a new required argument called `replyId`.
143
143
 
144
- Arguments for this are as follows: `replyId` (REQUIRED), `noteContent` (REQUIRED), `visibility`, `visibleUserIds`, `localOnly`, `cw`
144
+ Arguments for this are as follows: `replyId` (REQUIRED), `noteContent` (REQUIRED), `visibility`, `visibleUserIds`, `localOnly`, `cw`, `token`
145
145
 
146
146
  An example:
147
147
  ```ruby
@@ -366,6 +366,82 @@ In this example, `puts message` will print the message JSON data in the terminal
366
366
  ##### `Misskey.websocket.notifications.onMentionOrReply`
367
367
  This checks for a reply or mention and acts the same way as the onReply or onMention methods. Refer to those for more info.
368
368
 
369
+ #### Events
370
+ The raw Event Machine events for handling events yourself.
371
+
372
+ ##### `Misskey.websocket.event.onError`
373
+ Used with a block; runs said block with an argument contianing the raw Event Machine event data.
374
+
375
+ Example:
376
+ ```ruby
377
+ require "misskey"
378
+
379
+ Misskey.auth.token = "tokenwaaaaaaa"
380
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
381
+
382
+ Misskey.websocket.connect
383
+
384
+ Misskey.websocket.event.onError do
385
+ puts "Something went wrong"
386
+ Misskey.websocket.connect
387
+ end
388
+ ```
389
+ In this example, the script will reconnect to the websocket if it errors out.
390
+
391
+ ##### `Misskey.websocket.event.onClose`
392
+ Used with a block; runs said block with an argument contianing the raw Event Machine event data.
393
+
394
+ Example:
395
+ ```ruby
396
+ require "misskey"
397
+
398
+ Misskey.auth.token = "tokenwaaaaaaa"
399
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
400
+
401
+ Misskey.websocket.connect
402
+
403
+ Misskey.websocket.event.onError do
404
+ Misskey.notes.create "AAAAAA WEBSOCKET DIED NOOOOOO"
405
+ end
406
+ ```
407
+ In this example, the script will create a note if the websocket closes.
408
+
409
+ ##### `Misskey.websocket.event.onOpen`
410
+ Used with a block; runs said block with an argument contianing the raw Event Machine event data.
411
+
412
+ Example:
413
+ ```ruby
414
+ require "misskey"
415
+
416
+ Misskey.auth.token = "tokenwaaaaaaa"
417
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
418
+
419
+ Misskey.websocket.connect
420
+
421
+ Misskey.websocket.event.onOpen do
422
+ Misskey.notes.create "My websocket is open yayyyyy"
423
+ end
424
+ ```
425
+ In this example, the script will create a note if the websocket opens.
426
+
427
+ ##### `Misskey.websocket.event.onMessage`
428
+ Used with a block; runs said block with an argument contianing the raw Event Machine event data.
429
+
430
+ Example:
431
+ ```ruby
432
+ require "misskey"
433
+
434
+ Misskey.auth.token = "tokenwaaaaaaa"
435
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
436
+
437
+ Misskey.websocket.connect
438
+
439
+ Misskey.websocket.event.onMessage do |event|
440
+ puts event.data
441
+ end
442
+ ```
443
+ In this example, the script will print the raw event data.
444
+
369
445
  ### `Misskey.debug.debugging`
370
446
  true/false value. Prints response information in the console for when you want to debug why a note won't create or something.
371
447
 
data/lib/create.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Creates
2
- def created noteContent, visibility = "public", visibleUserIds = [], localOnly = false, cw = ""
2
+ def created noteContent, visibility = "public", visibleUserIds = [], localOnly = false, cw = "", token = Misskey.auth.token
3
3
  instance = "https://#{Misskey.auth.instanceURI}/api/notes/create"
4
4
  visibleUserIdsJSON = visibleUserIds.to_json
5
5
  # Visibility: public, home, followers, specified
@@ -25,7 +25,7 @@ JSON
25
25
  body: postJSON,
26
26
  headers: {
27
27
  'Content-Type' => 'application/json',
28
- "Authorization" => "Bearer #{Misskey.auth.token}"
28
+ "Authorization" => "Bearer #{token}"
29
29
  }
30
30
  )
31
31
  if Misskey.debug.debugging
@@ -36,8 +36,8 @@ JSON
36
36
  return response
37
37
  end
38
38
 
39
- def replied replyId, noteContent, visibility = "public", visibleUserIds = [], localOnly = false, cw = ""
40
- visibility = visibility.strip
39
+ def replied replyId, noteContent, visibility = "public", visibleUserIds = [], localOnly = false, cw = "", token = Misskey.auth.token
40
+ visibility = visibility
41
41
  instance = "https://#{Misskey.auth.instanceURI}/api/notes/create"
42
42
  visibleUserIdsJSON = visibleUserIds.to_json
43
43
  note = Misskey.notes.show replyId
@@ -48,7 +48,7 @@ JSON
48
48
  end
49
49
 
50
50
  userId = note["userId"]
51
- noteVisibility = note["visibility"].strip
51
+ noteVisibility = note["visibility"]
52
52
  noteVisibilityId = 0
53
53
  visibilityId = 0
54
54
 
@@ -113,7 +113,7 @@ JSON
113
113
  body: postJSON,
114
114
  headers: {
115
115
  'Content-Type' => 'application/json',
116
- "Authorization" => "Bearer #{Misskey.auth.token}"
116
+ "Authorization" => "Bearer #{token}"
117
117
  }
118
118
  )
119
119
  if Misskey.debug.debugging
data/lib/misskey.rb CHANGED
@@ -63,12 +63,12 @@ EOF
63
63
  end
64
64
 
65
65
  def notes
66
- def create noteContent, visibility = "public", visibleUserIds = [], localOnly = false, cw = ""
67
- Creates.created noteContent, visibility, visibleUserIds, localOnly, cw
66
+ def create noteContent, visibility = "public", visibleUserIds = [], localOnly = false, cw = "", token = Misskey.auth.token
67
+ Creates.created noteContent, visibility, visibleUserIds, localOnly, cw, token
68
68
  end
69
69
 
70
- def reply replyId, noteContent, visibility = "public", visibleUserIds = [], localOnly = false, cw = ""
71
- Creates.replied replyId, noteContent, visibility, visibleUserIds, localOnly, cw
70
+ def reply replyId, noteContent, visibility = "public", visibleUserIds = [], localOnly = false, cw = "", token = Misskey.auth.token
71
+ Creates.replied replyId, noteContent, visibility, visibleUserIds, localOnly, cw, token
72
72
  end
73
73
 
74
74
  def timeline limit = 10
data/lib/websocket.rb CHANGED
@@ -58,14 +58,14 @@ module WS
58
58
  if @@onNotificationDo[0]
59
59
  @@onNotificationDo[1].call message
60
60
  end
61
-
62
- if @@onMessage[0]
63
- @@onMessage[1].call event
64
- end
65
61
  rescue => error
66
62
  puts Rainbow("An error occurred in the websocket event: ").red + error.to_s
67
63
  end
68
64
  end
65
+
66
+ if @@onMessage[0]
67
+ @@onMessage[1].call event
68
+ end
69
69
  end
70
70
 
71
71
  socket.onclose = lambda do |event|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: misskey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sky.Bit
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 4.0.3
90
+ rubygems_version: 4.0.11
91
91
  specification_version: 4
92
92
  summary: A Ruby Gem for interacting with the Misskey API
93
93
  test_files: []