Module: Misskey
- Defined in:
- lib/misskey.rb
Constant Summary collapse
- @@token =
nil- @@instanceURI =
nil
Instance Method Summary collapse
- #auth ⇒ Object
- #connect ⇒ Object
- #create(noteContent, visibility = "public", localOnly = false, cw = "") ⇒ Object
- #debug ⇒ Object
- #debugging ⇒ Object
- #debugging=(bool) ⇒ Object
- #getOnlineUsersCount ⇒ Object
- #i ⇒ Object
- #instanceURI ⇒ Object
- #instanceURI=(uri) ⇒ Object
- #notes ⇒ Object
- #notifications ⇒ Object
- #onMention(&block) ⇒ Object
- #onMentionOrReply(&block) ⇒ Object
- #onNotification(&block) ⇒ Object
- #onQuote(&block) ⇒ Object
- #onReaction(&block) ⇒ Object
- #onRenote(&block) ⇒ Object
- #onReply(&block) ⇒ Object
- #reply(replyId, noteContent, visibility = "public", localOnly = false, cw = "") ⇒ Object
- #serverInfo ⇒ Object
- #show(id) ⇒ Object
- #timeline(limit = 10) ⇒ Object
- #token ⇒ Object
- #token=(tkn) ⇒ Object
- #websocket ⇒ Object
Instance Method Details
#auth ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/misskey.rb', line 15 def auth def token return @@token end def token=(tkn) @@token = tkn end def instanceURI return @@instanceURI end def instanceURI=(uri) @@instanceURI = uri end end |
#create(noteContent, visibility = "public", localOnly = false, cw = "") ⇒ Object
44 45 46 |
# File 'lib/misskey.rb', line 44 def create noteContent, visibility = "public", localOnly = false, cw = "" Creates.created noteContent, visibility = "public", localOnly = false, cw = "" end |
#debug ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/misskey.rb', line 33 def debug def debugging return @@debugging end def debugging=(bool) @@debugging = bool end end |
#debugging ⇒ Object
34 35 36 |
# File 'lib/misskey.rb', line 34 def debugging return @@debugging end |
#debugging=(bool) ⇒ Object
38 39 40 |
# File 'lib/misskey.rb', line 38 def debugging=(bool) @@debugging = bool end |
#getOnlineUsersCount ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/misskey.rb', line 95 def getOnlineUsersCount instance = "https://#{Misskey.auth.instanceURI}/api/get-online-users-count" postJSON = <<EOF { "Bah": "bahbooey" } EOF request = HTTParty.post( instance, body: postJSON, headers: { "Content-Type" => "application/json" } ) return JSON.parse request.body end |
#i ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/misskey.rb', line 133 def i instance = "https://#{Misskey.auth.instanceURI}/api/i" postJSON = <<EOF { "Bah": "bahbooey" } EOF request = HTTParty.post( instance, body: postJSON, headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{Misskey.auth.token}" } ) def notifications limit = 10 instance = "https://#{Misskey.auth.instanceURI}/api/i/notifications" postJSON = <<EOF { "limit": #{limit} } EOF request = HTTParty.post( instance, body: postJSON, headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{Misskey.auth.token}" } ) return JSON.parse request.body end return JSON.parse request.body end |
#instanceURI ⇒ Object
24 25 26 |
# File 'lib/misskey.rb', line 24 def instanceURI return @@instanceURI end |
#instanceURI=(uri) ⇒ Object
28 29 30 |
# File 'lib/misskey.rb', line 28 def instanceURI=(uri) @@instanceURI = uri end |
#notes ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/misskey.rb', line 43 def notes def create noteContent, visibility = "public", localOnly = false, cw = "" Creates.created noteContent, visibility = "public", localOnly = false, cw = "" end def reply replyId, noteContent, visibility = "public", localOnly = false, cw = "" Creates.replied replyId, noteContent, visibility = "public", localOnly = false, cw = "" end def timeline limit = 10 instance = "https://#{Misskey.auth.instanceURI}/api/notes/timeline" postJSON = <<EOF { "limit": #{limit} } EOF request = HTTParty.post( instance, body: postJSON, headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{Misskey.auth.token}" } ) return JSON.parse request.body end def show id instance = "https://#{Misskey.auth.instanceURI}/api/notes/show" postJSON = <<EOF { "noteId": "#{id}" } EOF request = HTTParty.post( instance, body: postJSON, headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{Misskey.auth.token}" } ) return JSON.parse request.body end end |
#notifications ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/misskey.rb', line 150 def notifications limit = 10 instance = "https://#{Misskey.auth.instanceURI}/api/i/notifications" postJSON = <<EOF { "limit": #{limit} } EOF request = HTTParty.post( instance, body: postJSON, headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{Misskey.auth.token}" } ) return JSON.parse request.body end |
#onMention(&block) ⇒ Object
180 181 182 |
# File 'lib/misskey.rb', line 180 def onMention &block WS.n.oM block end |
#onMentionOrReply(&block) ⇒ Object
204 205 206 |
# File 'lib/misskey.rb', line 204 def onMentionOrReply &block WS.n.oMOR block end |
#onNotification(&block) ⇒ Object
192 193 194 |
# File 'lib/misskey.rb', line 192 def onNotification &block WS.n.oN block end |
#onQuote(&block) ⇒ Object
196 197 198 |
# File 'lib/misskey.rb', line 196 def onQuote &block WS.n.oQ block end |
#onReaction(&block) ⇒ Object
184 185 186 |
# File 'lib/misskey.rb', line 184 def onReaction &block WS.n.oR block end |
#onRenote(&block) ⇒ Object
188 189 190 |
# File 'lib/misskey.rb', line 188 def onRenote &block WS.n.oRe block end |
#onReply(&block) ⇒ Object
200 201 202 |
# File 'lib/misskey.rb', line 200 def onReply &block WS.n.oRep block end |
#reply(replyId, noteContent, visibility = "public", localOnly = false, cw = "") ⇒ Object
48 49 50 |
# File 'lib/misskey.rb', line 48 def reply replyId, noteContent, visibility = "public", localOnly = false, cw = "" Creates.replied replyId, noteContent, visibility = "public", localOnly = false, cw = "" end |
#serverInfo ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/misskey.rb', line 114 def serverInfo instance = "https://#{Misskey.auth.instanceURI}/api/server-info" postJSON = <<EOF { "Bah": "bahbooey" } EOF request = HTTParty.post( instance, body: postJSON, headers: { "Content-Type" => "application/json" } ) return JSON.parse request.body end |
#show(id) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/misskey.rb', line 73 def show id instance = "https://#{Misskey.auth.instanceURI}/api/notes/show" postJSON = <<EOF { "noteId": "#{id}" } EOF request = HTTParty.post( instance, body: postJSON, headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{Misskey.auth.token}" } ) return JSON.parse request.body end |
#timeline(limit = 10) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/misskey.rb', line 52 def timeline limit = 10 instance = "https://#{Misskey.auth.instanceURI}/api/notes/timeline" postJSON = <<EOF { "limit": #{limit} } EOF request = HTTParty.post( instance, body: postJSON, headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{Misskey.auth.token}" } ) return JSON.parse request.body end |
#token ⇒ Object
16 17 18 |
# File 'lib/misskey.rb', line 16 def token return @@token end |
#token=(tkn) ⇒ Object
20 21 22 |
# File 'lib/misskey.rb', line 20 def token=(tkn) @@token = tkn end |
#websocket ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/misskey.rb', line 174 def websocket def connect WS.c end def notifications def onMention &block WS.n.oM block end def onReaction &block WS.n.oR block end def onRenote &block WS.n.oRe block end def onNotification &block WS.n.oN block end def onQuote &block WS.n.oQ block end def onReply &block WS.n.oRep block end def onMentionOrReply &block WS.n.oMOR block end end end |