misskey 0.0.2 → 0.0.4
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 +114 -0
- data/lib/misskey.rb +8 -6
- data/lib/websocket.rb +21 -0
- 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: c8608be345f4fa9d41798d8db5917bd25e9f708c0dfa5c79aa1a5b03ec29c12e
|
|
4
|
+
data.tar.gz: 6a616e68a8915c521cce618ccb543c9e847fa90484d0eeedb4958a4391fa41bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd244be74fc8f160a01cf1a92c5099acca753cc4cd629cd88ac0baa693d85679ad56d1d743b981a439165d5974bcc0442f98d8cf57936eb6506d1ef48fb2a593
|
|
7
|
+
data.tar.gz: 74bc5f2f9c15e592f8a72a113af4af56de0d05bf1b53515d04f8ccee43a2b0c910148e3ca39166017cbaf179c7d71979d053eb2857054469f44dd3e57632c660
|
data/README.md
CHANGED
|
@@ -30,6 +30,8 @@ I didn't have the energy to make a real wiki for this and I have no idea how to
|
|
|
30
30
|
|
|
31
31
|
Like I said in the contributing guide, this doesn't implement every Misskey API feature and if you want to see a feature added it would mean a lot to me if you could contribute! Thanks :neofox_heart:
|
|
32
32
|
|
|
33
|
+
All responses from the API are automatically parsed from JSON to a Ruby Array so you shouldn't need to worry about that.
|
|
34
|
+
|
|
33
35
|
### Authentication **(REQUIRED!!!)**
|
|
34
36
|
#### `Misskey.auth.instanceURI`
|
|
35
37
|
This sets the instance URI that your client will connect to. This and `Misskey.auth.token` are **required** when using Misskey.rb.
|
|
@@ -156,6 +158,8 @@ You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/n
|
|
|
156
158
|
Retrieves the home timeline of the currently logged-in user I believe? Not too sure because I only tested it on a dummy account that doesn't follow anyone.
|
|
157
159
|
|
|
158
160
|
There is one optional argument which is `limit`. As the name suggests, it sets a limit to how many notes should be retrieved. By default it's set to 10.
|
|
161
|
+
|
|
162
|
+
Here's an example:
|
|
159
163
|
```ruby
|
|
160
164
|
require "misskey"
|
|
161
165
|
|
|
@@ -217,3 +221,113 @@ Misskey.auth.instanceURI = "sharkey.skydevs.me"
|
|
|
217
221
|
puts Misskey.i
|
|
218
222
|
```
|
|
219
223
|
You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/account/POST/i) for more info.
|
|
224
|
+
|
|
225
|
+
#### `Misskey.i.notifications`
|
|
226
|
+
Retrieves the currently logged-in user's notifications. Has one argument which is `limit`. By default, `limit` is set to 10. Here's an example
|
|
227
|
+
```ruby
|
|
228
|
+
require "misskey"
|
|
229
|
+
|
|
230
|
+
Misskey.auth.token = "tokenwaaaaaaa"
|
|
231
|
+
Misskey.auth.instanceURI = "sharkey.skydevs.me"
|
|
232
|
+
|
|
233
|
+
puts Misskey.i.notifications
|
|
234
|
+
```
|
|
235
|
+
You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/account/POST/i/notifications) for more info.
|
|
236
|
+
|
|
237
|
+
### Websockets!! (THis is my favorite thing about this library :neofox_floof_cute:)
|
|
238
|
+
#### `Misskey.websocket.connect`
|
|
239
|
+
Connects your client to Misskey via the websocket protocol. Automatically runs in a separate thread. There is no documentation on websockets in the Misskey API docs but the JSON data it gives is in the same structure as doing a normal request to their documented API.
|
|
240
|
+
|
|
241
|
+
#### Notifications
|
|
242
|
+
##### `Misskey.websocket.notifications.onMention`
|
|
243
|
+
Used with a block; runs said block with an argument contianing the message when you recieve a mention notification.
|
|
244
|
+
|
|
245
|
+
Example:
|
|
246
|
+
```ruby
|
|
247
|
+
require "misskey"
|
|
248
|
+
|
|
249
|
+
Misskey.auth.token = "tokenwaaaaaaa"
|
|
250
|
+
Misskey.auth.instanceURI = "sharkey.skydevs.me"
|
|
251
|
+
|
|
252
|
+
Misskey.websocket.connect
|
|
253
|
+
|
|
254
|
+
Misskey.websocket.notifications.onMention do |message|
|
|
255
|
+
puts message
|
|
256
|
+
end
|
|
257
|
+
```
|
|
258
|
+
In this example, `puts message` will print the message JSON data in the terminal when it recieves a mention.
|
|
259
|
+
|
|
260
|
+
##### `Misskey.websocket.notifications.onReaction`
|
|
261
|
+
Used with a block; runs said block with an argument contianing the message when you recieve a reaction notification.
|
|
262
|
+
|
|
263
|
+
Example:
|
|
264
|
+
```ruby
|
|
265
|
+
require "misskey"
|
|
266
|
+
|
|
267
|
+
Misskey.auth.token = "tokenwaaaaaaa"
|
|
268
|
+
Misskey.auth.instanceURI = "sharkey.skydevs.me"
|
|
269
|
+
|
|
270
|
+
Misskey.websocket.connect
|
|
271
|
+
|
|
272
|
+
Misskey.websocket.notifications.onReaction do |message|
|
|
273
|
+
puts message
|
|
274
|
+
end
|
|
275
|
+
```
|
|
276
|
+
In this example, `puts message` will print the message JSON data in the terminal when it recieves a reaction.
|
|
277
|
+
|
|
278
|
+
##### `Misskey.websocket.notifications.onRenote`
|
|
279
|
+
Used with a block; runs said block with an argument contianing the message when you recieve a renote notification.
|
|
280
|
+
|
|
281
|
+
Example:
|
|
282
|
+
```ruby
|
|
283
|
+
require "misskey"
|
|
284
|
+
|
|
285
|
+
Misskey.auth.token = "tokenwaaaaaaa"
|
|
286
|
+
Misskey.auth.instanceURI = "sharkey.skydevs.me"
|
|
287
|
+
|
|
288
|
+
Misskey.websocket.connect
|
|
289
|
+
|
|
290
|
+
Misskey.websocket.notifications.onRenote do |message|
|
|
291
|
+
puts message
|
|
292
|
+
end
|
|
293
|
+
```
|
|
294
|
+
In this example, `puts message` will print the message JSON data in the terminal when it recieves a renote.
|
|
295
|
+
|
|
296
|
+
##### `Misskey.websocket.notifications.onNotification`
|
|
297
|
+
Used with a block; runs said block with an argument contianing the message when you recieve a notification.
|
|
298
|
+
|
|
299
|
+
Example:
|
|
300
|
+
```ruby
|
|
301
|
+
require "misskey"
|
|
302
|
+
|
|
303
|
+
Misskey.auth.token = "tokenwaaaaaaa"
|
|
304
|
+
Misskey.auth.instanceURI = "sharkey.skydevs.me"
|
|
305
|
+
|
|
306
|
+
Misskey.websocket.connect
|
|
307
|
+
|
|
308
|
+
Misskey.websocket.notifications.onNotification do |message|
|
|
309
|
+
puts message
|
|
310
|
+
end
|
|
311
|
+
```
|
|
312
|
+
In this example, `puts message` will print the message JSON data in the terminal when it recieves a notification.
|
|
313
|
+
|
|
314
|
+
##### `Misskey.websocket.notifications.onQuote`
|
|
315
|
+
Used with a block; runs said block with an argument contianing the message when you recieve a quote notification.
|
|
316
|
+
|
|
317
|
+
Example:
|
|
318
|
+
```ruby
|
|
319
|
+
require "misskey"
|
|
320
|
+
|
|
321
|
+
Misskey.auth.token = "tokenwaaaaaaa"
|
|
322
|
+
Misskey.auth.instanceURI = "sharkey.skydevs.me"
|
|
323
|
+
|
|
324
|
+
Misskey.websocket.connect
|
|
325
|
+
|
|
326
|
+
Misskey.websocket.notifications.onQuote do |message|
|
|
327
|
+
puts message
|
|
328
|
+
end
|
|
329
|
+
```
|
|
330
|
+
In this example, `puts message` will print the message JSON data in the terminal when it recieves a quote.
|
|
331
|
+
|
|
332
|
+
## That's all!
|
|
333
|
+
Those are all the features currently implemented, but don't worry, more will be added as time goes on :neofox_heart:
|
data/lib/misskey.rb
CHANGED
|
@@ -11,12 +11,6 @@ include WS
|
|
|
11
11
|
module Misskey
|
|
12
12
|
@@token = nil
|
|
13
13
|
@@instanceURI = nil
|
|
14
|
-
@@onMentionDo = [false, nil]
|
|
15
|
-
@@debugging = false
|
|
16
|
-
@@onReactionDo = [false, nil]
|
|
17
|
-
@@onRenoteDo = [false, nil]
|
|
18
|
-
@@onNotificationDo = [false, nil]
|
|
19
|
-
@@onQuoteDo = [false, nil]
|
|
20
14
|
|
|
21
15
|
def auth
|
|
22
16
|
def token
|
|
@@ -181,6 +175,14 @@ EOF
|
|
|
181
175
|
def onQuote &block
|
|
182
176
|
WS.n.oQ block
|
|
183
177
|
end
|
|
178
|
+
|
|
179
|
+
def onReply &block
|
|
180
|
+
WS.n.oRep block
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def onMentionOrReply &block
|
|
184
|
+
WS.n.oMOR block
|
|
185
|
+
end
|
|
184
186
|
end
|
|
185
187
|
end
|
|
186
188
|
end
|
data/lib/websocket.rb
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
module WS
|
|
2
2
|
def c
|
|
3
|
+
@@onMentionDo = [false, nil]
|
|
4
|
+
@@debugging = false
|
|
5
|
+
@@onReactionDo = [false, nil]
|
|
6
|
+
@@onRenoteDo = [false, nil]
|
|
7
|
+
@@onNotificationDo = [false, nil]
|
|
8
|
+
@@onQuoteDo = [false, nil]
|
|
9
|
+
@@onReplyDo = [false, nil]
|
|
10
|
+
@@onMentionOrReplyDo = [false, nil]
|
|
11
|
+
|
|
3
12
|
Thread.start do
|
|
4
13
|
EM.run do
|
|
5
14
|
instance = "wss://#{Misskey.auth.instanceURI}/streaming?i=#{Misskey.auth.token}"
|
|
@@ -31,6 +40,10 @@ module WS
|
|
|
31
40
|
@@onRenoteDo[1].call message
|
|
32
41
|
elsif @@onQuoteDo[0] and message["body"]["body"]["type"] == "quote"
|
|
33
42
|
@@onQuoteDo[1].call message
|
|
43
|
+
elsif @@onReplyDo[0] and message["body"]["body"]["type"] == "reply"
|
|
44
|
+
@@onReplyDo[1].call message
|
|
45
|
+
elsif @@onMentionOrReplyDo[0] and /(reply)|(mention)/.match message["body"]["body"]["type"]
|
|
46
|
+
@@onMentionOrReplyDo[1].call message
|
|
34
47
|
end
|
|
35
48
|
|
|
36
49
|
if @@onNotificationDo[0]
|
|
@@ -70,5 +83,13 @@ module WS
|
|
|
70
83
|
def oQ block # onQuote
|
|
71
84
|
@@onQuoteDo = [true, block]
|
|
72
85
|
end
|
|
86
|
+
|
|
87
|
+
def oRep block # onReply
|
|
88
|
+
@@onReplyDo = [true, block]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def oMOR block # onMentionOrReply
|
|
92
|
+
@@onMentionOrReplyDo = [true, block]
|
|
93
|
+
end
|
|
73
94
|
end
|
|
74
95
|
end
|