reddit_bot 1.6.2 → 1.6.3
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.rb +21 -14
- data/lib/reddit_bot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ab08bb7b694166f30bd533ca85c4eeed94e20d6
|
4
|
+
data.tar.gz: 8dfd2e2d90b7e9c479588ae64bf3378168831baa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dba466fd8d24244679c8323330463835a515686a52dbda66159e1f893f2cc311960f52887e775ae60a7d6e145213a8ee21788c49aba7380b9252b003968c21bd
|
7
|
+
data.tar.gz: 727f2ed736751f175cf4b4b0acabb44a06bf682140a2ccd538d7b48e4564b50cf6c7307f851ae8d09d36409a403cc6d9e7c5621a1ce5dcb0befa996b19437ad5
|
@@ -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.2)
|
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.2)
|
116
116
|
url2dimensions!
|
117
117
|
|
118
118
|
BUNDLED WITH
|
data/lib/reddit_bot.rb
CHANGED
@@ -197,7 +197,7 @@ module RedditBot
|
|
197
197
|
"User-Agent" => "bot/#{@username}/#{RedditBot::VERSION} by /u/nakilon",
|
198
198
|
}
|
199
199
|
rescue NetHTTPUtils::Error => e
|
200
|
-
sleep 5
|
200
|
+
# sleep 5
|
201
201
|
raise unless e.code == 401
|
202
202
|
@token_cached = nil
|
203
203
|
retry
|
@@ -206,20 +206,27 @@ module RedditBot
|
|
206
206
|
|
207
207
|
def reddit_resp *args
|
208
208
|
mtd, url, form, headers, base_auth = *args
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
209
|
+
begin
|
210
|
+
NetHTTPUtils.request_data(url, mtd, form: form, header: headers, auth: base_auth) do |response|
|
211
|
+
next unless remaining = response.to_hash["x-ratelimit-remaining"]
|
212
|
+
if Gem::Platform.local.os == "darwin"
|
213
|
+
puts %w{
|
214
|
+
x-ratelimit-remaining
|
215
|
+
x-ratelimit-used
|
216
|
+
x-ratelimit-reset
|
217
|
+
}.map{ |key| "#{key}=#{response.to_hash[key]}" }.join ", "
|
218
|
+
end
|
219
|
+
fail remaining[0] if remaining[0].size < 4
|
220
|
+
next if remaining[0].size > 4
|
221
|
+
t = (response.to_hash["x-ratelimit-reset"][0].to_f + 1) / [remaining[0].to_f - 10, 1].max + 1
|
222
|
+
puts "sleeping #{t} seconds because of x-ratelimit"
|
223
|
+
sleep t
|
217
224
|
end
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
puts "
|
222
|
-
|
225
|
+
rescue NetHTTPUtils::Error => e
|
226
|
+
sleep 5
|
227
|
+
raise unless e.code == 503
|
228
|
+
puts "API ERROR 503"
|
229
|
+
retry
|
223
230
|
end
|
224
231
|
end
|
225
232
|
|
data/lib/reddit_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reddit_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|