reddit_bot 0.1.0 → 0.1.1

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: 15d553095ba152bbaae221eae90f979af34d3c15
4
- data.tar.gz: e69581752893dd5e33295288e41913d8c8911b24
3
+ metadata.gz: cf853922de330ff48fbb769f10d7f49375c1af7c
4
+ data.tar.gz: 951e17435175ecbd77704ccc91b2ec262081a317
5
5
  SHA512:
6
- metadata.gz: c84e63458312902936b0bd272ff4af284f6277b601b12dee1b3e65471e52809679b00a9d179d5e427c2757d61ab8280ce8544f261507788679afd94a1a76a7c1
7
- data.tar.gz: fdba28df65eb98e47a93397e4115dc30dd7b01adbd59b44e885a65e8f2b537161089dd0fa8c349f9b74b860eea3ddd9511cd6f1ef8e9dd2a509bf84f58bb2cdd
6
+ metadata.gz: 1ee0c205ec62a088e7336ecbefc760fb8bf0f91f2af46ceace29678fc9ad002d0c4924c3fb0baca7c84f8faf00ced71f6fdecabd2e6ae954617fff1a318e2a22
7
+ data.tar.gz: 2cf030135c7458facff5432319f5ee2fbbbe590a8ab68352187df20ac29927cd87db14c19a44c4900ab4f080be089e2cea4260e9b283396bc3aca6a7ad92489c
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,15 @@
1
+ STDOUT.sync = true
2
+
3
+ require "pp"
4
+
5
+ require_relative File.join \
6
+ *("../../../download_with_retry" if ENV["LOGNAME"] == "nakilon"),
7
+ "download_with_retry"
8
+
9
+ require "reddit_bot"
10
+ # RedditBot.init *File.read(File.join(Dir.pwd, "secrets")).split, ignore_captcha: true
11
+ RedditBot.init *File.read("secrets").split, ignore_captcha: true
12
+
13
+ require_relative File.join \
14
+ *("../../.." if ENV["LOGNAME"] == "nakilon"),
15
+ "awsstatus/2.rb"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ # ruby "2.0.0"
4
+ gem "json"#, "1.7.7"
5
+ gem "reddit_bot"
@@ -0,0 +1,15 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ json (1.8.3)
5
+ reddit_bot (0.1.0)
6
+
7
+ PLATFORMS
8
+ ruby
9
+
10
+ DEPENDENCIES
11
+ json
12
+ reddit_bot
13
+
14
+ BUNDLED WITH
15
+ 1.11.2
@@ -0,0 +1,37 @@
1
+ STDOUT.sync = true
2
+
3
+ require_relative File.join "..", "boilerplate"
4
+
5
+ # SUBREDDIT = "test___________"
6
+ SUBREDDIT = "iostroubleshooting"
7
+
8
+ # require "open-uri"
9
+ require "csv" # /api/flaircsv
10
+
11
+ loop do
12
+ AWSStatus::touch
13
+ catch :loop do
14
+
15
+ existing = RedditBot.json(:get, "/r/#{SUBREDDIT}/api/flairlist")["users"]
16
+ begin
17
+ JSON.parse(DownloadWithRetry::download_with_retry("#{File.read "gas.url"}sheet_name=Bot&spreadsheet_id=10UzXUbawBgXLQkxXDMz28Qcx3IQPjwG9nByd_d8y31I", &:read))
18
+ rescue JSON::ParserError
19
+ puts "smth wrong with GAS script"
20
+ throw :loop
21
+ end.drop(1).reverse.uniq{ |_, user, _, _| user }.map do |row|
22
+ next unless row.map(&:empty?) == [false, false, false, false]
23
+ _, user, ios, flair = row
24
+ next if existing.include?({"flair_css_class"=>flair, "user"=>user, "flair_text"=>ios})
25
+ [user, ios, flair]
26
+ # {"iPhone"=>"greenflair", "iPad"=>"blue", "iPod"=>"red"}[device[/iP(od|ad|hone)/]]]
27
+ end.compact.each_slice(50) do |slice|
28
+ CSV(load = ""){ |csv| slice.each{ |record| csv << record } }
29
+ puts load
30
+ RedditBot.json(:post, "/r/#{SUBREDDIT}/api/flaircsv", [["flair_csv", load]]).each do |report|
31
+ pp report unless report.values_at("errors", "ok", "warnings") == [{}, true, {}]
32
+ end
33
+ end
34
+
35
+ end
36
+ sleep 60
37
+ end
data/lib/reddit_bot.rb CHANGED
@@ -8,7 +8,7 @@ require "json"
8
8
 
9
9
 
10
10
  module RedditBot
11
- VERSION = "0.1.0"
11
+ VERSION = "0.1.1"
12
12
 
13
13
  class << self
14
14
 
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: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Maslov
@@ -19,6 +19,11 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - Gemfile
21
21
  - LICENSE.txt
22
+ - Rakefile
23
+ - examples/boilerplate.rb
24
+ - examples/iostroubleshooting/Gemfile
25
+ - examples/iostroubleshooting/Gemfile.lock
26
+ - examples/iostroubleshooting/main.rb
22
27
  - lib/reddit_bot.rb
23
28
  - reddit_bot.gemspec
24
29
  homepage: ''