reddit_bot 1.7.7 → 1.7.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/reddit_bot.rb +3 -1
  3. data/reddit_bot.gemspec +9 -11
  4. metadata +9 -77
  5. data/.gitignore +0 -5
  6. data/Gemfile +0 -5
  7. data/README.md +0 -101
  8. data/Rakefile +0 -6
  9. data/examples/.bashrc +0 -2
  10. data/examples/.gitignore +0 -2
  11. data/examples/Gemfile.lock +0 -17
  12. data/examples/boilerplate.rb +0 -12
  13. data/examples/councilofricks/Gemfile +0 -4
  14. data/examples/councilofricks/Gemfile.lock +0 -17
  15. data/examples/councilofricks/main.rb +0 -58
  16. data/examples/cptflairbot3/.bashrc +0 -1
  17. data/examples/cptflairbot3/Code.gs +0 -13
  18. data/examples/cptflairbot3/Gemfile +0 -5
  19. data/examples/cptflairbot3/Gemfile.lock +0 -74
  20. data/examples/cptflairbot3/app.js +0 -40
  21. data/examples/cptflairbot3/casual/casualpokemontrades.htm +0 -910
  22. data/examples/cptflairbot3/casual/script.js +0 -55
  23. data/examples/cptflairbot3/casual/style.css +0 -1099
  24. data/examples/cptflairbot3/log.htm +0 -1
  25. data/examples/cptflairbot3/main.rb +0 -62
  26. data/examples/cptflairbot3/package.json +0 -6
  27. data/examples/cptflairbot3/pubsub.rb +0 -30
  28. data/examples/devflairbot/Gemfile +0 -6
  29. data/examples/devflairbot/Gemfile.lock +0 -74
  30. data/examples/devflairbot/main.rb +0 -81
  31. data/examples/dut/Gemfile +0 -4
  32. data/examples/dut/Gemfile.lock +0 -24
  33. data/examples/dut/main.rb +0 -41
  34. data/examples/get_dimensions.rb +0 -212
  35. data/examples/iostroubleshooting/Gemfile +0 -5
  36. data/examples/iostroubleshooting/Gemfile.lock +0 -16
  37. data/examples/iostroubleshooting/main.rb +0 -36
  38. data/examples/johnnymarr/Gemfile +0 -3
  39. data/examples/johnnymarr/Gemfile.lock +0 -17
  40. data/examples/johnnymarr/main.rb +0 -54
  41. data/examples/johnnymarr/twitter.rb +0 -80
  42. data/examples/largeimages/Gemfile +0 -11
  43. data/examples/largeimages/Gemfile.lock +0 -105
  44. data/examples/largeimages/main.rb +0 -173
  45. data/examples/largeimagesreview/Gemfile +0 -4
  46. data/examples/largeimagesreview/Gemfile.lock +0 -15
  47. data/examples/largeimagesreview/main.rb +0 -43
  48. data/examples/mlgtv/Gemfile +0 -4
  49. data/examples/mlgtv/Gemfile.lock +0 -23
  50. data/examples/mlgtv/channels.txt +0 -127
  51. data/examples/mlgtv/main.rb +0 -160
  52. data/examples/net_http_utils.rb +0 -148
  53. data/examples/oneplus/Gemfile +0 -5
  54. data/examples/oneplus/Gemfile.lock +0 -26
  55. data/examples/oneplus/main.rb +0 -43
  56. data/examples/realtimeww2/.bashrc +0 -1
  57. data/examples/realtimeww2/Gemfile +0 -3
  58. data/examples/realtimeww2/Gemfile.lock +0 -17
  59. data/examples/realtimeww2/main.rb +0 -129
  60. data/examples/sexypizza/Gemfile +0 -3
  61. data/examples/sexypizza/Gemfile.lock +0 -15
  62. data/examples/sexypizza/main.rb +0 -33
  63. data/examples/unisa/Gemfile +0 -4
  64. data/examples/unisa/Gemfile.lock +0 -24
  65. data/examples/unisa/main.rb +0 -41
  66. data/examples/wallpaper/Gemfile +0 -5
  67. data/examples/wallpaper/Gemfile.lock +0 -34
  68. data/examples/wallpaper/main.rb +0 -27
  69. data/examples/yayornay/Gemfile +0 -3
  70. data/examples/yayornay/Gemfile.lock +0 -15
  71. data/examples/yayornay/main.rb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 678fcb0251bf04be23802b62ddea29f5ea338386
4
- data.tar.gz: b65667dea035f15f24a40f2c26017374b959780d
3
+ metadata.gz: a79ccb6940bda2173afa1e2e1814e89bb0793b72
4
+ data.tar.gz: a7b8a729599ad509480782cffaf5351d5444ac73
5
5
  SHA512:
6
- metadata.gz: 384b4e42c38453c2a3ceb90892e144824f078f81dcc91e2c2ba65c39e22ed5e95d4b7ebc8bcba080d7113a10c654295768c8c6fcf32f7089495cd4395fafd80c
7
- data.tar.gz: 24b3318a50e0ad0b784a8b8b1689ab3eef7dbebc1461760bc42a8fa920d6a223e2414910d2dfc38e5b50f394a1c032632d2aca87c12ba50141c1f07d941188dd
6
+ metadata.gz: d8aa5d6fd2e4e8f1319eaba631bff0a00f1309e9258917f8d154f6d2a08a9c4751ef14b2ce4c0ad174d55db6dc9a950637eed77748ac3993ec447b88923e50a2
7
+ data.tar.gz: 496c9948ad1a8ddae3a19d12e6280f4f59024f6f2200a8719a8ce2060efdc5264e8a6f6fd198639701cea1eeaf5e2dbb86acc651279c9091bdfaee766a02c5c9
@@ -152,7 +152,9 @@ module RedditBot
152
152
  result["data"].keys == %w{ modhash dist children after before }
153
153
  @@skip_erroneous_descending_ids[ result["data"]["children"].map do |post|
154
154
  fail "unknown type post['kind']: #{post["kind"]}" unless post["kind"] == "t3"
155
- post["data"]
155
+ post["data"].dup.tap do |data|
156
+ data["url"] = "https://www.reddit.com" + data["url"] if /\A\/r\/[0-9a-zA-Z_]+\/comments\/[0-9a-z]{5,6}\// =~ data["url"] if data["crosspost_parent"]
157
+ end
156
158
  end ].each do |data|
157
159
  e << data
158
160
  end
@@ -1,23 +1,21 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "reddit_bot"
3
- spec.version = "1.7.7"
4
- spec.authors = ["Victor Maslov"]
5
- spec.email = ["nakilon@gmail.com"]
3
+ spec.version = "1.7.8"
4
+ spec.summary = "Simple library for Reddit bots"
6
5
 
7
- spec.summary = "Library for Reddit bots"
8
- spec.description = "better than PRAW"
9
- spec.homepage = "https://github.com/Nakilon/reddit_bot"
6
+ spec.author = "Victor Maslov aka Nakilon"
7
+ spec.email = "nakilon@gmail.com"
10
8
  spec.license = "MIT"
9
+ spec.metadata = {"source_code_uri" => "https://github.com/Nakilon/reddit_bot"}
11
10
 
12
- spec.files = `git ls-files -z`.split("\x0")#.reject { |f| f.match(%r{^(test|spec|features)/})/ }
13
- # spec.require_paths = ["lib"]
14
-
15
- spec.add_runtime_dependency "json"
16
- spec.add_runtime_dependency "nethttputils", "~>0.4.1.0"
11
+ spec.add_dependency "json"
12
+ spec.add_dependency "nethttputils", "~>0.4.1.0"
17
13
  # spec.add_development_dependency "bundler", "~> 1.11"
18
14
  # spec.add_development_dependency "rake", "~> 10.0"
19
15
  # spec.add_development_dependency "rspec", "~> 3.0"
20
16
  spec.required_ruby_version = ">= 2.0.0"
17
+
18
+ spec.files = %w{ LICENSE.txt reddit_bot.gemspec lib/reddit_bot.rb }
21
19
  end
22
20
 
23
21
  # spec.test_files = ["spec/"]
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.7.7
4
+ version: 1.7.8
5
5
  platform: ruby
6
6
  authors:
7
- - Victor Maslov
7
+ - Victor Maslov aka Nakilon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-02 00:00:00.000000000 Z
11
+ date: 2020-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -38,88 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.4.1.0
41
- description: better than PRAW
42
- email:
43
- - nakilon@gmail.com
41
+ description:
42
+ email: nakilon@gmail.com
44
43
  executables: []
45
44
  extensions: []
46
45
  extra_rdoc_files: []
47
46
  files:
48
- - ".gitignore"
49
- - Gemfile
50
47
  - LICENSE.txt
51
- - README.md
52
- - Rakefile
53
- - examples/.bashrc
54
- - examples/.gitignore
55
- - examples/Gemfile.lock
56
- - examples/boilerplate.rb
57
- - examples/councilofricks/Gemfile
58
- - examples/councilofricks/Gemfile.lock
59
- - examples/councilofricks/main.rb
60
- - examples/cptflairbot3/.bashrc
61
- - examples/cptflairbot3/Code.gs
62
- - examples/cptflairbot3/Gemfile
63
- - examples/cptflairbot3/Gemfile.lock
64
- - examples/cptflairbot3/app.js
65
- - examples/cptflairbot3/casual/casualpokemontrades.htm
66
- - examples/cptflairbot3/casual/script.js
67
- - examples/cptflairbot3/casual/style.css
68
- - examples/cptflairbot3/log.htm
69
- - examples/cptflairbot3/main.rb
70
- - examples/cptflairbot3/package.json
71
- - examples/cptflairbot3/pubsub.rb
72
- - examples/cptflairbot3/update_gas_hook_secret.rb
73
- - examples/devflairbot/Gemfile
74
- - examples/devflairbot/Gemfile.lock
75
- - examples/devflairbot/main.rb
76
- - examples/dut/Gemfile
77
- - examples/dut/Gemfile.lock
78
- - examples/dut/main.rb
79
- - examples/get_dimensions.rb
80
- - examples/iostroubleshooting/Gemfile
81
- - examples/iostroubleshooting/Gemfile.lock
82
- - examples/iostroubleshooting/main.rb
83
- - examples/johnnymarr/Gemfile
84
- - examples/johnnymarr/Gemfile.lock
85
- - examples/johnnymarr/main.rb
86
- - examples/johnnymarr/twitter.rb
87
- - examples/largeimages/Gemfile
88
- - examples/largeimages/Gemfile.lock
89
- - examples/largeimages/main.rb
90
- - examples/largeimagesreview/Gemfile
91
- - examples/largeimagesreview/Gemfile.lock
92
- - examples/largeimagesreview/main.rb
93
- - examples/mlgtv/Gemfile
94
- - examples/mlgtv/Gemfile.lock
95
- - examples/mlgtv/channels.txt
96
- - examples/mlgtv/main.rb
97
- - examples/net_http_utils.rb
98
- - examples/oneplus/Gemfile
99
- - examples/oneplus/Gemfile.lock
100
- - examples/oneplus/main.rb
101
- - examples/realtimeww2/.bashrc
102
- - examples/realtimeww2/Gemfile
103
- - examples/realtimeww2/Gemfile.lock
104
- - examples/realtimeww2/main.rb
105
- - examples/sexypizza/Gemfile
106
- - examples/sexypizza/Gemfile.lock
107
- - examples/sexypizza/main.rb
108
- - examples/unisa/Gemfile
109
- - examples/unisa/Gemfile.lock
110
- - examples/unisa/main.rb
111
- - examples/wallpaper/Gemfile
112
- - examples/wallpaper/Gemfile.lock
113
- - examples/wallpaper/main.rb
114
- - examples/yayornay/Gemfile
115
- - examples/yayornay/Gemfile.lock
116
- - examples/yayornay/main.rb
117
48
  - lib/reddit_bot.rb
118
49
  - reddit_bot.gemspec
119
- homepage: https://github.com/Nakilon/reddit_bot
50
+ homepage:
120
51
  licenses:
121
52
  - MIT
122
- metadata: {}
53
+ metadata:
54
+ source_code_uri: https://github.com/Nakilon/reddit_bot
123
55
  post_install_message:
124
56
  rdoc_options: []
125
57
  require_paths:
@@ -139,5 +71,5 @@ rubyforge_project:
139
71
  rubygems_version: 2.5.2.3
140
72
  signing_key:
141
73
  specification_version: 4
142
- summary: Library for Reddit bots
74
+ summary: Simple library for Reddit bots
143
75
  test_files: []
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- /examples/*/twitter.token
2
- temp
3
- *secret*
4
- .byebug_history
5
- /pkg
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec
4
-
5
- # git: "git@github.com:Nakilon/nethttputils.git", tag: "v0.0.1.4"
data/README.md DELETED
@@ -1,101 +0,0 @@
1
- # RedditBot
2
-
3
- [![Join the chat at https://gitter.im/Nakilon/reddit_bot](https://badges.gitter.im/Nakilon/reddit_bot.svg)](https://gitter.im/Nakilon/reddit_bot)
4
- [![Gem Version](https://badge.fury.io/rb/reddit_bot.svg)](http://badge.fury.io/rb/reddit_bot)
5
-
6
- ### What
7
-
8
- This library provides an easy way to run bots and scripts that use Reddit API.
9
- I ([/u/nakilon](https://www.reddit.com/u/nakilon)) currently run near 10 bots with it.
10
-
11
- ### Why
12
-
13
- Python (and so PRAW) sucks.
14
-
15
- ### Examples
16
-
17
- I'm not usually publish every program (since there are thousand of them and adequate programmer knows that publishing everything is like throwing trash on street) but I'll add bots here so you could see how to use the library.
18
- The [examples folder](examples) includes:
19
-
20
- * **sexypizza** -- bot that updates wiki page with current flairs statistics
21
- * **devflairbot** -- bot that flairs posts when some specifically flaired user comments there
22
- * **mlgtv** -- bot that updates sidebar with currently streaming twitch channels
23
- * **councilofricks** -- bot that flairs users according to Google Spreadsheet
24
- * **wallpaper** -- bot that reports images with dimensions being not the same as in title
25
- * **cptflairbot3** -- bot that sets user flair according to request submitted via web form
26
- also publishes its activily log here http://www.nakilon.pro/casualpokemontrades/log.htm via Google Cloud Platform automations (Apps Script and Functions)
27
- * **oneplus** -- bot that removes and modmails about links to 1080x1920 images
28
- * **yayornay** -- bot that flairs posts according to voting in top level comments
29
- * **realtimeww2** -- bot that posts tweets to a subreddit from a Twitter user timeline
30
- * **johnnymarr** -- another Twitter timeline streaming bot working in the similar way
31
- * **largeimages** -- this was my first bot -- it uses two approaches to track the most high resolution photos posted anywhere on Reddit to x-post them to [subreddit /r/largeimages](https://www.reddit.com/r/largeimages)
32
- * **largeimagesreview** -- script that was used /r/largeimages to calculates quality of x-posts from different subreddits based on mods activity (remove/approve) so it showed that /r/pics and /r/foodporn should better be excluded:
33
-
34
- pics Total: 98 Quality: 19%
35
- wallpapers Total: 69 Quality: 52%
36
- wallpaper Total: 45 Quality: 51%
37
- woahdude Total: 30 Quality: 66%
38
- CityPorn Total: 17 Quality: 82%
39
- FoodPorn Total: 13 Quality: 7%
40
- MapPorn Total: 13 Quality: 46%
41
- SkyPorn Total: 11 Quality: 45%
42
- carporn Total: 11 Quality: 45%
43
- InfrastructurePorn Total: 9 Quality: 77%
44
-
45
- EarthPorn Total: 23 Quality: 82% ✅⛔✅✅✅✅⛔✅✅✅✅✅⛔⛔✅✅✅✅✅✅✅✅✅
46
- FoodPorn Total: 5 Quality: 0% ⛔⛔⛔⛔⛔
47
- carporn Total: 4 Quality: 0% ⛔⛔⛔⛔
48
- CityPorn Total: 4 Quality: 100% ✅✅✅✅
49
- spaceporn Total: 4 Quality: 100% ✅✅✅✅
50
- MapPorn Total: 4 Quality: 50% ✅⛔✅⛔
51
- BotanicalPorn Total: 3 Quality: 66% ✅✅⛔
52
- CemeteryPorn Total: 2 Quality: 0% ⛔⛔
53
- MilitaryPorn Total: 2 Quality: 50% ✅⛔
54
- DessertPorn Total: 2 Quality: 50% ⛔✅
55
- pic Total: 2 Quality: 100% ✅✅
56
- ArchitecturePorn Total: 2 Quality: 50% ✅⛔
57
- AbandonedPorn Total: 2 Quality: 100% ✅✅
58
-
59
- ### Usage
60
-
61
- $ gem install reddit_bot
62
-
63
- or via Gemfile:
64
-
65
- source "https://rubygems.org"
66
- gem "reddit_bot"
67
-
68
- helloworld.rb:
69
-
70
- ```ruby
71
- require "reddit_bot"
72
- ```
73
-
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:
75
-
76
- :client_id: Kb9.......6wBw
77
- :client_secret: Fqo.....................AFI
78
- :password: mybotpassword
79
- :login: MyBotUsername
80
- # :user_agent: optional_custom_useragent_to_bypass_reddit_spam_protection
81
-
82
- To change log level:
83
-
84
- ```ruby
85
- RedditBot.logger.level = Logger::ERROR
86
- ```
87
-
88
- To update the gem version in Gemfile.lock when using Gemfile like this: `gem "reddit_bot", "~>1.1.0"`, do the:
89
-
90
- $ bundle update reddit_bot
91
-
92
- ### Contributing and License
93
-
94
- Bug reports and pull requests are welcome.
95
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
96
-
97
- ### TODO
98
-
99
- * write more usage instructions here
100
- * manual on how to create bots with Reddit web interface and run via bash console
101
- * about NetHTTPUtils dependency; and that get_response returns String code not Integer like request_data
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
-
3
- # require "rspec/core/rake_task"
4
- # RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,2 +0,0 @@
1
- echo "for get_dimensions.rb self-test: bundle exec ruby get_dimensions.rb"
2
- source ./secrets
@@ -1,2 +0,0 @@
1
- secrets
2
- secrets.yaml
@@ -1,17 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- json (2.1.0)
5
- nethttputils (0.2.5.1)
6
- reddit_bot (1.6.13)
7
- json
8
- nethttputils (~> 0.2.5.1)
9
-
10
- PLATFORMS
11
- ruby
12
-
13
- DEPENDENCIES
14
- reddit_bot
15
-
16
- BUNDLED WITH
17
- 1.17.1
@@ -1,12 +0,0 @@
1
- STDOUT.sync = true
2
- require "pp"
3
-
4
- if Gem.loaded_specs.include? "nethttputils"
5
- require "nethttputils"
6
- else
7
- require_relative "net_http_utils"
8
- end
9
-
10
- require "reddit_bot"
11
-
12
- require "yaml"
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "reddit_bot", "~>1.6.8"
4
- gem "nethttputils"
@@ -1,17 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- json (2.1.0)
5
- nethttputils (0.2.4.2)
6
- reddit_bot (1.6.8)
7
- json
8
- nethttputils (~> 0.2.4.1)
9
-
10
- PLATFORMS
11
- ruby
12
-
13
- DEPENDENCIES
14
- reddit_bot (~> 1.6.8)
15
-
16
- BUNDLED WITH
17
- 1.16.1
@@ -1,58 +0,0 @@
1
- require_relative "../boilerplate"
2
-
3
- BOT = RedditBot::Bot.new YAML.load_file "secrets.yaml"
4
- SUBREDDIT = "CouncilOfRicks"
5
-
6
- CSS_CLASS = "blueflair"
7
-
8
- require "csv"
9
-
10
- ignored = []
11
- loop do
12
- names, flairs = begin
13
- JSON.load begin
14
- NetHTTPUtils.request_data File.read "gas.url"
15
- rescue NetHTTPUtils::Error => e
16
- fail e unless [404, 500].include? e.code
17
- puts "smth wrong with GAS script"
18
- sleep 60
19
- retry
20
- end
21
- rescue JSON::ParserError
22
- puts "smth wrong with GAS script"
23
- sleep 60
24
- retry
25
- end
26
-
27
- existing = BOT.json(:get, "/r/#{SUBREDDIT}/api/flairlist", limit: 1000)["users"]
28
- fail if existing.size >= 1000
29
-
30
- if names.size != flairs.size
31
- puts "columns are different by length -- probably someone is editing the Spreadsheet"
32
- else
33
- names.zip(flairs).drop(1).map(&:flatten).map do |user, text|
34
- user = user.to_s.strip
35
- next unless user[/\A[a-z-_\d]+\z/i]
36
- text = text.to_s.strip
37
- next puts "ignored #{user}" if ignored.include? user
38
- next if existing.include?( {"user"=>user, "flair_text"=>text, "flair_css_class"=>CSS_CLASS} )
39
- [user, text, CSS_CLASS]
40
- end.compact.each_slice(50) do |slice|
41
- load = CSV.generate do |csv|
42
- slice.each &csv.method(:<<)
43
- end
44
- BOT.json(:post, "/r/#{SUBREDDIT}/api/flaircsv", flair_csv: load).each do |report|
45
- unless report.values_at("errors", "ok", "warnings") == [{}, true, {}]
46
- pp report
47
- abort "wrong keys" unless report.keys.sort == %w{ errors ok status warnings }
48
- abort "wrong values" unless report.values_at(*%w{ ok status warnings }) == [false, "skipped", {}]
49
- abort "wrong error keys" unless report["errors"].keys == %w{ user }
50
- abort "wrong error values" unless user = report["errors"]["user"][/\Aunable to resolve user `([A-Za-z-_\d]+)', ignoring\z/, 1]
51
- ignored |= [user]
52
- end
53
- end
54
- end
55
- end
56
-
57
- sleep 300
58
- end
@@ -1 +0,0 @@
1
- export LOGGING_KEYFILE=$GOOGLE_APPLICATION_CREDENTIALS_NAKILONPRO_LOGGING
@@ -1,13 +0,0 @@
1
- function doGet(e) {
2
- const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
3
- const range = sheet.getRange("A2:D100"); // hardcode
4
- console.log(e.parameter.payload);
5
- payload = JSON.parse(Utilities.newBlob(Utilities.base64Decode(e.parameter.payload)).getDataAsString());
6
- range.moveTo(range.offset(1, 0));
7
- sheet.getRange("A2:2").setValues( [ [
8
- payload.messaged_at,
9
- payload.processed_at,
10
- payload.name,
11
- payload.text,
12
- ] ] ); // hardcoded columns order
13
- }
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "reddit_bot", "~>1.3.0"
4
- gem "jwt", "<2" # Ruby 2.0
5
- gem "gcplogger", git: "git@github.com:Nakilon/gcplogger.git"