misskey 0.0.1 → 0.0.2

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +217 -1
  3. data/lib/misskey.rb +21 -21
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71cbb354bf3e664aced3e95663daf3913fbc15164101b9e142c287b30ee8832c
4
- data.tar.gz: 64b42af87b8adb89acf63b1127b7b33928f4eee6efd2ceea366ced0c3b46841e
3
+ metadata.gz: 03e2e920853b80640240b7ad629a1f998b23df4369542f9d8a6e909a3883147d
4
+ data.tar.gz: bd07e84986ca9e0d9807b5c3055c20c02ff9ec7ffe39e7388f5864cb0739af58
5
5
  SHA512:
6
- metadata.gz: 36fbcabc078bc9802c708b1f9653a7a1677a29ab21433aa8ea34a95b90913945c975b33066e009ae948da8a44b52eafaab944eee34827c181d675628e0faaece
7
- data.tar.gz: 9794cbf3ddaf2ae5bb4b2d8a2dd1a654d539f2be83cc5ef048178217bac8f60309c98c6b62b3f2b6ed4f89c5e251d570eb18e3bda6dce5123c43d0969119ba0e
6
+ metadata.gz: dadffdeacd82c3244c69a5e00a41bad5ed2ef275de8169deb4d384459bdb1788a78f6b143d6e53b19b3aabda3fdcd9bf359a3cd734a66836c4f0f8859818b777
7
+ data.tar.gz: e7e120302904faa5d1863bef0af94654a643f7788e0a4fc307a6a3897d59c2266361d3e14022dffdf165e14641d710887046cdf804d1b8c4e5a67f08af50d8ea
data/README.md CHANGED
@@ -1,3 +1,219 @@
1
1
  # Misskey.rb
2
2
 
3
- A Ruby module for interacting with the Misskey API
3
+ A Ruby module for interacting with the Misskey API. Releases hosted on [Rubygems](https://rubygems.org/gems/misskey). **This is not affiliated with Syuilo in any way!!**
4
+
5
+ ## Installation :neofox_science:
6
+ Either add it to your Gemfile:
7
+ ```Gemfile
8
+ gem "misskey"
9
+ ```
10
+ or install it directly with Gem:
11
+ ```sh
12
+ gem install misskey
13
+ ```
14
+
15
+ ## Contributing :neofox_laptop:
16
+ Because it would be really difficult for me to implement *every* Misskey API feature, I would really appreciate contributions!
17
+
18
+ When contributing please make sure to follow these guidelines. These may change as time goes on:
19
+
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
+
22
+ 2) Please do not create multiple functions that do the same thing.
23
+
24
+ 3) Follow common sense.
25
+
26
+ Thank you! :neofox_heart:
27
+
28
+ ## Using :neofox_notice:
29
+ I didn't have the energy to make a real wiki for this and I have no idea how to use the Rubygems documentation thingy so I just stuck it in one big readme. I am deeply sorry about this :neofox_googly_shocked:
30
+
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
+
33
+ ### Authentication **(REQUIRED!!!)**
34
+ #### `Misskey.auth.instanceURI`
35
+ This sets the instance URI that your client will connect to. This and `Misskey.auth.token` are **required** when using Misskey.rb.
36
+
37
+ This can be used like a variable. You can change it or access it at any time. See some examples below:
38
+
39
+ Changing the value:
40
+ ```ruby
41
+ require "misskey"
42
+
43
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
44
+ ```
45
+
46
+ Calling the value:
47
+ ```ruby
48
+ require "misskey"
49
+
50
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
51
+
52
+ # Getting the value
53
+ puts Misskey.auth.instanceURI
54
+ ```
55
+
56
+ Pretty simple :neofox_floof_happy:
57
+
58
+ #### `Misskey.auth.token`
59
+ This sets the API key/token that your client will connect to. This and `Misskey.auth.instanceURI` are **required** when using Misskey.rb.
60
+
61
+ This can be used like a variable. You can change it or access it at any time. See some examples below:
62
+
63
+ Changing the value:
64
+ ```ruby
65
+ require "misskey"
66
+
67
+ Misskey.auth.token = "blahblahtokenweeewooooooo"
68
+ ```
69
+
70
+ Calling the value:
71
+ ```ruby
72
+ require "misskey"
73
+
74
+ Misskey.auth.token = "wafwaftokenaaaaaa"
75
+
76
+ # Getting the value
77
+ puts Misskey.auth.token
78
+ ```
79
+
80
+ You can also use this in pair with the `dotenv` module:
81
+ ```ruby
82
+ require "misskey"
83
+ require "dotenv"
84
+
85
+ Dotenv.load "./.env"
86
+ Misskey.auth.token = ENV["APIKey"]
87
+ ```
88
+
89
+ Also pretty simple :neofox_floof_happy:
90
+
91
+ ### Notes
92
+ #### `Misskey.notes.create`
93
+ Creates a note.
94
+
95
+ Order of arguments are as follows: `noteContent` also known as the body text (REQUIRED), `visibility`, `localonly`, `cw` also known as a content warning.
96
+
97
+ Visibility options include: `public`, `home`, `followers`, and `specified`. `specified` is also known as a direct note or private message.
98
+
99
+ Some examples:
100
+ ```ruby
101
+ require "misskey"
102
+
103
+ Misskey.auth.token = "tokenwaaaaaaa"
104
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
105
+
106
+ Misskey.notes.create "Hello world!! :neofox_floof:"
107
+ ```
108
+ It will automatically convert things like ":neofox_floof:" to their respective emojis as seen above.
109
+ ```ruby
110
+ require "misskey"
111
+
112
+ Misskey.auth.token = "tokenwaaaaaaa"
113
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
114
+
115
+ Misskey.notes.create "Hello there, this is a home note.", "home"
116
+ ```
117
+ The example above shows a client creating a note with the visibility "home"
118
+ ```ruby
119
+ require "misskey"
120
+
121
+ Misskey.auth.token = "tokenwaaaaaaa"
122
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
123
+
124
+ Misskey.notes.create "Hi this is local!", "public", true
125
+ ```
126
+ The example above shows a client creating a public local (aka defederated) note.
127
+ ```ruby
128
+ require "misskey"
129
+
130
+ Misskey.auth.token = "tokenwaaaaaaa"
131
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
132
+
133
+ Misskey.notes.create "Hi this is local and features a content warning!", "public", true, "Holy moly it's a post by me wow beware"
134
+ ```
135
+ As the note body suggests, this is a local note that has a content warning.
136
+
137
+ You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/notes/POST/notes/create) for more info.
138
+
139
+ #### `Misskey.notes.create.reply`
140
+ Very similar to `Misskey.notes.create` except it features a new required argument called `replyId`.
141
+
142
+ Arguments for this are as follows: `replyId` (REQUIRED), `noteContent` (REQUIRED), visibility, localOnly, cw
143
+
144
+ An example:
145
+ ```ruby
146
+ require "misskey"
147
+
148
+ Misskey.auth.token = "tokenwaaaaaaa"
149
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
150
+
151
+ Misskey.notes.create.reply "someReplyId", "Hello there, this is a reply."
152
+ ```
153
+ You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/notes/POST/notes/create) for more info.
154
+
155
+ #### `Misskey.notes.timeline`
156
+ 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
+
158
+ 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.
159
+ ```ruby
160
+ require "misskey"
161
+
162
+ Misskey.auth.token = "tokenwaaaaaaa"
163
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
164
+
165
+ puts Misskey.notes.timeline
166
+ ```
167
+ You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/notes/POST/notes/timeline) for more info.
168
+
169
+ ### `Misskey.getOnlineUsersCount`
170
+ Pretty self-explanatory, gets the number of users online. Using it is really simple, here's an example:
171
+ ```ruby
172
+ require "misskey"
173
+
174
+ Misskey.auth.token = "tokenwaaaaaaa"
175
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
176
+
177
+ puts "There are #{Misskey.getOnlineUsersCount} user(s) online right now!"
178
+ ```
179
+ Slightly more complicated example:
180
+ ```ruby
181
+ require "misskey"
182
+
183
+ Misskey.auth.token = "tokenwaaaaaaa"
184
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
185
+
186
+ case Misskey.getOnlineUserscount.to_i
187
+ when 0
188
+ puts "There are no users online :("
189
+ when 1
190
+ puts "There is 1 user online."
191
+ when > 1
192
+ puts "There are #{Misskey.getOnlineUserscount} users online"
193
+ end
194
+ ```
195
+ You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/meta/POST/get-online-users-count) for more info.
196
+
197
+ ### `Misskey.serverInfo`
198
+ Retrieves the instance/server information. Example:
199
+ ```ruby
200
+ require "misskey"
201
+
202
+ Misskey.auth.token = "tokenwaaaaaaa"
203
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
204
+
205
+ puts Misskey.serverInfo
206
+ ```
207
+ You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/meta/POST/server-info) for more info.
208
+
209
+ ### `Misskey.i`
210
+ Retrieves the information about the currently logged-in user. Example:
211
+ ```ruby
212
+ require "misskey"
213
+
214
+ Misskey.auth.token = "tokenwaaaaaaa"
215
+ Misskey.auth.instanceURI = "sharkey.skydevs.me"
216
+
217
+ puts Misskey.i
218
+ ```
219
+ You may refer to the [Misskey API docs](https://sharkey.skydevs.me/api-doc#tag/account/POST/i) for more info.
data/lib/misskey.rb CHANGED
@@ -54,6 +54,27 @@ module Misskey
54
54
  Creates.created.reply replyId, noteContent, visibility = "public", localOnly = false, cw = ""
55
55
  end
56
56
  end
57
+
58
+ def timeline limit = 10
59
+ instance = "https://#{Misskey.auth.instanceURI}/api/notes/timeline"
60
+
61
+ postJSON = <<EOF
62
+ {
63
+ "limit": #{limit}
64
+ }
65
+ EOF
66
+
67
+ request = HTTParty.post(
68
+ instance,
69
+ body: postJSON,
70
+ headers: {
71
+ "Content-Type" => "application/json",
72
+ "Authorization" => "Bearer #{Misskey.auth.token}"
73
+ }
74
+ )
75
+
76
+ return JSON.parse request.body
77
+ end
57
78
  end
58
79
 
59
80
  def getOnlineUsersCount
@@ -110,27 +131,6 @@ EOF
110
131
  "Authorization" => "Bearer #{Misskey.auth.token}"
111
132
  }
112
133
  )
113
-
114
- def timeline limit = 100
115
- instance = "https://#{Misskey.auth.instanceURI}/api/notes/timeline"
116
-
117
- postJSON = <<EOF
118
- {
119
- "limit": #{limit}
120
- }
121
- EOF
122
-
123
- request = HTTParty.post(
124
- instance,
125
- body: postJSON,
126
- headers: {
127
- "Content-Type" => "application/json",
128
- "Authorization" => "Bearer #{Misskey.auth.token}"
129
- }
130
- )
131
-
132
- return JSON.parse request.body
133
- end
134
134
 
135
135
  def notifications limit = 10
136
136
  instance = "https://#{Misskey.auth.instanceURI}/api/i/notifications"
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sky.Bit