Module: Misskey
- Defined in:
- lib/misskey.rb
Constant Summary collapse
- @@token =
nil- @@instanceURI =
nil- @@onMentionDo =
[false, nil]
- @@debugging =
false- @@onReactionDo =
[false, nil]
- @@onRenoteDo =
[false, nil]
- @@onNotificationDo =
[false, nil]
- @@onQuoteDo =
[false, 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
- #onNotification(&block) ⇒ Object
- #onQuote(&block) ⇒ Object
- #onReaction(&block) ⇒ Object
- #onRenote(&block) ⇒ Object
- #reply(replyId, noteContent, visibility = "public", localOnly = false, cw = "") ⇒ Object
- #serverInfo ⇒ Object
- #timeline(limit = 100) ⇒ Object
- #token ⇒ Object
- #token=(tkn) ⇒ Object
- #websocket ⇒ Object
Instance Method Details
#auth ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/misskey.rb', line 21 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
50 51 52 53 54 55 56 |
# File 'lib/misskey.rb', line 50 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
39 40 41 42 43 44 45 46 47 |
# File 'lib/misskey.rb', line 39 def debug def debugging return @@debugging end def debugging=(bool) @@debugging = bool end end |
#debugging ⇒ Object
40 41 42 |
# File 'lib/misskey.rb', line 40 def debugging return @@debugging end |
#debugging=(bool) ⇒ Object
44 45 46 |
# File 'lib/misskey.rb', line 44 def debugging=(bool) @@debugging = bool end |
#getOnlineUsersCount ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/misskey.rb', line 59 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
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 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 152 153 154 155 156 157 |
# File 'lib/misskey.rb', line 97 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 timeline limit = 100 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 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
30 31 32 |
# File 'lib/misskey.rb', line 30 def instanceURI return @@instanceURI end |
#instanceURI=(uri) ⇒ Object
34 35 36 |
# File 'lib/misskey.rb', line 34 def instanceURI=(uri) @@instanceURI = uri end |
#notes ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/misskey.rb', line 49 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 end |
#notifications ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/misskey.rb', line 135 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
165 166 167 |
# File 'lib/misskey.rb', line 165 def onMention &block WS.n.oM block end |
#onNotification(&block) ⇒ Object
177 178 179 |
# File 'lib/misskey.rb', line 177 def onNotification &block WS.n.oN block end |
#onQuote(&block) ⇒ Object
181 182 183 |
# File 'lib/misskey.rb', line 181 def onQuote &block WS.n.oQ block end |
#onReaction(&block) ⇒ Object
169 170 171 |
# File 'lib/misskey.rb', line 169 def onReaction &block WS.n.oR block end |
#onRenote(&block) ⇒ Object
173 174 175 |
# File 'lib/misskey.rb', line 173 def onRenote &block WS.n.oRe block end |
#reply(replyId, noteContent, visibility = "public", localOnly = false, cw = "") ⇒ Object
53 54 55 |
# File 'lib/misskey.rb', line 53 def reply replyId, noteContent, visibility = "public", localOnly = false, cw = "" Creates.created.reply replyId, noteContent, visibility = "public", localOnly = false, cw = "" end |
#serverInfo ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/misskey.rb', line 78 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 = 100) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/misskey.rb', line 114 def timeline limit = 100 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
22 23 24 |
# File 'lib/misskey.rb', line 22 def token return @@token end |
#token=(tkn) ⇒ Object
26 27 28 |
# File 'lib/misskey.rb', line 26 def token=(tkn) @@token = tkn end |
#websocket ⇒ Object
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 |
# File 'lib/misskey.rb', line 159 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 end end |