reddit_bot 0.1.2 → 0.1.3
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 +73 -0
- data/examples/boilerplate.rb +2 -2
- data/examples/largeimages/Gemfile +4 -0
- data/examples/largeimages/Gemfile.lock +15 -0
- data/examples/largeimages/main.rb +30 -0
- data/lib/reddit_bot.rb +2 -2
- data/reddit_bot.gemspec +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f71731b982933f8e4326cb498f7d9d26192ff106
|
4
|
+
data.tar.gz: 89fd6b15ed1cb5b6140499eeebaa3700f4e511d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f50a272953603b3312ae011fb232253b90b32a14089ee05cdcacfbbeee2d2e615bc2c9218cfbc68e54a494489273ac759e8d36c73c9869b5f6778b062b4cd94b
|
7
|
+
data.tar.gz: 7c87aeff60aa38951ffbeeacde592da865142df88b083e670e9ef9c889a813759dbcdb21d87fd8eaa1081146b7afa67b6227d08d59790bdcf21132769c6b4019
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# RedditBot
|
2
|
+
|
3
|
+
[](https://gitter.im/Nakilon/reddit_bot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
+
|
5
|
+
[](http://badge.fury.io/rb/mll)
|
6
|
+
|
7
|
+
#### What
|
8
|
+
|
9
|
+
This library provides an easy way to run bots and scripts that use Reddit API.
|
10
|
+
I (@nakilon) currently run 8 bots with it.
|
11
|
+
|
12
|
+
#### Why
|
13
|
+
|
14
|
+
Python (and so PRAW) sucks.
|
15
|
+
|
16
|
+
#### Examples
|
17
|
+
|
18
|
+
The [examples folder](examples) includes:
|
19
|
+
|
20
|
+
* iostroubleshooting -- (currently active) bot that applies flairs to posts
|
21
|
+
* mlgtv -- (currently active) bot that updates sidebar with currently streaming twitch channels
|
22
|
+
* largeimages -- useful script for [subreddit /r/largeimages](https://reddit.com/r/largeimages/top)
|
23
|
+
It calculates quality of x-posts from different subreddits based on mods activity (remove/approve).
|
24
|
+
For example, this shows that it would be ok to ignore /r/pics from now:
|
25
|
+
|
26
|
+
pics Total: 98 Quality: 19%
|
27
|
+
wallpapers Total: 69 Quality: 52%
|
28
|
+
wallpaper Total: 45 Quality: 51%
|
29
|
+
woahdude Total: 30 Quality: 66%
|
30
|
+
CityPorn Total: 17 Quality: 82%
|
31
|
+
FoodPorn Total: 13 Quality: 7%
|
32
|
+
MapPorn Total: 13 Quality: 46%
|
33
|
+
SkyPorn Total: 11 Quality: 45%
|
34
|
+
carporn Total: 11 Quality: 45%
|
35
|
+
InfrastructurePorn Total: 9 Quality: 77%
|
36
|
+
ArtPorn Total: 9 Quality: 22%
|
37
|
+
EarthPorn Total: 8 Quality: 75%
|
38
|
+
waterporn Total: 8 Quality: 87%
|
39
|
+
GunPorn Total: 7 Quality: 85%
|
40
|
+
ExposurePorn Total: 7 Quality: 57%
|
41
|
+
DessertPorn Total: 7 Quality: 14%
|
42
|
+
MilitaryPorn Total: 7 Quality: 57%
|
43
|
+
ArchitecturePorn Total: 7 Quality: 57%
|
44
|
+
spaceporn Total: 7 Quality: 14%
|
45
|
+
AbandonedPorn Total: 6 Quality: 50%
|
46
|
+
|
47
|
+
You obviously can't run these examples as is, because they have some dependencies that are not in this repo. Like `secrets` file for authorization of the following format:
|
48
|
+
|
49
|
+
Kb9.......6wBw
|
50
|
+
Fqo.....................AFI
|
51
|
+
mybotpassword
|
52
|
+
MyBotUsername
|
53
|
+
|
54
|
+
#### Usage
|
55
|
+
|
56
|
+
$ gem install reddit_bot
|
57
|
+
|
58
|
+
helloworld.rb:
|
59
|
+
|
60
|
+
require "reddit_bot"
|
61
|
+
|
62
|
+
probably Gemfile:
|
63
|
+
|
64
|
+
source "https://rubygems.org"
|
65
|
+
gem "reddit_bot"
|
66
|
+
|
67
|
+
TODO: Write usage instructions here
|
68
|
+
TODO: manual on how to create bots with Reddit web interface and run via bash console
|
69
|
+
|
70
|
+
#### Contributing and License
|
71
|
+
|
72
|
+
Bug reports and pull requests are welcome.
|
73
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/examples/boilerplate.rb
CHANGED
@@ -10,6 +10,6 @@ require "reddit_bot"
|
|
10
10
|
# RedditBot.init *File.read(File.join(Dir.pwd, "secrets")).split, ignore_captcha: true
|
11
11
|
RedditBot.init *File.read("secrets").split, ignore_captcha: true
|
12
12
|
|
13
|
-
require_relative File.join
|
14
|
-
*("
|
13
|
+
require_relative File.join "../..",
|
14
|
+
*(".." if ENV["LOGNAME"] == "nakilon"),
|
15
15
|
"awsstatus/2.rb"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
cache = lambda do |&block|
|
2
|
+
require "yaml"
|
3
|
+
next YAML.load File.read "cache.yaml" if File.exist? "cache.yaml"
|
4
|
+
block.call.tap do |data|
|
5
|
+
File.write "cache.yaml", YAML.dump(data)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
require_relative File.join "..", "boilerplate"
|
11
|
+
SUBREDDIT = "largeimages"
|
12
|
+
|
13
|
+
table = cache.call do
|
14
|
+
RedditBot.json(:get, "/r/#{SUBREDDIT}/about/log", [["limit", 500]])["data"]["children"].map do |child|
|
15
|
+
fail child unless child["kind"] == "modaction"
|
16
|
+
next unless %w{ removelink approvelink }.include? child["data"]["action"]
|
17
|
+
title = RedditBot.json(:get, "/api/info", [["id", child["data"]["target_fullname"]]])["data"]["children"][0]["data"]["title"]
|
18
|
+
[child["data"]["action"], title[/(?<=^\[)\d+x\d+/], title[/[^\/]+$/]]
|
19
|
+
end.compact
|
20
|
+
end
|
21
|
+
|
22
|
+
report = table.group_by(&:last).sort_by{ |_, group| -group.size }.map do |sub, group|
|
23
|
+
good = (group.group_by(&:first)["approvelink"] || []).size
|
24
|
+
[sub, "Total: #{group.size}", "Quality: #{good * 100 / group.size}%"]
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
require "mll"
|
29
|
+
|
30
|
+
puts MLL::grid[report.take(20), spacings: [3, 0]]
|
data/lib/reddit_bot.rb
CHANGED
@@ -8,7 +8,7 @@ require "json"
|
|
8
8
|
|
9
9
|
|
10
10
|
module RedditBot
|
11
|
-
VERSION = "0.1.
|
11
|
+
VERSION = "0.1.3"
|
12
12
|
|
13
13
|
class << self
|
14
14
|
|
@@ -164,7 +164,7 @@ module RedditBot
|
|
164
164
|
end
|
165
165
|
response = begin
|
166
166
|
http.request request
|
167
|
-
rescue Net::ReadTimeout, Errno::EPIPE
|
167
|
+
rescue Net::ReadTimeout, Errno::EPIPE, EOFError
|
168
168
|
puts "ERROR: Net::ReadTimeout"
|
169
169
|
retry
|
170
170
|
end
|
data/reddit_bot.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
# spec.add_development_dependency "bundler", "~> 1.11"
|
22
22
|
# spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
# spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.required_ruby_version = ">= 2.0.0"
|
24
25
|
end
|
25
26
|
|
26
27
|
# spec.test_files = ["spec/"]
|
27
|
-
# spec.required_ruby_version = ">= 2.0.0"
|
28
28
|
# spec.post_install_message = ""
|
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: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Maslov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -33,11 +33,15 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- Gemfile
|
35
35
|
- LICENSE.txt
|
36
|
+
- README.md
|
36
37
|
- Rakefile
|
37
38
|
- examples/boilerplate.rb
|
38
39
|
- examples/iostroubleshooting/Gemfile
|
39
40
|
- examples/iostroubleshooting/Gemfile.lock
|
40
41
|
- examples/iostroubleshooting/main.rb
|
42
|
+
- examples/largeimages/Gemfile
|
43
|
+
- examples/largeimages/Gemfile.lock
|
44
|
+
- examples/largeimages/main.rb
|
41
45
|
- examples/mlgtv/Gemfile
|
42
46
|
- examples/mlgtv/Gemfile.lock
|
43
47
|
- examples/mlgtv/main.rb
|
@@ -55,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
59
|
requirements:
|
56
60
|
- - '>='
|
57
61
|
- !ruby/object:Gem::Version
|
58
|
-
version:
|
62
|
+
version: 2.0.0
|
59
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
64
|
requirements:
|
61
65
|
- - '>='
|