snoo 0.1.1 → 0.1.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 +7 -0
- data/.gitignore +14 -13
- data/Gemfile.lock +32 -0
- data/README.md +11 -0
- data/examples/modlog_report_generator/Gemfile +7 -0
- data/examples/modlog_report_generator/README.md +45 -0
- data/examples/modlog_report_generator/modreport.rb +134 -0
- data/examples/modmailer/Gemfile.lock +20 -0
- data/examples/modmailer/modmail.rb +1 -0
- data/lib/snoo/account.rb +1 -1
- data/lib/snoo/links_comments.rb +9 -0
- data/lib/snoo/version.rb +4 -1
- metadata +18 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4a7fdd5cd9346d80ab767c7a08d21e7ec372de5f
|
4
|
+
data.tar.gz: 181e6c309afb527984f3bd19f155a1fb2bb78047
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c46e3b5386c49361bad02ffe8f5cabd851841cd007fc52eba5770b95440ce86cf7d8290c135a5a0b8c2c01ac0276a46071179f29902ea63738a7c0947b13c32b
|
7
|
+
data.tar.gz: 3344ac3c1db1ddfe24e8cb206d48031d456ef83a63587d4570b9926dc00a432fcaefd95291cfea1d04fc856a23b1ec0b8b96c764bc5c757983f956c685a61957
|
data/.gitignore
CHANGED
@@ -1,19 +1,20 @@
|
|
1
|
+
tmp
|
2
|
+
spec/reports
|
3
|
+
coverage
|
4
|
+
|
1
5
|
*.gem
|
6
|
+
InstalledFiles
|
2
7
|
*.rbc
|
3
|
-
.bundle
|
4
8
|
.config
|
9
|
+
rdoc
|
10
|
+
snoo.sublime-project
|
11
|
+
test/version_tmp
|
12
|
+
lib/bundler/man
|
13
|
+
.bundle
|
14
|
+
snoo.sublime-workspace
|
15
|
+
doc/
|
16
|
+
.DS_Store
|
5
17
|
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
18
|
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
19
|
test/tmp
|
16
|
-
|
17
|
-
tmp
|
18
|
-
|
19
|
-
.DS_Store
|
20
|
+
pkg
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
snoo (0.0.4)
|
5
|
+
httparty
|
6
|
+
nokogiri
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.1.3)
|
12
|
+
httparty (0.8.3)
|
13
|
+
multi_json (~> 1.0)
|
14
|
+
multi_xml
|
15
|
+
multi_json (1.3.6)
|
16
|
+
multi_xml (0.5.1)
|
17
|
+
nokogiri (1.5.5)
|
18
|
+
rspec (2.11.0)
|
19
|
+
rspec-core (~> 2.11.0)
|
20
|
+
rspec-expectations (~> 2.11.0)
|
21
|
+
rspec-mocks (~> 2.11.0)
|
22
|
+
rspec-core (2.11.0)
|
23
|
+
rspec-expectations (2.11.1)
|
24
|
+
diff-lcs (~> 1.1.3)
|
25
|
+
rspec-mocks (2.11.0)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
rspec
|
32
|
+
snoo!
|
data/README.md
CHANGED
@@ -53,6 +53,17 @@ See the [docs](http://rubydoc.info/github/paradox460/snoo/) for more info.
|
|
53
53
|
4. Push to the branch (`git push origin my-new-feature`)
|
54
54
|
5. Create new Pull Request
|
55
55
|
|
56
|
+
## Feed me!
|
57
|
+
Any and all donations are graciously accepted:
|
58
|
+
|
59
|
+
+ [](https://flattr.com/submit/auto?user_id=Paradox460&url=https://github.com/paradox460/snoo&title=Snoo&language=&tags=github&category=software)
|
60
|
+
+ [Gittip](https://www.gittip.com/paradox460/)
|
61
|
+
+ Paypal: send to paradox460@gmail.com
|
62
|
+
|
63
|
+
I also would love it if you could endorse this on Coderwall: [](http://coderwall.com/paradox)
|
64
|
+
|
65
|
+
Thanks!
|
66
|
+
|
56
67
|
## License
|
57
68
|
|
58
69
|
```
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Requirements
|
2
|
+
+ You must be running a 1.9x or newer version of ruby. I do not support 1.8 or older.
|
3
|
+
+ You must use bundler. `bundle install` for the various dependencies
|
4
|
+
+ You must be comfortable editing code, but if you can follow comments, you can use this script
|
5
|
+
|
6
|
+
# Running the script
|
7
|
+
1. Edit modreport.rb to fill in the required information
|
8
|
+
+ **Username:** Self-explanatory
|
9
|
+
+ **Password:** Self-explanatory
|
10
|
+
+ **Subreddit:** the subreddit, without the `/r/`. IAMA would be `IAMA`. Case does not matter
|
11
|
+
+ **Start Date:** The beginning (oldest) of when you want to parse. Uses ruby `Date.parse`, so any supported syntax works, but I recommend `December 1, 2012 0:00 UTC` style syntax
|
12
|
+
+ **End Date:** The end (newest) of when you want to parse. Uses ruby `Date.parse`, so any supported syntax works, but I recommend `December 1, 2012 0:00 UTC` style syntax
|
13
|
+
+ **CSV Prefix:** The prefix for the CSV files you want to generate. I usually name mine something like `subreddit-month`
|
14
|
+
2. Run `ruby modreport.rb`
|
15
|
+
3. Watch the response for errors
|
16
|
+
+ [Open an issue on the tracker if you find one](https://github.com/paradox460/snoo/issues)
|
17
|
+
4. Open the CSV files in excel or your spreadsheet of choice and do what you will with them
|
18
|
+
|
19
|
+
# License
|
20
|
+
This is licensed under the same terms as the Snoo script, the MIT License:
|
21
|
+
|
22
|
+
```
|
23
|
+
Copyright (c) 2012 Jeff Sandberg
|
24
|
+
|
25
|
+
MIT License
|
26
|
+
|
27
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
28
|
+
a copy of this software and associated documentation files (the
|
29
|
+
"Software"), to deal in the Software without restriction, including
|
30
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
31
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
32
|
+
permit persons to whom the Software is furnished to do so, subject to
|
33
|
+
the following conditions:
|
34
|
+
|
35
|
+
The above copyright notice and this permission notice shall be
|
36
|
+
included in all copies or substantial portions of the Software.
|
37
|
+
|
38
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
39
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
40
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
41
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
42
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
43
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
44
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
45
|
+
```
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'snoo'
|
2
|
+
require 'csv'
|
3
|
+
require 'set'
|
4
|
+
require 'highline/import'
|
5
|
+
|
6
|
+
reddit = Snoo::Client.new
|
7
|
+
|
8
|
+
# CONFIG BLOCK
|
9
|
+
|
10
|
+
username = ask("Username: ")
|
11
|
+
password = ask("Password: ") { |c| c.echo = '*' ; c.readline = true}
|
12
|
+
|
13
|
+
subreddit = ask("Subreddit: ")
|
14
|
+
|
15
|
+
start_date = ask("Start Date: ")
|
16
|
+
end_date = ask("End Date: ")
|
17
|
+
|
18
|
+
csv_prefix = ask("CSV Prefix: ")
|
19
|
+
|
20
|
+
|
21
|
+
reddit.log_in username, password
|
22
|
+
|
23
|
+
modlog = reddit.get_modlog(subreddit)
|
24
|
+
data, last = modlog[:data], modlog[:last]
|
25
|
+
while (data[-1][:time] > Time.parse(start_date) ) do
|
26
|
+
begin
|
27
|
+
modlog = reddit.get_modlog(subreddit, after: last)
|
28
|
+
last = modlog[:last]
|
29
|
+
data.concat modlog[:data]
|
30
|
+
puts "Got #{data[-1][:time]}"
|
31
|
+
sleep 2
|
32
|
+
rescue
|
33
|
+
puts "Error in modlog. subreddit: #{subreddit} last: #{last} modlog #{modlog}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
data.delete_if do |i|
|
38
|
+
(i[:time] > Time.parse(end_date)) or (i[:time] < Time.parse(start_date)) or (i[:author] == 'RoboMod')
|
39
|
+
end
|
40
|
+
|
41
|
+
modlist = {}
|
42
|
+
data.each do |i|
|
43
|
+
modlist[i[:author]] ||= Hash.new(0)
|
44
|
+
modlist[i[:author]][i[:action]] += 1
|
45
|
+
end
|
46
|
+
|
47
|
+
CSV.open("#{csv_prefix}.csv", "wb") do |csv|
|
48
|
+
csv << ["Mod", "Remove", "Approve", "Remove Comment", "Approve Comment", "NSFW", "Edit Flair", "Edit Settings", "Distingusih", "Ban", "Unban", "Add Mod", "Remove Mod", "Add Contrib.", "Remove Contrib."]
|
49
|
+
modlist.each do |k, v|
|
50
|
+
csv << [
|
51
|
+
k,
|
52
|
+
v["removelink"],
|
53
|
+
v["approvelink"],
|
54
|
+
v["removecomment"],
|
55
|
+
v["approvecomment"],
|
56
|
+
v["marknsfw"],
|
57
|
+
v["editflair"],
|
58
|
+
v["editsettings"],
|
59
|
+
v["distinguish"],
|
60
|
+
v["banuser"],
|
61
|
+
v["unbanuser"],
|
62
|
+
v["addmoderator"],
|
63
|
+
v["removemoderator"],
|
64
|
+
v["addcontributor"],
|
65
|
+
v["removecontributor"]
|
66
|
+
]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
puts "Saved #{csv_prefix}.csv with modlog table"
|
70
|
+
|
71
|
+
modtime = {}
|
72
|
+
data.each do |m|
|
73
|
+
modtime[Date.parse(m[:time].utc.strftime('%Y-%m-%d'))] ||= Hash.new(0)
|
74
|
+
modtime[Date.parse(m[:time].utc.strftime('%Y-%m-%d'))][m[:action]] += 1
|
75
|
+
end
|
76
|
+
|
77
|
+
CSV.open("#{csv_prefix}_time.csv", "wb") do |csv|
|
78
|
+
csv << ["Date", "Remove", "Approve", "Remove Comment", "Approve Comment", "NSFW", "Edit Flair", "Edit Settings", "Distingusih", "Ban", "Unban", "Add Mod", "Remove Mod", "Add Contrib.", "Remove Contrib."]
|
79
|
+
modtime.each do |k, v|
|
80
|
+
csv << [
|
81
|
+
k.strftime('%Y-%m-%d'),
|
82
|
+
v["removelink"],
|
83
|
+
v["approvelink"],
|
84
|
+
v["removecomment"],
|
85
|
+
v["approvecomment"],
|
86
|
+
v["marknsfw"],
|
87
|
+
v["editflair"],
|
88
|
+
v["editsettings"],
|
89
|
+
v["distinguish"],
|
90
|
+
v["banuser"],
|
91
|
+
v["unbanuser"],
|
92
|
+
v["addmoderator"],
|
93
|
+
v["removemoderator"],
|
94
|
+
v["addcontributor"],
|
95
|
+
v["removecontributor"]
|
96
|
+
]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
puts "Saved #{csv_prefix}_time.csv with time-series data"
|
100
|
+
|
101
|
+
|
102
|
+
# Moderator activity per day
|
103
|
+
authors = Set.new
|
104
|
+
data.each do |i|
|
105
|
+
authors << i[:author]
|
106
|
+
end
|
107
|
+
|
108
|
+
authorhash = {}
|
109
|
+
authors.to_a.each do |i|
|
110
|
+
authorhash[i] = 0
|
111
|
+
end
|
112
|
+
|
113
|
+
modactivity = {}
|
114
|
+
data.each do |m|
|
115
|
+
modactivity[Date.parse(m[:time].utc.strftime('%Y-%m-%d'))] ||= authorhash.dup
|
116
|
+
modactivity[Date.parse(m[:time].utc.strftime('%Y-%m-%d'))][m[:author]] += 1
|
117
|
+
end
|
118
|
+
|
119
|
+
header = ["Date"]
|
120
|
+
header += authors.to_a
|
121
|
+
|
122
|
+
CSV.open("#{csv_prefix}_actions_over_time.csv", "wb") do |csv|
|
123
|
+
csv << header
|
124
|
+
modactivity.each do |k, v|
|
125
|
+
line = []
|
126
|
+
line << k.strftime('%Y-%m-%d')
|
127
|
+
v.each do |name, amount|
|
128
|
+
line << amount
|
129
|
+
end
|
130
|
+
csv << line
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
puts "Saved #{csv_prefix}_actions_over_time.csv with actions-over-time data"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
highline (1.6.14)
|
5
|
+
httparty (0.8.3)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
multi_xml
|
8
|
+
multi_json (1.3.6)
|
9
|
+
multi_xml (0.5.1)
|
10
|
+
nokogiri (1.5.5)
|
11
|
+
snoo (0.0.6)
|
12
|
+
httparty
|
13
|
+
nokogiri
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
highline
|
20
|
+
snoo
|
@@ -146,6 +146,7 @@ else
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
editor_name = ENV['EDITOR']
|
149
|
+
raise "Unknown Editor" unless editor_name
|
149
150
|
system "#{editor_name} #{blocking_flag_for_editor(true, editor_name)} #{start_line_syntax_for_editor(editor_name, modmessage_path, 4)}"
|
150
151
|
|
151
152
|
message['message'] = File.read(modmessage_path)
|
data/lib/snoo/account.rb
CHANGED
@@ -35,7 +35,7 @@ module Snoo
|
|
35
35
|
# Logs out of a reddit account. This is usually uneeded, you can just log_in as a new account to replace the current one.
|
36
36
|
# This just nils the cookies and modhash
|
37
37
|
def log_out
|
38
|
-
set_cookies
|
38
|
+
set_cookies ""
|
39
39
|
@modhash = nil
|
40
40
|
@userid = nil
|
41
41
|
@username = nil
|
data/lib/snoo/links_comments.rb
CHANGED
@@ -124,6 +124,15 @@ module Snoo
|
|
124
124
|
end
|
125
125
|
alias_method :mark_sfw, :unmark_nsfw
|
126
126
|
|
127
|
+
# Un-save a thing
|
128
|
+
#
|
129
|
+
# @param (see #delete)
|
130
|
+
# @return (see #clear_sessions)
|
131
|
+
def unsave id
|
132
|
+
logged_in?
|
133
|
+
post('/api/unsave', body: {id: id, uh: @modhash, api_type: 'json'})
|
134
|
+
end
|
135
|
+
|
127
136
|
# Vote on a comment or link
|
128
137
|
#
|
129
138
|
# @param direction [-1, 0, 1] The direction to vote in. -1 is a downvote, 1 is an upvote, 0 cancels any vote
|
data/lib/snoo/version.rb
CHANGED
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jeff Sandberg
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-07-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: httparty
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: nokogiri
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Snoo is yet another reddit API wrapper. Unlike the other wrappers out
|
@@ -73,13 +66,18 @@ files:
|
|
73
66
|
- .yardopts
|
74
67
|
- CHANGELOG.md
|
75
68
|
- Gemfile
|
69
|
+
- Gemfile.lock
|
76
70
|
- LICENSE
|
77
71
|
- README.md
|
78
72
|
- Rakefile
|
79
73
|
- examples/flairbot/README.md
|
80
74
|
- examples/flairbot/config.yaml
|
81
75
|
- examples/flairbot/flair.rb
|
76
|
+
- examples/modlog_report_generator/Gemfile
|
77
|
+
- examples/modlog_report_generator/README.md
|
78
|
+
- examples/modlog_report_generator/modreport.rb
|
82
79
|
- examples/modmailer/Gemfile
|
80
|
+
- examples/modmailer/Gemfile.lock
|
83
81
|
- examples/modmailer/modmail.rb
|
84
82
|
- lib/snoo.rb
|
85
83
|
- lib/snoo/account.rb
|
@@ -99,27 +97,26 @@ files:
|
|
99
97
|
homepage: https://github.com/paradox460/snoo
|
100
98
|
licenses:
|
101
99
|
- MIT
|
100
|
+
metadata: {}
|
102
101
|
post_install_message:
|
103
102
|
rdoc_options: []
|
104
103
|
require_paths:
|
105
104
|
- lib
|
106
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
106
|
requirements:
|
109
|
-
- -
|
107
|
+
- - '>='
|
110
108
|
- !ruby/object:Gem::Version
|
111
109
|
version: '1.9'
|
112
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
111
|
requirements:
|
115
|
-
- -
|
112
|
+
- - '>='
|
116
113
|
- !ruby/object:Gem::Version
|
117
114
|
version: '0'
|
118
115
|
requirements: []
|
119
116
|
rubyforge_project:
|
120
|
-
rubygems_version:
|
117
|
+
rubygems_version: 2.0.3
|
121
118
|
signing_key:
|
122
|
-
specification_version:
|
119
|
+
specification_version: 4
|
123
120
|
summary: A simple reddit api wrapper
|
124
121
|
test_files:
|
125
122
|
- spec/auth.rb
|