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
- #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 47 48 49 50 |
# File 'lib/misskey.rb', line 44 def create noteContent, visibility = "public", localOnly = false, cw = "" Creates.created noteContent, visibility = "public", localOnly = false, cw = "" def reply replyId, noteContent, visibility = "public", localOnly = false, cw = "" Creates.created.reply replyId, noteContent, visibility = "public", localOnly = false, cw = "" end 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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/misskey.rb', line 74 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
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/misskey.rb', line 112 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 |
# File 'lib/misskey.rb', line 43 def notes def create noteContent, visibility = "public", localOnly = false, cw = "" Creates.created noteContent, visibility = "public", localOnly = false, cw = "" def reply replyId, noteContent, visibility = "public", localOnly = false, cw = "" Creates.created.reply replyId, noteContent, visibility = "public", localOnly = false, cw = "" end 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 end |
#notifications ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/misskey.rb', line 129 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
159 160 161 |
# File 'lib/misskey.rb', line 159 def onMention &block WS.n.oM block end |
#onMentionOrReply(&block) ⇒ Object
183 184 185 |
# File 'lib/misskey.rb', line 183 def onMentionOrReply &block WS.n.oMOR block end |
#onNotification(&block) ⇒ Object
171 172 173 |
# File 'lib/misskey.rb', line 171 def onNotification &block WS.n.oN block end |
#onQuote(&block) ⇒ Object
175 176 177 |
# File 'lib/misskey.rb', line 175 def onQuote &block WS.n.oQ block end |
#onReaction(&block) ⇒ Object
163 164 165 |
# File 'lib/misskey.rb', line 163 def onReaction &block WS.n.oR block end |
#onRenote(&block) ⇒ Object
167 168 169 |
# File 'lib/misskey.rb', line 167 def onRenote &block WS.n.oRe block end |
#onReply(&block) ⇒ Object
179 180 181 |
# File 'lib/misskey.rb', line 179 def onReply &block WS.n.oRep block end |
#reply(replyId, noteContent, visibility = "public", localOnly = false, cw = "") ⇒ Object
47 48 49 |
# File 'lib/misskey.rb', line 47 def reply replyId, noteContent, visibility = "public", localOnly = false, cw = "" Creates.created.reply replyId, noteContent, visibility = "public", localOnly = false, cw = "" end |
#serverInfo ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/misskey.rb', line 93 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 |
#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
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/misskey.rb', line 153 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 |