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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed538f85641e24b1db67d460183ef732ab44ee72
4
- data.tar.gz: 07702ff0d6b95ffdb0f4877b922f09fc339fe8a8
3
+ metadata.gz: d146d73f8ec0fa6fcd8e5f895ab6cb601c024241
4
+ data.tar.gz: 8484ae9c72e87808339fb15fa878d40bb3ca779d
5
5
  SHA512:
6
- metadata.gz: 07bc678bf7a32015325f7ba18f9343da143791a7b2b37771400dfb1fb7359728f460f9c475978b50a2a9d0eb729ac373e58e4774afbb70de719258d17e9b3fbc
7
- data.tar.gz: 00fb4e6b37364087b6b80c08af5a4355ac1398b525091afc01da697678de0b1f60b16c315427cdb13b99fa949e4a3862a525b7b006f30cc35a54b86ba2c29d7e
6
+ metadata.gz: 075e8dcb66e72069c33634ab00206e70d7a351526fd1436762886232a7140dac7f6006a61296717393d9103db909dd35b32da1d84229af5757724e661942b33e
7
+ data.tar.gz: b54082106ba18dd46dfce12aa23a89f6ed4b9fe104e13d7cf0ffed37a76fef2db8c74afd5f95c3fca5daa34814b28c433f7ef2aec62d3407f4cf47067c860243
@@ -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.0"
7
+ gem "reddit_bot", "~>1.6.1"
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.0)
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.0)
115
+ reddit_bot (~> 1.6.1)
116
116
  url2dimensions!
117
117
 
118
118
  BUNDLED WITH
@@ -1,3 +1,3 @@
1
1
  module RedditBot
2
- VERSION = "1.6.1" # :nodoc:
2
+ VERSION = "1.6.2" # :nodoc:
3
3
  end
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
- reddit_resp mtd, "https://oauth.reddit.com" + path, form, {
195
- "Authorization" => "bearer #{token}",
196
- "User-Agent" => "bot/#{@username}/#{RedditBot::VERSION} by /u/nakilon",
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reddit_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Maslov