reddit_bot 1.6.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/largeimages/Gemfile +1 -1
- data/examples/largeimages/Gemfile.lock +2 -2
- data/lib/reddit_bot/version.rb +1 -1
- data/lib/reddit_bot.rb +11 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d146d73f8ec0fa6fcd8e5f895ab6cb601c024241
|
4
|
+
data.tar.gz: 8484ae9c72e87808339fb15fa878d40bb3ca779d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 075e8dcb66e72069c33634ab00206e70d7a351526fd1436762886232a7140dac7f6006a61296717393d9103db909dd35b32da1d84229af5757724e661942b33e
|
7
|
+
data.tar.gz: b54082106ba18dd46dfce12aa23a89f6ed4b9fe104e13d7cf0ffed37a76fef2db8c74afd5f95c3fca5daa34814b28c433f7ef2aec62d3407f4cf47067c860243
|
@@ -90,7 +90,7 @@ GEM
|
|
90
90
|
mini_portile2 (~> 2.1.0)
|
91
91
|
os (0.9.6)
|
92
92
|
public_suffix (2.0.5)
|
93
|
-
reddit_bot (1.6.
|
93
|
+
reddit_bot (1.6.1)
|
94
94
|
json
|
95
95
|
rly (0.2.3)
|
96
96
|
signet (0.8.1)
|
@@ -112,7 +112,7 @@ DEPENDENCIES
|
|
112
112
|
json
|
113
113
|
nethttputils!
|
114
114
|
nokogiri
|
115
|
-
reddit_bot (~> 1.6.
|
115
|
+
reddit_bot (~> 1.6.1)
|
116
116
|
url2dimensions!
|
117
117
|
|
118
118
|
BUNDLED WITH
|
data/lib/reddit_bot/version.rb
CHANGED
data/lib/reddit_bot.rb
CHANGED
@@ -191,15 +191,21 @@ module RedditBot
|
|
191
191
|
|
192
192
|
def resp_with_token mtd, path, form
|
193
193
|
fail unless path.start_with? ?/
|
194
|
-
|
195
|
-
"
|
196
|
-
|
197
|
-
|
194
|
+
begin
|
195
|
+
reddit_resp mtd, "https://oauth.reddit.com" + path, form, {
|
196
|
+
"Authorization" => "bearer #{token}",
|
197
|
+
"User-Agent" => "bot/#{@username}/#{RedditBot::VERSION} by /u/nakilon",
|
198
|
+
}
|
199
|
+
rescue NetHTTPUtils::Error => e
|
200
|
+
sleep 5
|
201
|
+
raise unless e.code == 401
|
202
|
+
@token_cached = nil
|
203
|
+
retry
|
204
|
+
end
|
198
205
|
end
|
199
206
|
|
200
207
|
def reddit_resp *args
|
201
208
|
mtd, url, form, headers, base_auth = *args
|
202
|
-
begin
|
203
209
|
NetHTTPUtils.request_data(url, mtd, form: form, header: headers, auth: base_auth) do |response|
|
204
210
|
next unless remaining = response.to_hash["x-ratelimit-remaining"]
|
205
211
|
if Gem::Platform.local.os == "darwin"
|
@@ -215,12 +221,6 @@ module RedditBot
|
|
215
221
|
puts "sleeping #{t} seconds because of x-ratelimit"
|
216
222
|
sleep t
|
217
223
|
end
|
218
|
-
rescue NetHTTPUtils::Error => e
|
219
|
-
sleep 5
|
220
|
-
raise unless e.code == 401
|
221
|
-
@token_cached = nil
|
222
|
-
retry
|
223
|
-
end
|
224
224
|
end
|
225
225
|
|
226
226
|
end
|