reddit_bot 1.2.0 → 1.2.2
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 +4 -4
- data/README.md +4 -5
- data/examples/councilofricks/Gemfile +4 -0
- data/examples/councilofricks/Gemfile.lock +22 -0
- data/examples/{flairmotron → councilofricks}/main.rb +4 -5
- data/examples/{flairmotron → cptflairbot3}/Gemfile +0 -0
- data/examples/{flairmotron → cptflairbot3}/Gemfile.lock +0 -0
- data/examples/{pokemon_trading → cptflairbot3}/main.rb +5 -6
- data/examples/devflairbot/Gemfile +1 -0
- data/examples/devflairbot/Gemfile.lock +8 -1
- data/examples/devflairbot/main.rb +7 -8
- data/examples/mlgtv/Gemfile +1 -1
- data/examples/mlgtv/Gemfile.lock +2 -2
- data/examples/mlgtv/main.rb +7 -3
- data/examples/oneplus/Gemfile +2 -6
- data/examples/oneplus/Gemfile.lock +8 -1
- data/examples/oneplus/main.rb +11 -21
- data/examples/sexypizza/main.rb +1 -1
- data/examples/wallpaper/Gemfile +1 -1
- data/examples/wallpaper/Gemfile.lock +7 -0
- data/examples/wallpaper/main.rb +4 -5
- data/examples/yayornay/main.rb +2 -5
- data/lib/reddit_bot.rb +6 -5
- metadata +9 -8
- data/examples/pokemon_trading/Gemfile +0 -7
- data/examples/pokemon_trading/Gemfile.lock +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a2cc85bddbbc5aeee82fd5084eae257f1413340
|
4
|
+
data.tar.gz: 1de2e501873e4fa303e0223ceeed4a9b9c367334
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b25c329d7d3ee4f87651a6f4deff8e76abff139b924f15d24168d9c0132edbe7dad46acbfce38ccd7af8fc2ebb13bed2f3978b7182926247e129a969691437a5
|
7
|
+
data.tar.gz: b14a6b1ab5f03bbaff46aa013a217f7dffb9aa9ba9bfe1fc702c454d2c2f46c8800441a07066859b781859f8707666744c7e5a3e887a51425337c7f9867d0e68
|
data/README.md
CHANGED
@@ -17,13 +17,12 @@ Python (and so PRAW) sucks.
|
|
17
17
|
The [examples folder](examples) includes:
|
18
18
|
|
19
19
|
* sexypizza -- bot that updates wiki page with current flairs statistics
|
20
|
-
* mlgtv -- bot that updates sidebar with currently streaming twitch channels
|
21
|
-
* flairmotron -- bot that flairs users according to Google Spreadsheet
|
22
20
|
* devflairbot -- bot that flairs posts when some specifically flaired user comments there
|
23
|
-
*
|
24
|
-
*
|
25
|
-
* oneplus -- bot that removes and modmails about links to 1080x1920 images
|
21
|
+
* mlgtv -- bot that updates sidebar with currently streaming twitch channels
|
22
|
+
* councilofricks -- bot that flairs users according to Google Spreadsheet
|
26
23
|
* wallpaper -- bot that reports images with dimensions not the same as in title
|
24
|
+
* cptflairbot3 -- bot that sets flair to user according to request submitted via PM
|
25
|
+
* oneplus -- bot that removes and modmails about links to 1080x1920 images
|
27
26
|
* yayornay -- bot that flairs posts according to voting in top level comments
|
28
27
|
* largeimagesreview -- useful script for [subreddit /r/largeimages](https://reddit.com/r/largeimages/top)
|
29
28
|
It calculates quality of x-posts from different subreddits based on mods activity (remove/approve).
|
@@ -0,0 +1,22 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://gist.github.com/97549ceb58d21e1fcbc0e6cdaf92fce8.git
|
3
|
+
revision: 54c47ab3f9665f3e35a8e94fdd267e3743c736a9
|
4
|
+
specs:
|
5
|
+
net_http_utils (0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
json (2.0.2)
|
11
|
+
reddit_bot (1.2.0)
|
12
|
+
json
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
net_http_utils (= 0)!
|
19
|
+
reddit_bot (~> 1.2.0)
|
20
|
+
|
21
|
+
BUNDLED WITH
|
22
|
+
1.13.1
|
@@ -1,19 +1,17 @@
|
|
1
1
|
require_relative "../boilerplate"
|
2
2
|
|
3
|
-
BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: true
|
3
|
+
BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: true
|
4
4
|
SUBREDDIT = "CouncilOfRicks"
|
5
5
|
|
6
6
|
CSS_CLASS = "blueflair"
|
7
7
|
|
8
|
-
# require "open-uri"
|
9
|
-
# require "json"
|
10
8
|
require "csv"
|
11
9
|
|
12
10
|
loop do
|
13
|
-
|
11
|
+
Hearthbeat.beat "u_FlairMoTron_r_CouncilOfRicks", 310 unless Gem::Platform.local.os == "darwin"
|
14
12
|
|
15
13
|
names, flairs = begin
|
16
|
-
JSON.parse
|
14
|
+
catch(:"404"){ JSON.parse NetHTTPUtils.request_data File.read "gas.url" } or raise(JSON::ParserError)
|
17
15
|
rescue JSON::ParserError
|
18
16
|
puts "smth wrong with GAS script"
|
19
17
|
sleep 60
|
@@ -21,6 +19,7 @@ loop do
|
|
21
19
|
end
|
22
20
|
|
23
21
|
existing = BOT.json(:get, "/r/#{SUBREDDIT}/api/flairlist", limit: 1000)["users"]
|
22
|
+
fail if existing.size >= 1000
|
24
23
|
|
25
24
|
if names.size == flairs.size
|
26
25
|
names.zip(flairs).drop(1).map(&:flatten).each_slice(50) do |slice|
|
File without changes
|
File without changes
|
@@ -2,18 +2,17 @@
|
|
2
2
|
BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: true
|
3
3
|
|
4
4
|
loop do
|
5
|
-
|
5
|
+
Hearthbeat.beat "u_CPTFlairBot3_r_casualpokemontrades", 70 unless Gem::Platform.local.os == "darwin"
|
6
6
|
|
7
7
|
unread = BOT.json :get, "/message/unread"
|
8
8
|
unread["data"]["children"].each do |msg|
|
9
|
-
# next unless msg["data"]["author"] == "nakilon" if ENV["LOGNAME"] == "nakilon"
|
10
9
|
next puts "bad destination: #{msg["data"]["dest"]}" unless msg["data"]["dest"] == "CPTFlairBot3"
|
11
10
|
case msg["data"]["subject"]
|
12
|
-
when "casualpokemontrades"
|
11
|
+
when "casualpokemontrades"
|
13
12
|
unless /^(?<name>\S+)\n(?<id>\d\d\d\d-\d\d\d\d-\d\d\d\d)\n(?<css_class>\S+)$/ =~ msg["data"]["body"]
|
14
|
-
puts "invalid message for #{msg["data"]["subject"]}: %p" % msg["data"]["body"] if
|
13
|
+
puts "invalid message for #{msg["data"]["subject"]}: %p" % msg["data"]["body"] if Gem::Platform.local.os == "darwin"
|
15
14
|
# puts "marking invalid message as read: %p" % msg["data"]["body"]
|
16
|
-
# BOT.json :post, "/api/read_message", {id: msg["data"]["name"]} unless
|
15
|
+
# BOT.json :post, "/api/read_message", {id: msg["data"]["name"]} unless Gem::Platform.local.os == "darwin"
|
17
16
|
next
|
18
17
|
end
|
19
18
|
begin
|
@@ -39,6 +38,6 @@ loop do
|
|
39
38
|
break # just for a case
|
40
39
|
end
|
41
40
|
|
42
|
-
puts "END LOOP #{Time.now}" if
|
41
|
+
puts "END LOOP #{Time.now}" if Gem::Platform.local.os == "darwin"
|
43
42
|
sleep 60
|
44
43
|
end
|
@@ -1,3 +1,9 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://gist.github.com/97549ceb58d21e1fcbc0e6cdaf92fce8.git
|
3
|
+
revision: a5728a4745cf4479a3cc4a7742ca54fcb94955ab
|
4
|
+
specs:
|
5
|
+
net_http_utils (0.1)
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: https://rubygems.org/
|
3
9
|
specs:
|
@@ -9,7 +15,8 @@ PLATFORMS
|
|
9
15
|
ruby
|
10
16
|
|
11
17
|
DEPENDENCIES
|
18
|
+
net_http_utils!
|
12
19
|
reddit_bot (~> 1.1.5)
|
13
20
|
|
14
21
|
BUNDLED WITH
|
15
|
-
1.
|
22
|
+
1.13.5
|
@@ -1,25 +1,24 @@
|
|
1
1
|
require_relative "../boilerplate"
|
2
2
|
|
3
|
-
BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: true
|
4
|
-
|
3
|
+
BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: true
|
5
4
|
|
6
5
|
loop do
|
7
|
-
|
6
|
+
Hearthbeat.beat "u_DevFlairBot_r_ion_r_survivetheculling", 130 unless Gem::Platform.local.os == "darwin"
|
8
7
|
puts "LOOP #{Time.now}"
|
9
8
|
|
10
9
|
[
|
11
10
|
["ion", "Developer"],
|
12
11
|
["survivetheculling", "Developer"],
|
13
12
|
].each do |subreddit, developer_class|
|
14
|
-
puts subreddit
|
13
|
+
puts "sub: #{subreddit}"
|
15
14
|
|
16
15
|
JSON.parse(
|
17
|
-
|
16
|
+
NetHTTPUtils.request_data "https://www.reddit.com/r/#{subreddit}/comments.json", header: ["User-Agent", "ajsdjasdasd"]
|
18
17
|
)["data"]["children"].each do |comment|
|
19
18
|
id = comment["data"]["link_id"][3..-1]
|
20
19
|
commenter_flair = comment["data"]["author_flair_css_class"]
|
21
|
-
puts commenter_flair if commenter_flair
|
22
|
-
next
|
20
|
+
# puts "flair: #{commenter_flair}" if commenter_flair
|
21
|
+
next unless developer_class == commenter_flair
|
23
22
|
puts "https://reddit.com/r/#{subreddit}/comments/#{id}/#{comment["data"]["id"]} '#{commenter_flair}'"
|
24
23
|
flairselector = BOT.json :post, "/api/flairselector", { link: comment["data"]["link_id"] }
|
25
24
|
existing_flair_class = flairselector["current"]["flair_css_class"]
|
@@ -49,5 +48,5 @@ loop do
|
|
49
48
|
end
|
50
49
|
|
51
50
|
puts "END LOOP #{Time.now}"
|
52
|
-
sleep
|
51
|
+
sleep 120
|
53
52
|
end
|
data/examples/mlgtv/Gemfile
CHANGED
data/examples/mlgtv/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ GEM
|
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
json (2.0.2)
|
11
|
-
reddit_bot (1.
|
11
|
+
reddit_bot (1.2.0)
|
12
12
|
json
|
13
13
|
|
14
14
|
PLATFORMS
|
@@ -16,7 +16,7 @@ PLATFORMS
|
|
16
16
|
|
17
17
|
DEPENDENCIES
|
18
18
|
net_http_utils (= 0)!
|
19
|
-
reddit_bot (~> 1.
|
19
|
+
reddit_bot (~> 1.2.0)
|
20
20
|
|
21
21
|
BUNDLED WITH
|
22
22
|
1.13.1
|
data/examples/mlgtv/main.rb
CHANGED
@@ -42,9 +42,13 @@ loop do
|
|
42
42
|
"Call of Duty: Modern Warfare Remastered",
|
43
43
|
"Call of Duty 4: Modern Warfare",
|
44
44
|
].each do |game|
|
45
|
-
(
|
46
|
-
NetHTTPUtils.request_data "https://api.twitch.tv/kraken/streams?game=#{CGI::escape game}&access_token=#{File.read("twitch.token").strip}&client_id=#{File.read("client.id").strip}&channel=Ricky,ACHES,Lacefield,Clayster,Enable,Zoomaa,Attach,TheFEARS,PHiZZURP,MiRx1,SaintsRF,StuDyy,SpaceLyTV,NAMELESS,
|
47
|
-
|
45
|
+
(begin
|
46
|
+
JSON.parse NetHTTPUtils.request_data "https://api.twitch.tv/kraken/streams?game=#{CGI::escape game}&access_token=#{File.read("twitch.token").strip}&client_id=#{File.read("client.id").strip}&channel=Ricky,ACHES,Lacefield,Clayster,Enable,Zoomaa,Attach,TheFEARS,PHiZZURP,MiRx1,SaintsRF,StuDyy,SpaceLyTV,NAMELESS,Scump,FORMAL,Crimsix,Karma,Loony,Slacked,Octane,MJChino,Diabolic_TV,ImTheIvy,Senderxz,Jkap,John,SlasheRAL,Apathy,ColtHavok,MikeSwarley,ParasiteTV,TyreeLegal,Silly,Blfire,methodz,TwiZzyTV,Mochila,Remy,Xotic16,AquA,Faccento,Nagafen,Tylerfelo,TheoryCoD,ColeChanTV,happyy97,goonjar,Burns,Dedo,Neslo,TeeCM,K1lla93,NeLsoNNaTeR,ProoFy,Whea7s,MBoZe,Merk,Nadeshot,ReeP,Sharp,TeePee,Braaain2015,Nolsonn,QwiKeRTHaNu,Zedenyer1,Jurd,Tommey,Swanny,MadCatEU,Rated_EU1,BsportJoshh,Sy_Vortex,TheMarkyB,Peatie95,urbandm,TreiZer0,iDqvee,Tojor,MethodZ_TV,Gotaga,WailersWL,TCM_Moose,RampageSkrapz,Reedy,fighta71,Swiftazor,BacabecNZ,Zeuss_Gaming,Hopeyy,GuydraCOD,mattmrx,Maven,CouRageJD,Revan,BriceyHD,Benson,PHILWHI7"
|
47
|
+
rescue JSON::ParserError
|
48
|
+
puts "JSON::ParserError"
|
49
|
+
sleep 60
|
50
|
+
retry
|
51
|
+
end["streams"] || []).each do |channel|
|
48
52
|
list << "* [](#twitch) [](#live) [**#{
|
49
53
|
channel["channel"]["display_name"]
|
50
54
|
}**](#{
|
data/examples/oneplus/Gemfile
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
# gem "reddit_bot", "~>1.0", path: File.join("..", "..")
|
5
|
-
# else
|
6
|
-
gem "reddit_bot", "~>1.1.5"
|
7
|
-
# end
|
8
|
-
|
3
|
+
gem "reddit_bot", "~>1.1.5"
|
9
4
|
gem "fastimage", "1.7.0"
|
5
|
+
gem "net_http_utils", ?0, gist: "97549ceb58d21e1fcbc0e6cdaf92fce8"
|
@@ -1,3 +1,9 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://gist.github.com/97549ceb58d21e1fcbc0e6cdaf92fce8.git
|
3
|
+
revision: 54c47ab3f9665f3e35a8e94fdd267e3743c736a9
|
4
|
+
specs:
|
5
|
+
net_http_utils (0)
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: https://rubygems.org/
|
3
9
|
specs:
|
@@ -13,7 +19,8 @@ PLATFORMS
|
|
13
19
|
|
14
20
|
DEPENDENCIES
|
15
21
|
fastimage (= 1.7.0)
|
22
|
+
net_http_utils (= 0)!
|
16
23
|
reddit_bot (~> 1.1.5)
|
17
24
|
|
18
25
|
BUNDLED WITH
|
19
|
-
1.
|
26
|
+
1.13.1
|
data/examples/oneplus/main.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
require_relative "../boilerplate"
|
2
2
|
|
3
3
|
BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: true
|
4
|
-
|
5
|
-
require_relative "#{"../" if ENV["LOGNAME"] == "nakilon"}../../../dimensioner/get_dimensions"
|
6
|
-
|
7
4
|
SUBREDDIT = "oneplus"
|
8
|
-
|
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
|
9
11
|
|
10
12
|
checked = []
|
11
13
|
loop do
|
12
|
-
|
14
|
+
Hearthbeat.beat "u_oneplus_mod_r_oneplus", 310 unless Gem::Platform.local.os == "darwin"
|
13
15
|
puts "LOOP #{Time.now}"
|
14
16
|
|
15
|
-
BOT.json(:get, "/r/#{SUBREDDIT}/new")["data"]["children"].each do |
|
16
|
-
id, url, title, subreddit =
|
17
|
-
next if checked.include? id
|
18
|
-
checked
|
17
|
+
BOT.json(:get, "/r/#{SUBREDDIT}/new")["data"]["children"].each do |post|
|
18
|
+
id, url, title, subreddit = post["data"].values_at(*%w{ id url title subreddit })
|
19
|
+
next if checked.include? id
|
20
|
+
checked.push id
|
19
21
|
redd_it = "https://redd.it/#{id}"
|
20
22
|
next puts "skipped #{url} from #{redd_it}" if :skipped == _ = GetDimensions::get_dimensions(url)
|
21
23
|
next puts "unable #{url} from #{redd_it}" unless _
|
@@ -24,18 +26,6 @@ loop do
|
|
24
26
|
puts "#{result} #{id} [#{resolution}] #{title} #{url}"
|
25
27
|
next if result
|
26
28
|
|
27
|
-
### flair
|
28
|
-
# {"json"=>{"errors"=>[]}} == _ = BOT.json(:post,
|
29
|
-
# "/api/selectflair",
|
30
|
-
# flair_template_id: BOT.json(:post,
|
31
|
-
# "/api/flairselector",
|
32
|
-
# link: "t3_#{id}",
|
33
|
-
# )["choices"].find{ |i| i["flair_css_class"] == FLAIR_CLASS }["flair_template_id"],
|
34
|
-
# link: "t3_#{id}",
|
35
|
-
# ) or fail _.inspect
|
36
|
-
### report
|
37
|
-
# BOT.report "1080x1920", "t3_#{id}"
|
38
|
-
|
39
29
|
### delete
|
40
30
|
BOT.json :post, "/api/remove",
|
41
31
|
id: "t3_#{id}",
|
data/examples/sexypizza/main.rb
CHANGED
@@ -22,7 +22,7 @@ loop do
|
|
22
22
|
if text != BOT.json(:get, "/r/#{SUBREDDIT}/wiki/toppings")["data"]["content_md"]
|
23
23
|
puts "editing wiki page '/r/#{SUBREDDIT}/wiki/toppings'"
|
24
24
|
pp text
|
25
|
-
p json :post,
|
25
|
+
p BOT.json :post,
|
26
26
|
"/r/#{SUBREDDIT}/api/wiki/edit",
|
27
27
|
page: "toppings",
|
28
28
|
content: text
|
data/examples/wallpaper/Gemfile
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://gist.github.com/97549ceb58d21e1fcbc0e6cdaf92fce8.git
|
3
|
+
revision: 54c47ab3f9665f3e35a8e94fdd267e3743c736a9
|
4
|
+
specs:
|
5
|
+
net_http_utils (0)
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: https://rubygems.org/
|
3
9
|
specs:
|
@@ -13,6 +19,7 @@ PLATFORMS
|
|
13
19
|
|
14
20
|
DEPENDENCIES
|
15
21
|
fastimage (= 1.7.0)
|
22
|
+
net_http_utils (= 0)!
|
16
23
|
reddit_bot (~> 1.1.5)
|
17
24
|
|
18
25
|
BUNDLED WITH
|
data/examples/wallpaper/main.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
require_relative "../boilerplate"
|
2
2
|
|
3
|
-
BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: true
|
3
|
+
BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: true
|
4
4
|
SUBREDDIT = "wallpaper"
|
5
5
|
|
6
|
-
if
|
6
|
+
if Gem::Platform.local.os == "darwin"
|
7
7
|
require_relative "../../../../dimensioner/get_dimensions"
|
8
8
|
else
|
9
|
-
require_relative
|
9
|
+
require_relative "#{Dir.home}/get_dimensions"
|
10
10
|
end
|
11
11
|
|
12
12
|
checked = []
|
13
13
|
loop do
|
14
|
-
|
14
|
+
Hearthbeat.beat "u_wallpaperpedantbot_r_#{SUBREDDIT}", 70 unless Gem::Platform.local.os == "darwin"
|
15
15
|
puts "LOOP #{Time.now}"
|
16
16
|
|
17
|
-
# _ = DownloadWithRetry::download_with_retry("https://www.reddit.com/r/#{SUBREDDIT}.json?sort=new&restrict_sr=on&t=hour") \
|
18
17
|
BOT.json(:get, "/r/#{SUBREDDIT}/new")["data"]["children"].each do |post|
|
19
18
|
id, url, title, subreddit = post["data"].values_at(*%w{ id url title subreddit })
|
20
19
|
next if checked.include? id
|
data/examples/yayornay/main.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
require_relative "../boilerplate"
|
2
2
|
|
3
|
-
# SUBREDDIT = "test___________"
|
4
3
|
SUBREDDIT = "yayornay"
|
5
|
-
|
6
4
|
BOT = RedditBot::Bot.new YAML.load(File.read "secrets.yaml"), ignore_captcha: true, subreddit: SUBREDDIT
|
7
5
|
|
8
|
-
|
9
6
|
loop do
|
10
|
-
|
7
|
+
Hearthbeat.beat "u_gotfan247_r_yayornay", 310 unless Gem::Platform.local.os == "darwin"
|
11
8
|
puts "LOOP #{Time.now}"
|
12
9
|
|
13
10
|
BOT.each_new_post_with_top_level_comments do |post, comments|
|
@@ -17,7 +14,7 @@ loop do
|
|
17
14
|
yay |= [comment["author"]] if comment["body"][/\A\s*yay/i]
|
18
15
|
nay |= [comment["author"]] if comment["body"][/\A\s*nay/i]
|
19
16
|
end
|
20
|
-
p [post["id"], yay, nay] if
|
17
|
+
p [post["id"], yay, nay] if Gem::Platform.local.os == "darwin"
|
21
18
|
yay, nay = [(yay - nay).size, (nay - yay).size]
|
22
19
|
next if 0 == total = yay + nay
|
23
20
|
proper_class = yay > nay ? "yay" : yay < nay ? "nay" : "none"
|
data/lib/reddit_bot.rb
CHANGED
@@ -8,7 +8,7 @@ require "json"
|
|
8
8
|
|
9
9
|
|
10
10
|
module RedditBot
|
11
|
-
VERSION = "1.2.
|
11
|
+
VERSION = "1.2.2" # :nodoc:
|
12
12
|
|
13
13
|
class Bot
|
14
14
|
|
@@ -253,15 +253,16 @@ module RedditBot
|
|
253
253
|
use_ssl: uri.scheme == "https",
|
254
254
|
verify_mode: OpenSSL::SSL::VERIFY_NONE,
|
255
255
|
open_timeout: 300
|
256
|
-
rescue OpenSSL::SSL::SSLError, SocketError, Errno::ECONNRESET, Net::OpenTimeout, Errno::ETIMEDOUT => e
|
256
|
+
rescue OpenSSL::SSL::SSLError, SocketError, Errno::ECONNRESET, Net::OpenTimeout, Errno::ETIMEDOUT, Errno::EPIPE => e
|
257
257
|
puts "ERROR: #{e.class}: #{e}"
|
258
258
|
sleep 5
|
259
259
|
retry
|
260
260
|
end
|
261
261
|
response = begin
|
262
262
|
http.request request
|
263
|
-
rescue OpenSSL::SSL::SSLError, SocketError, Net::ReadTimeout, Errno::EPIPE, EOFError, Zlib::BufError
|
264
|
-
puts "ERROR:
|
263
|
+
rescue OpenSSL::SSL::SSLError, SocketError, Net::ReadTimeout, Errno::EPIPE, EOFError, Zlib::BufError, Errno::ECONNRESET => e
|
264
|
+
puts "ERROR: #{e}"
|
265
|
+
sleep 5
|
265
266
|
retry
|
266
267
|
end
|
267
268
|
puts %w{
|
@@ -276,7 +277,7 @@ module RedditBot
|
|
276
277
|
# end
|
277
278
|
fail response.to_hash["x-ratelimit-remaining"][0] \
|
278
279
|
if response.to_hash["x-ratelimit-remaining"] &&
|
279
|
-
response.to_hash["x-ratelimit-remaining"][0].size
|
280
|
+
response.to_hash["x-ratelimit-remaining"][0].size < 5
|
280
281
|
|
281
282
|
# if response.code == "401"
|
282
283
|
# puts request.path
|
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.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -37,12 +37,15 @@ files:
|
|
37
37
|
- Rakefile
|
38
38
|
- examples/.gitignore
|
39
39
|
- examples/boilerplate.rb
|
40
|
+
- examples/councilofricks/Gemfile
|
41
|
+
- examples/councilofricks/Gemfile.lock
|
42
|
+
- examples/councilofricks/main.rb
|
43
|
+
- examples/cptflairbot3/Gemfile
|
44
|
+
- examples/cptflairbot3/Gemfile.lock
|
45
|
+
- examples/cptflairbot3/main.rb
|
40
46
|
- examples/devflairbot/Gemfile
|
41
47
|
- examples/devflairbot/Gemfile.lock
|
42
48
|
- examples/devflairbot/main.rb
|
43
|
-
- examples/flairmotron/Gemfile
|
44
|
-
- examples/flairmotron/Gemfile.lock
|
45
|
-
- examples/flairmotron/main.rb
|
46
49
|
- examples/iostroubleshooting/Gemfile
|
47
50
|
- examples/iostroubleshooting/Gemfile.lock
|
48
51
|
- examples/iostroubleshooting/main.rb
|
@@ -55,9 +58,6 @@ files:
|
|
55
58
|
- examples/oneplus/Gemfile
|
56
59
|
- examples/oneplus/Gemfile.lock
|
57
60
|
- examples/oneplus/main.rb
|
58
|
-
- examples/pokemon_trading/Gemfile
|
59
|
-
- examples/pokemon_trading/Gemfile.lock
|
60
|
-
- examples/pokemon_trading/main.rb
|
61
61
|
- examples/sexypizza/Gemfile
|
62
62
|
- examples/sexypizza/Gemfile.lock
|
63
63
|
- examples/sexypizza/main.rb
|
@@ -94,3 +94,4 @@ signing_key:
|
|
94
94
|
specification_version: 4
|
95
95
|
summary: Library for Reddit bots
|
96
96
|
test_files: []
|
97
|
+
has_rdoc:
|