reddit_bot 1.6.13 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 645a6f7aaf1ab61bbc83b3a4d3a7d57f8f305e1a
4
- data.tar.gz: 6a76531bfabed4d18796d6a25fce201113e07407
3
+ metadata.gz: f0c06107eb4207ba45e047f0215189bd5fe47fc2
4
+ data.tar.gz: e0d609e5b43af0229d3b8f96b0f9dd406635ae56
5
5
  SHA512:
6
- metadata.gz: 59c592e1b11fac0a770a17e2d25a7283d08b49d79b4e5f414d495a1762ad1abdbedd09af84614b39a0f87a24c77d7ea309111eff0b2d0d0c87751723445c9aa8
7
- data.tar.gz: 3dd6469209d4991668f60d8658115a6ffd9be6e77a209cd05d740c96475213f64cfa829b1854c57000cfe1507c41c6e700ec90935b955823da98a2ddc99d14c9
6
+ metadata.gz: 4978e63e9a25c61094f15db396f274099e4ccf9f475fb1c71b630d9fe717cd07764a29fd3bb56533cedc55e071a79cd1a37911255635663d2f20d7c7507931bc
7
+ data.tar.gz: 07cf64c0550cb8505a2dfb87b86bf503680ac24c3020ba3791aede79fe9ea452fd307a164b8abf647f9bca311eb124ed18b117d2b0e64e1e44f7f856d62bdd13
data/README.md CHANGED
@@ -67,9 +67,11 @@ or via Gemfile:
67
67
 
68
68
  helloworld.rb:
69
69
 
70
- require "reddit_bot"
70
+ ```ruby
71
+ require "reddit_bot"
72
+ ```
71
73
 
72
- You obviously can't run these examples as is, because they use some dependencies that are not in git repo, like `secrets.yaml` file for Reddit authorization of the following format:
74
+ You obviously can't run these examples as is, because they use local configs that are not in git repo, like `secrets.yaml` file for Reddit authorization of the following format:
73
75
 
74
76
  :client_id: Kb9.......6wBw
75
77
  :client_secret: Fqo.....................AFI
@@ -77,6 +79,12 @@ You obviously can't run these examples as is, because they use some dependencies
77
79
  :login: MyBotUsername
78
80
  # :user_agent: optional_custom_useragent_to_bypass_reddit_spam_protection
79
81
 
82
+ To change the log level:
83
+
84
+ ```ruby
85
+ RedditBot.logger.level = Logger::ERROR
86
+ ```
87
+
80
88
  To update the gem version in Gemfile.lock when using Gemfile like this: `gem "reddit_bot", "~>1.1.0"`, do the:
81
89
 
82
90
  $ bundle update reddit_bot
@@ -1,35 +1,17 @@
1
- GIT
2
- remote: git@github.com:Nakilon/imgur2array.git
3
- revision: eea2aa8a39d72726318aae8805b66bcddd7acbb6
4
- tag: v0.0.2.7
5
- specs:
6
- imgur2array (0.0.2.7)
7
-
8
- GIT
9
- remote: git@github.com:Nakilon/nethttputils.git
10
- revision: 84ac32db6d44b68f5bd6e2f1ce8698fc5e2ad968
11
- tag: v0.0.4.1
12
- specs:
13
- nethttputils (0.0.4.1)
14
-
15
1
  GEM
16
2
  remote: https://rubygems.org/
17
3
  specs:
18
- addressable (2.5.2)
19
- public_suffix (>= 2.0.2, < 4.0)
20
- fastimage (1.7.0)
21
- addressable (~> 2.3, >= 2.3.5)
22
4
  json (2.1.0)
23
- public_suffix (2.0.5)
5
+ nethttputils (0.2.5.1)
6
+ reddit_bot (1.6.13)
7
+ json
8
+ nethttputils (~> 0.2.5.1)
24
9
 
25
10
  PLATFORMS
26
11
  ruby
27
12
 
28
13
  DEPENDENCIES
29
- fastimage (= 1.7.0)
30
- imgur2array!
31
- json
32
- nethttputils!
14
+ reddit_bot
33
15
 
34
16
  BUNDLED WITH
35
- 1.16.0
17
+ 1.17.1
@@ -1,6 +1,6 @@
1
1
  require_relative "../boilerplate"
2
2
 
3
- BOT = RedditBot::Bot.new YAML.load File.read "secrets.yaml"
3
+ BOT = RedditBot::Bot.new YAML.load_file "secrets.yaml"
4
4
  SUBREDDIT = "CouncilOfRicks"
5
5
 
6
6
  CSS_CLASS = "blueflair"
@@ -1,5 +1,5 @@
1
1
  require_relative "../boilerplate"
2
- BOT = RedditBot::Bot.new YAML.load File.read "secrets.yaml"
2
+ BOT = RedditBot::Bot.new YAML.load_file "secrets.yaml"
3
3
 
4
4
  require "gcplogger"
5
5
  logger = GCPLogger.logger "cptflairbot3"
@@ -4,7 +4,7 @@
4
4
  # so it's possible to miss if bot is down for a while but in fact it's enough stable and does not go down.
5
5
 
6
6
  require_relative "../boilerplate"
7
- BOT = RedditBot::Bot.new YAML.load File.read "secrets.yaml"
7
+ BOT = RedditBot::Bot.new YAML.load_file "secrets.yaml"
8
8
 
9
9
  fail("no ENV['ERROR_REPORTING_KEYFILE'] specified") unless ENV["ERROR_REPORTING_KEYFILE"]
10
10
  require "google/cloud/error_reporting"
@@ -85,7 +85,7 @@ GEM
85
85
  mini_portile2 (~> 2.3.0)
86
86
  os (0.9.6)
87
87
  public_suffix (2.0.5)
88
- reddit_bot (1.6.10)
88
+ reddit_bot (1.6.13)
89
89
  json
90
90
  nethttputils (~> 0.2.5.1)
91
91
  rly (0.2.3)
@@ -16,7 +16,7 @@ require "directlink"
16
16
  require "nokogiri"
17
17
 
18
18
  require "../boilerplate"
19
- BOT = RedditBot::Bot.new YAML.load File.read "secrets.yaml"
19
+ BOT = RedditBot::Bot.new YAML.load_file "secrets.yaml"
20
20
 
21
21
  INCLUDE = %w{
22
22
  user/kjoneslol/m/sfwpornnetwork
@@ -1,6 +1,6 @@
1
1
  require_relative File.join "../boilerplate"
2
2
 
3
- BOT = RedditBot::Bot.new YAML.load File.read "secrets.yaml"
3
+ BOT = RedditBot::Bot.new YAML.load_file "secrets.yaml"
4
4
 
5
5
  SUBREDDIT = "codcompetitive"
6
6
 
@@ -2,7 +2,7 @@ GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
4
  json (2.1.0)
5
- reddit_bot (1.3.0)
5
+ reddit_bot (1.3.1)
6
6
  json
7
7
 
8
8
  PLATFORMS
@@ -12,4 +12,4 @@ DEPENDENCIES
12
12
  reddit_bot (~> 1.3.0)
13
13
 
14
14
  BUNDLED WITH
15
- 1.13.1
15
+ 1.17.1
@@ -4,7 +4,6 @@ BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: tr
4
4
  SUBREDDIT = "sexypizza"
5
5
 
6
6
  loop do
7
- Hearthbeat.beat "u_SexyPizzaBot_r_sexypizza", 3610 unless Gem::Platform.local.os == "darwin"
8
7
  puts "LOOP #{Time.now}"
9
8
 
10
9
  flairs = BOT.json(:get, "/r/#{SUBREDDIT}/api/flairlist", {limit: 1000})["users"]
@@ -1,5 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "fastimage", "1.7.0"
4
- gem "reddit_bot", "~>1.3.0"
5
- gem "net_http_utils", ?0, gist: "97549ceb58d21e1fcbc0e6cdaf92fce8"
3
+ gem "nokogiri", "~>1.6.7" # Ruby 2.0
4
+ gem "public_suffix", "<3.0" # Ruby 2.0
5
+ gem "directlink"
@@ -1,26 +1,33 @@
1
- GIT
2
- remote: https://gist.github.com/97549ceb58d21e1fcbc0e6cdaf92fce8.git
3
- revision: 54c47ab3f9665f3e35a8e94fdd267e3743c736a9
4
- specs:
5
- net_http_utils (0)
6
-
7
1
  GEM
8
2
  remote: https://rubygems.org/
9
3
  specs:
10
- addressable (2.3.8)
11
- fastimage (1.7.0)
12
- addressable (~> 2.3, >= 2.3.5)
4
+ addressable (2.5.2)
5
+ public_suffix (>= 2.0.2, < 4.0)
6
+ directlink (0.0.4.7)
7
+ addressable
8
+ fastimage (~> 2.1.3)
9
+ kramdown
10
+ nokogiri
11
+ reddit_bot (~> 1.6.13)
12
+ fastimage (2.1.5)
13
13
  json (2.1.0)
14
- reddit_bot (1.3.0)
14
+ kramdown (1.17.0)
15
+ mini_portile2 (2.1.0)
16
+ nethttputils (0.2.5.1)
17
+ nokogiri (1.6.8.1)
18
+ mini_portile2 (~> 2.1.0)
19
+ public_suffix (2.0.5)
20
+ reddit_bot (1.6.13)
15
21
  json
22
+ nethttputils (~> 0.2.5.1)
16
23
 
17
24
  PLATFORMS
18
25
  ruby
19
26
 
20
27
  DEPENDENCIES
21
- fastimage (= 1.7.0)
22
- net_http_utils (= 0)!
23
- reddit_bot (~> 1.3.0)
28
+ directlink
29
+ nokogiri (~> 1.6.7)
30
+ public_suffix (< 3.0)
24
31
 
25
32
  BUNDLED WITH
26
- 1.13.1
33
+ 1.17.1
@@ -1,31 +1,25 @@
1
1
  require_relative "../boilerplate"
2
2
 
3
- BOT = RedditBot::Bot.new YAML.load File.read "secrets.yaml"
3
+ BOT = RedditBot::Bot.new YAML.load_file "secrets.yaml"
4
4
  SUBREDDIT = "wallpaper"
5
5
 
6
- if Gem::Platform.local.os == "darwin"
7
- require_relative "../../../../dimensioner/get_dimensions"
8
- else
9
- require_relative "#{Dir.home}/get_dimensions"
10
- end
6
+ require "directlink"
11
7
 
12
8
  checked = []
13
9
  loop do
14
- Hearthbeat.beat "u_wallpaperpedantbot_r_#{SUBREDDIT}", 70 unless Gem::Platform.local.os == "darwin"
15
10
  puts "LOOP #{Time.now}"
16
11
 
17
12
  BOT.json(:get, "/r/#{SUBREDDIT}/new")["data"]["children"].each do |post|
18
13
  id, url, title, subreddit = post["data"].values_at(*%w{ id url title subreddit })
19
14
  next if checked.include? id
20
15
  checked.push id
21
- next puts "skipped #{url} from http://redd.it/#{id}" if :skipped == _ = GetDimensions::get_dimensions(url)
22
- next puts "unable #{url} from http://redd.it/#{id}" unless _
23
- width, height, best_direct_url, *all_direct_urls = _
24
-
25
- resolution = "#{width}x#{height}"
26
- result = title[/\s*\[?#{width}\s*[*x×]\s*#{height}\]?\s*/i]
27
- puts "#{!!result} #{id} [#{resolution}] #{title} #{url}"
28
- BOT.report "true resolution is #{resolution}", "t3_#{id}" unless result
16
+ t = DirectLink url
17
+ (t.is_a?(Array) ? t : [t]).each do |s|
18
+ resolution = "#{s.width}x#{s.height}"
19
+ result = title[/\s*\[?#{s.width}\s*[*x×]\s*#{s.height}\]?\s*/i]
20
+ puts "#{!!result} #{id} [#{resolution}] #{title} #{s.url}"
21
+ BOT.report "true resolution is #{resolution}", "t3_#{id}" unless result
22
+ end
29
23
  end
30
24
 
31
25
  puts "END LOOP #{Time.now}"
@@ -2,7 +2,7 @@ GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
4
  json (2.1.0)
5
- reddit_bot (1.3.0)
5
+ reddit_bot (1.3.1)
6
6
  json
7
7
 
8
8
  PLATFORMS
@@ -12,4 +12,4 @@ DEPENDENCIES
12
12
  reddit_bot (~> 1.3.0)
13
13
 
14
14
  BUNDLED WITH
15
- 1.13.1
15
+ 1.17.1
@@ -4,7 +4,6 @@ SUBREDDIT = "yayornay"
4
4
  BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), subreddit: SUBREDDIT
5
5
 
6
6
  loop do
7
- Hearthbeat.beat "u_gotfan247_r_yayornay", 310 unless Gem::Platform.local.os == "darwin"
8
7
  puts "LOOP #{Time.now}"
9
8
 
10
9
  BOT.each_new_post_with_top_level_comments do |post, comments|
data/lib/reddit_bot.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  STDOUT.sync = true
2
2
  # require "pp"
3
3
 
4
- require "net/http"
5
4
  require "openssl"
6
5
  require "json"
7
6
 
@@ -228,13 +227,16 @@ module RedditBot
228
227
 
229
228
  def resp_with_token mtd, path, form
230
229
  fail unless path.start_with? ?/
230
+ timeout = 5
231
231
  begin
232
232
  reddit_resp mtd, "https://oauth.reddit.com" + path, form, {
233
233
  "Authorization" => "bearer #{token}",
234
234
  "User-Agent" => "bot/#{@user_agent || @name}/#{RedditBot::VERSION} by /u/nakilon",
235
235
  }
236
236
  rescue NetHTTPUtils::Error => e
237
- sleep 5
237
+ sleep timeout
238
+ Module.nesting[1].logger.info "sleeping #{timeout} seconds because of #{e.code}"
239
+ timeout *= 2
238
240
  raise unless e.code == 401
239
241
  @token_cached = nil
240
242
  retry
@@ -1,3 +1,3 @@
1
1
  module RedditBot
2
- VERSION = "1.6.13" # :nodoc:
2
+ VERSION = "1.7.0" # :nodoc:
3
3
  end
data/reddit_bot.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  # spec.require_paths = ["lib"]
16
16
 
17
17
  spec.add_runtime_dependency "json"
18
- spec.add_runtime_dependency "nethttputils", "~>0.2.5.1"
18
+ spec.add_runtime_dependency "nethttputils", "~>0.3.1.0"
19
19
  # spec.add_development_dependency "bundler", "~> 1.11"
20
20
  # spec.add_development_dependency "rake", "~> 10.0"
21
21
  # spec.add_development_dependency "rspec", "~> 3.0"
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.13
4
+ version: 1.7.0
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-12-03 00:00:00.000000000 Z
11
+ date: 2018-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.5.1
33
+ version: 0.3.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.5.1
40
+ version: 0.3.1.0
41
41
  description: better than PRAW
42
42
  email:
43
43
  - nakilon@gmail.com