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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d146d73f8ec0fa6fcd8e5f895ab6cb601c024241
4
- data.tar.gz: 8484ae9c72e87808339fb15fa878d40bb3ca779d
3
+ metadata.gz: 3ab08bb7b694166f30bd533ca85c4eeed94e20d6
4
+ data.tar.gz: 8dfd2e2d90b7e9c479588ae64bf3378168831baa
5
5
  SHA512:
6
- metadata.gz: 075e8dcb66e72069c33634ab00206e70d7a351526fd1436762886232a7140dac7f6006a61296717393d9103db909dd35b32da1d84229af5757724e661942b33e
7
- data.tar.gz: b54082106ba18dd46dfce12aa23a89f6ed4b9fe104e13d7cf0ffed37a76fef2db8c74afd5f95c3fca5daa34814b28c433f7ef2aec62d3407f4cf47067c860243
6
+ metadata.gz: dba466fd8d24244679c8323330463835a515686a52dbda66159e1f893f2cc311960f52887e775ae60a7d6e145213a8ee21788c49aba7380b9252b003968c21bd
7
+ data.tar.gz: 727f2ed736751f175cf4b4b0acabb44a06bf682140a2ccd538d7b48e4564b50cf6c7307f851ae8d09d36409a403cc6d9e7c5621a1ce5dcb0befa996b19437ad5
@@ -4,7 +4,7 @@ gem "json"
4
4
 
5
5
  gem "nethttputils", git: "git@github.com:Nakilon/nethttputils.git"
6
6
 
7
- gem "reddit_bot", "~>1.6.1"
7
+ gem "reddit_bot", "~>1.6.2"
8
8
  gem "nokogiri"
9
9
 
10
10
  gem "imgur2array", git: "git@github.com:Nakilon/imgur2array.git"
@@ -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.1)
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.1)
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
- NetHTTPUtils.request_data(url, mtd, form: form, header: headers, auth: base_auth) do |response|
210
- next unless remaining = response.to_hash["x-ratelimit-remaining"]
211
- if Gem::Platform.local.os == "darwin"
212
- puts %w{
213
- x-ratelimit-remaining
214
- x-ratelimit-used
215
- x-ratelimit-reset
216
- }.map{ |key| "#{key}=#{response.to_hash[key]}" }.join ", "
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
- fail remaining[0] if remaining[0].size < 4
219
- next if remaining[0].size > 4
220
- t = (response.to_hash["x-ratelimit-reset"][0].to_f + 1) / [remaining[0].to_f - 10, 1].max + 1
221
- puts "sleeping #{t} seconds because of x-ratelimit"
222
- sleep t
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
 
@@ -1,3 +1,3 @@
1
1
  module RedditBot
2
- VERSION = "1.6.2" # :nodoc:
2
+ VERSION = "1.6.3" # :nodoc:
3
3
  end
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.2
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-04 00:00:00.000000000 Z
11
+ date: 2018-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json