misskey 0.0.4 → 0.0.5

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +51 -3
  3. data/lib/create.rb +67 -17
  4. data/lib/misskey.rb +26 -3
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8608be345f4fa9d41798d8db5917bd25e9f708c0dfa5c79aa1a5b03ec29c12e
4
- data.tar.gz: 6a616e68a8915c521cce618ccb543c9e847fa90484d0eeedb4958a4391fa41bb
3
+ metadata.gz: 0ea84373b52dedf73ef21f31937e5209d0f48b187090f73d935959496da25d02
4
+ data.tar.gz: 509c6f8655424ef9d7420262db58def2feb0d9b4c083d20415a2782796320e4e
5
5
  SHA512:
6
- metadata.gz: bd244be74fc8f160a01cf1a92c5099acca753cc4cd629cd88ac0baa693d85679ad56d1d743b981a439165d5974bcc0442f98d8cf57936eb6506d1ef48fb2a593
7
- data.tar.gz: 74bc5f2f9c15e592f8a72a113af4af56de0d05bf1b53515d04f8ccee43a2b0c910148e3ca39166017cbaf179c7d71979d053eb2857054469f44dd3e57632c660
6
+ metadata.gz: 26869141756d27a4948a9b3dc953d9b24cf375f6776583d092e3343e1f7610cf4c9c17a0c3a5bc1fa2693a4a930877f05f7d322c7b5490260c087dddf498cfa8
7
+ data.tar.gz: 05d274f648741d2ef61b726089d0745401326166a0e071f9ddb2be24057eb9594b57e14c8183fd778553fe53b8264deb071d03f698e4102cda77568f4c895459
data/README.md CHANGED
@@ -19,7 +19,7 @@ When contributing please make sure to follow these guidelines. These may change
19
19
 
20
20
  1) No LLM-generated commits please! Vibecoded software tends to get really messy and introduce more issues than it solves. Also everything around LLMs are highly unethical and I don't want to support that. Thanks!
21
21
 
22
- 2) Please do not create multiple functions that do the same thing.
22
+ 2) Please do not create multiple methods that do the same thing.
23
23
 
24
24
  3) Follow common sense.
25
25
 
@@ -138,7 +138,7 @@ As the note body suggests, this is a local note that has a content warning.
138
138
 
139
139
  You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/notes/POST/notes/create) for more info.
140
140
 
141
- #### `Misskey.notes.create.reply`
141
+ #### `Misskey.notes.reply`
142
142
  Very similar to `Misskey.notes.create` except it features a new required argument called `replyId`.
143
143
 
144
144
  Arguments for this are as follows: `replyId` (REQUIRED), `noteContent` (REQUIRED), visibility, localOnly, cw
@@ -150,7 +150,7 @@ require "misskey"
150
150
  Misskey.auth.token = "tokenwaaaaaaa"
151
151
  Misskey.auth.instanceURI = "sharkey.skydevs.me"
152
152
 
153
- Misskey.notes.create.reply "someReplyId", "Hello there, this is a reply."
153
+ Misskey.notes.reply "someReplyId", "Hello there, this is a reply."
154
154
  ```
155
155
  You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/notes/POST/notes/create) for more info.
156
156
 
@@ -170,6 +170,22 @@ puts Misskey.notes.timeline
170
170
  ```
171
171
  You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/notes/POST/notes/timeline) for more info.
172
172
 
173
+ #### `Misskey.notes.show`
174
+ Retrieves a note of the specified ID.
175
+
176
+ There is one optional argument which is `id`. As the name suggests, it is the ID of the note you'd like to get info about.
177
+
178
+ Here's an example:
179
+ ```ruby
180
+ require "misskey"
181
+
182
+ Misskey.auth.token = "tokenwaaaaaaa"
183
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
184
+
185
+ puts Misskey.notes.show "noteweeewoooo"
186
+ ```
187
+ You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/notes/POST/notes/show) for more info.
188
+
173
189
  ### `Misskey.getOnlineUsersCount`
174
190
  Pretty self-explanatory, gets the number of users online. Using it is really simple, here's an example:
175
191
  ```ruby
@@ -329,5 +345,37 @@ end
329
345
  ```
330
346
  In this example, `puts message` will print the message JSON data in the terminal when it recieves a quote.
331
347
 
348
+ ##### `Misskey.websocket.notifications.onReply`
349
+ Used with a block; runs said block with an argument contianing the message when you recieve a reply notification.
350
+
351
+ Example:
352
+ ```ruby
353
+ require "misskey"
354
+
355
+ Misskey.auth.token = "tokenwaaaaaaa"
356
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
357
+
358
+ Misskey.websocket.connect
359
+
360
+ Misskey.websocket.notifications.onReply do |message|
361
+ puts message
362
+ end
363
+ ```
364
+ In this example, `puts message` will print the message JSON data in the terminal when it recieves a reply.
365
+
366
+ ##### `Misskey.websocket.notifications.onMentionOrReply`
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
+
369
+ ### `Misskey.debug.debugging`
370
+ true/false value. Prints response information in the console for when you want to debug why a note won't create or something.
371
+
372
+ Example:
373
+
374
+ ```ruby
375
+ require "misskey"
376
+
377
+ Misskey.debug.debugging = true
378
+ ```
379
+
332
380
  ## That's all!
333
381
  Those are all the features currently implemented, but don't worry, more will be added as time goes on :neofox_heart:
data/lib/create.rb CHANGED
@@ -31,11 +31,61 @@ JSON
31
31
  puts postJSON
32
32
  puts response
33
33
  end
34
+ end
35
+
36
+ def replied replyId, noteContent, visibility = "public", localOnly = false, cw = ""
37
+ instance = "https://#{Misskey.auth.instanceURI}/api/notes/create"
38
+ note = Misskey.notes.show replyId
39
+
40
+ if Misskey.debug.debugging
41
+ puts "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nnote:"
42
+ puts note
43
+ end
44
+
45
+ userId = note["userId"]
46
+ noteVisibility = note["visibility"].strip
47
+ noteVisibilityId = 0
48
+ visibilityId = 0
49
+
50
+ case noteVisibility
51
+ when "public"
52
+ noteVisibilityId = 1
53
+ when "home"
54
+ noteVisibilityId = 2
55
+ when "followers"
56
+ noteVisibilityId = 3
57
+ when "specified"
58
+ noteVisibilityId = 4
59
+ end
60
+
61
+ case visibility
62
+ when "public"
63
+ visibilityId = 1
64
+ when "home"
65
+ visibilityId = 2
66
+ when "followers"
67
+ visibilityId = 3
68
+ when "specified"
69
+ visibilityId = 4
70
+ end
71
+
72
+ if visibilityId >> noteVisibilityId
73
+ visibility = noteVisibility
74
+
75
+ if Misskey.debug.debugging
76
+ puts "Adjusted visibility accordingly."
77
+ end
78
+ end
79
+
80
+ if Misskey.debug.debugging
81
+ puts "Note visiblity: #{noteVisibility}"
82
+ puts "Note visibility ID: #{noteVisibilityId}"
83
+ puts "Reply visibility: #{visibility}"
84
+ puts "Reply visibility ID: #{visibilityId}"
85
+ end
34
86
 
35
- def reply replyId, noteContent, visibility = "public", localOnly = false, cw = ""
36
- instance = "https://#{Misskey.auth.instanceURI}/api/notes/create"
37
- # Visibility: public, home, followers, specified
38
- postJSON = <<~JSON
87
+ # Visibility: public, home, followers, specified
88
+ postJSON = <<~JSON
39
89
  {
40
90
  "visibility": "#{visibility}",
41
91
  "visibleUserIds": [],
@@ -45,25 +95,25 @@ JSON
45
95
  "noExtractMentions": false,
46
96
  "noExtractHashtags": false,
47
97
  "noExtractEmojis": false,
48
- "replyId": #{replyId},
98
+ "replyId": "#{replyId}",
99
+ "userId": "#{userId}",
49
100
  "renoteId": null,
50
101
  "channelId": null,
51
102
  "text": "#{noteContent}"
52
103
  }
53
104
  JSON
54
105
 
55
- response = HTTParty.post(
56
- instance,
57
- body: postJSON,
58
- headers: {
59
- 'Content-Type' => 'application/json',
60
- "Authorization" => "Bearer #{Misskey.auth.token}"
61
- }
62
- )
63
- if Misskey.debug.debugging
64
- puts postJSON
65
- puts response
66
- end
106
+ response = HTTParty.post(
107
+ instance,
108
+ body: postJSON,
109
+ headers: {
110
+ 'Content-Type' => 'application/json',
111
+ "Authorization" => "Bearer #{Misskey.auth.token}"
112
+ }
113
+ )
114
+ if Misskey.debug.debugging
115
+ puts postJSON
116
+ puts response
67
117
  end
68
118
  end
69
119
  end
data/lib/misskey.rb CHANGED
@@ -43,10 +43,10 @@ module Misskey
43
43
  def notes
44
44
  def create noteContent, visibility = "public", localOnly = false, cw = ""
45
45
  Creates.created noteContent, visibility = "public", localOnly = false, cw = ""
46
+ end
46
47
 
47
- def reply replyId, noteContent, visibility = "public", localOnly = false, cw = ""
48
- Creates.created.reply replyId, noteContent, visibility = "public", localOnly = false, cw = ""
49
- end
48
+ def reply replyId, noteContent, visibility = "public", localOnly = false, cw = ""
49
+ Creates.replied replyId, noteContent, visibility = "public", localOnly = false, cw = ""
50
50
  end
51
51
 
52
52
  def timeline limit = 10
@@ -69,6 +69,27 @@ EOF
69
69
 
70
70
  return JSON.parse request.body
71
71
  end
72
+
73
+ def show id
74
+ instance = "https://#{Misskey.auth.instanceURI}/api/notes/show"
75
+
76
+ postJSON = <<EOF
77
+ {
78
+ "noteId": "#{id}"
79
+ }
80
+ EOF
81
+
82
+ request = HTTParty.post(
83
+ instance,
84
+ body: postJSON,
85
+ headers: {
86
+ "Content-Type" => "application/json",
87
+ "Authorization" => "Bearer #{Misskey.auth.token}"
88
+ }
89
+ )
90
+
91
+ return JSON.parse request.body
92
+ end
72
93
  end
73
94
 
74
95
  def getOnlineUsersCount
@@ -188,3 +209,5 @@ EOF
188
209
  end
189
210
 
190
211
  include Misskey
212
+
213
+ Misskey.debug.debugging = false
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.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sky.Bit