redd 0.6.5 → 0.7.0
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/.gitignore +34 -33
- data/.rspec +3 -4
- data/.rubocop.yml +5 -5
- data/.travis.yml +9 -7
- data/{LICENSE.md → LICENSE.txt} +22 -22
- data/README.md +126 -241
- data/Rakefile +5 -6
- data/{RedditKit.LICENSE.md → RedditKit.LICENSE.txt} +13 -13
- data/lib/redd.rb +50 -4
- data/lib/redd/access.rb +76 -0
- data/lib/redd/clients/base.rb +178 -0
- data/lib/redd/clients/base/account.rb +20 -0
- data/lib/redd/clients/base/identity.rb +22 -0
- data/lib/redd/clients/base/none.rb +27 -0
- data/lib/redd/clients/base/privatemessages.rb +28 -0
- data/lib/redd/clients/base/read.rb +66 -0
- data/lib/redd/clients/base/stream.rb +74 -0
- data/lib/redd/clients/base/submit.rb +54 -0
- data/lib/redd/clients/base/utilities.rb +80 -0
- data/lib/redd/clients/base/wikiread.rb +33 -0
- data/lib/redd/clients/installed.rb +55 -0
- data/lib/redd/clients/script.rb +37 -0
- data/lib/redd/clients/userless.rb +31 -0
- data/lib/redd/clients/web.rb +57 -0
- data/lib/redd/error.rb +138 -153
- data/lib/redd/objects/base.rb +36 -0
- data/lib/redd/objects/comment.rb +22 -0
- data/lib/redd/objects/listing.rb +29 -0
- data/lib/redd/objects/more_comments.rb +10 -0
- data/lib/redd/objects/private_message.rb +18 -0
- data/lib/redd/objects/submission.rb +72 -0
- data/lib/redd/objects/subreddit.rb +152 -0
- data/lib/redd/objects/thing.rb +33 -0
- data/lib/redd/objects/thing/editable.rb +22 -0
- data/lib/redd/objects/thing/hideable.rb +18 -0
- data/lib/redd/objects/thing/inboxable.rb +25 -0
- data/lib/redd/objects/thing/messageable.rb +34 -0
- data/lib/redd/objects/thing/moderatable.rb +43 -0
- data/lib/redd/objects/thing/refreshable.rb +14 -0
- data/lib/redd/objects/thing/saveable.rb +21 -0
- data/lib/redd/objects/thing/votable.rb +33 -0
- data/lib/redd/objects/user.rb +52 -0
- data/lib/redd/objects/wiki_page.rb +15 -0
- data/lib/redd/rate_limit.rb +50 -49
- data/lib/redd/response/parse_json.rb +17 -33
- data/lib/redd/response/raise_error.rb +16 -25
- data/lib/redd/version.rb +4 -5
- data/redd.gemspec +30 -31
- data/spec/redd/objects/base_spec.rb +1 -0
- data/spec/redd/rate_limit_spec.rb +29 -29
- data/spec/redd/response/parse_json_spec.rb +12 -0
- data/spec/redd/response/raise_error_spec.rb +11 -0
- data/spec/redd_spec.rb +7 -5
- data/spec/spec_helper.rb +69 -50
- metadata +73 -136
- data/.yardopts +0 -1
- data/lib/redd/base.rb +0 -56
- data/lib/redd/client/authenticated.rb +0 -83
- data/lib/redd/client/authenticated/account.rb +0 -13
- data/lib/redd/client/authenticated/apps.rb +0 -13
- data/lib/redd/client/authenticated/flair.rb +0 -71
- data/lib/redd/client/authenticated/gold.rb +0 -13
- data/lib/redd/client/authenticated/links_comments.rb +0 -189
- data/lib/redd/client/authenticated/live.rb +0 -13
- data/lib/redd/client/authenticated/moderation.rb +0 -126
- data/lib/redd/client/authenticated/multis.rb +0 -9
- data/lib/redd/client/authenticated/private_messages.rb +0 -73
- data/lib/redd/client/authenticated/subreddits.rb +0 -172
- data/lib/redd/client/authenticated/users.rb +0 -9
- data/lib/redd/client/authenticated/wiki.rb +0 -9
- data/lib/redd/client/oauth2.rb +0 -71
- data/lib/redd/client/oauth2/authorization.rb +0 -108
- data/lib/redd/client/oauth2/identity.rb +0 -16
- data/lib/redd/client/oauth2_script.rb +0 -24
- data/lib/redd/client/oauth2_script/authorization.rb +0 -21
- data/lib/redd/client/unauthenticated.rb +0 -118
- data/lib/redd/client/unauthenticated/account.rb +0 -30
- data/lib/redd/client/unauthenticated/captcha.rb +0 -27
- data/lib/redd/client/unauthenticated/links_comments.rb +0 -60
- data/lib/redd/client/unauthenticated/listing.rb +0 -65
- data/lib/redd/client/unauthenticated/live.rb +0 -9
- data/lib/redd/client/unauthenticated/moderation.rb +0 -26
- data/lib/redd/client/unauthenticated/subreddits.rb +0 -49
- data/lib/redd/client/unauthenticated/users.rb +0 -67
- data/lib/redd/client/unauthenticated/utilities.rb +0 -109
- data/lib/redd/client/unauthenticated/wiki.rb +0 -33
- data/lib/redd/oauth2_access.rb +0 -70
- data/lib/redd/object/comment.rb +0 -74
- data/lib/redd/object/listing.rb +0 -29
- data/lib/redd/object/more_comments.rb +0 -14
- data/lib/redd/object/private_message.rb +0 -35
- data/lib/redd/object/submission.rb +0 -94
- data/lib/redd/object/subreddit.rb +0 -74
- data/lib/redd/object/user.rb +0 -34
- data/lib/redd/object/wiki_page.rb +0 -27
- data/lib/redd/thing.rb +0 -27
- data/lib/redd/thing/commentable.rb +0 -27
- data/lib/redd/thing/editable.rb +0 -16
- data/lib/redd/thing/hideable.rb +0 -16
- data/lib/redd/thing/inboxable.rb +0 -20
- data/lib/redd/thing/messageable.rb +0 -12
- data/lib/redd/thing/moderatable.rb +0 -32
- data/lib/redd/thing/reportable.rb +0 -12
- data/lib/redd/thing/saveable.rb +0 -16
- data/lib/redd/thing/voteable.rb +0 -22
- data/spec/README.md +0 -18
- data/spec/redd/base_spec.rb +0 -36
- data/spec/redd/client/authenticated/account_spec.rb +0 -5
- data/spec/redd/client/authenticated/apps_spec.rb +0 -2
- data/spec/redd/client/authenticated/flair_spec.rb +0 -26
- data/spec/redd/client/authenticated/gold_spec.rb +0 -2
- data/spec/redd/client/authenticated/links_comments_spec.rb +0 -231
- data/spec/redd/client/authenticated/live_spec.rb +0 -2
- data/spec/redd/client/unauthenticated/account_spec.rb +0 -15
- data/spec/redd/client/unauthenticated/captcha_spec.rb +0 -23
- data/spec/redd/client/unauthenticated/links_comments_spec.rb +0 -28
- data/spec/redd/client/unauthenticated/listing_spec.rb +0 -23
- data/spec/redd/client/unauthenticated/live_spec.rb +0 -2
- data/spec/redd/client/unauthenticated/moderation_spec.rb +0 -14
- data/spec/redd/client/unauthenticated/subreddits_spec.rb +0 -35
- data/spec/redd/client/unauthenticated/users_spec.rb +0 -34
- data/spec/redd/client/unauthenticated/wiki_spec.rb +0 -18
- data/spec/redd/oauth2_access_spec.rb +0 -83
- data/spec/redd/thing_spec.rb +0 -22
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Redd
|
|
2
|
-
module Client
|
|
3
|
-
class Authenticated
|
|
4
|
-
# Methods to interact with OAuth2 Apps
|
|
5
|
-
module Apps
|
|
6
|
-
# Low-Priority
|
|
7
|
-
#
|
|
8
|
-
# There should be very little reasons for bots to mess around with app
|
|
9
|
-
# settings, so this module might be worked on later or not at all.
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
module Redd
|
|
2
|
-
module Client
|
|
3
|
-
class Authenticated
|
|
4
|
-
# Methods to interact with link and user flairs.
|
|
5
|
-
module Flair
|
|
6
|
-
# Get a list of everbody on the subreddit with a user flair.
|
|
7
|
-
#
|
|
8
|
-
# @param subreddit [Redd::Object::Subreddit, String] The subreddit to
|
|
9
|
-
# find the users in.
|
|
10
|
-
# @param params [Hash] A list of params to send with the request.
|
|
11
|
-
# @option params [String] :after Return results after the given
|
|
12
|
-
# fullname.
|
|
13
|
-
# @option params [String] :before Return results before the given
|
|
14
|
-
# fullname.
|
|
15
|
-
# @option params [Integer] :count (0) The number of items already seen
|
|
16
|
-
# in the listing.
|
|
17
|
-
# @option params [1..1000] :limit (25) The maximum number of things to
|
|
18
|
-
# return.
|
|
19
|
-
# @return [Array<Hash>] An array of users.
|
|
20
|
-
def get_flair_list(subreddit, params = {})
|
|
21
|
-
name = extract_attribute(subreddit, :display_name)
|
|
22
|
-
|
|
23
|
-
path = "/api/flairlist.json"
|
|
24
|
-
path = path.prepend("/r/#{name}")
|
|
25
|
-
|
|
26
|
-
get(path, params)[:users]
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Get the flair of a user.
|
|
30
|
-
#
|
|
31
|
-
# @param subreddit [Redd::Object::Subreddit, String] The subreddit to
|
|
32
|
-
# find the user in.
|
|
33
|
-
# @param user [Redd::Object::User, String] The user to find.
|
|
34
|
-
# @return [Hash, nil] Flair info about the user or nil if nobody was
|
|
35
|
-
# found.
|
|
36
|
-
def get_flair(subreddit, user)
|
|
37
|
-
display_name = extract_attribute(subreddit, :display_name)
|
|
38
|
-
username = extract_attribute(user, :name)
|
|
39
|
-
options = {name: username}
|
|
40
|
-
|
|
41
|
-
flair = get_flair_list(display_name, options).first
|
|
42
|
-
flair if flair[:user].casecmp(username.downcase) == 0
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# Set the flair of a user or link.
|
|
46
|
-
# @param subreddit [Redd::Object::Subreddit, String] The subreddit to
|
|
47
|
-
# find the user in.
|
|
48
|
-
# @param user_or_link [Redd::Object::Subreddit, Redd::Object::User]
|
|
49
|
-
# The user or link to set the flair to.
|
|
50
|
-
# @param text [String] The text to set the flair to.
|
|
51
|
-
# @param css_class [String] The css_class of the flair.
|
|
52
|
-
def set_flair(subreddit, user_or_link, text = "", css_class = "")
|
|
53
|
-
name = extract_attribute(subreddit, :display_name)
|
|
54
|
-
path = "/r/#{name}/api/flair"
|
|
55
|
-
params = {api_type: "json", text: text, css_class: css_class}
|
|
56
|
-
|
|
57
|
-
case user_or_link
|
|
58
|
-
when Redd::Object::User
|
|
59
|
-
params[:name] = extract_attribute(user_or_link, :name)
|
|
60
|
-
when Redd::Object::Submission
|
|
61
|
-
params[:link] = extract_attribute(user_or_link, :display_name)
|
|
62
|
-
else
|
|
63
|
-
fail "You should provide a User or Submission object."
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
post path, params
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Redd
|
|
2
|
-
module Client
|
|
3
|
-
class Authenticated
|
|
4
|
-
# Methods to gild a user, link or comment
|
|
5
|
-
module Gold
|
|
6
|
-
# Low-Priority
|
|
7
|
-
#
|
|
8
|
-
# Yeeaahh... Handing conrol of spending money to some code is pretty
|
|
9
|
-
# stupid. This might not be developed.
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
module Redd
|
|
2
|
-
module Client
|
|
3
|
-
class Authenticated
|
|
4
|
-
# Methods to deal with comments and links
|
|
5
|
-
module LinksComments
|
|
6
|
-
# Submit a link or a text post to a subreddit.
|
|
7
|
-
#
|
|
8
|
-
# @param title [String] The title of the submission.
|
|
9
|
-
# @param kind [:self, :link] The type of submission to make.
|
|
10
|
-
# @param text_or_url [String] The url of the post if :link or the
|
|
11
|
-
# content of the post if :text
|
|
12
|
-
# @param subreddit [Redd::Object::Submission, String] The subreddit
|
|
13
|
-
# to submit to.
|
|
14
|
-
# @param captcha [String] A possible captcha result to send if one
|
|
15
|
-
# is required.
|
|
16
|
-
# @param identifier [String] The identifier for the captcha if one
|
|
17
|
-
# is required.
|
|
18
|
-
# @param options [Hash] A hash of additional options to send.
|
|
19
|
-
# @option options [Boolean] :resubmit (false) Whether to post a link
|
|
20
|
-
# to a subreddit despite it having been posted there before.
|
|
21
|
-
# @option options [Boolean] :resubmit (false) Whether to automatically
|
|
22
|
-
# save the post to the user's account after posting.
|
|
23
|
-
def submit(
|
|
24
|
-
title, kind, text_or_url, subreddit, captcha = nil, identifier = nil,
|
|
25
|
-
options = {}
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
params = {
|
|
29
|
-
api_type: "json", extension: "json", title: title, kind: kind
|
|
30
|
-
}
|
|
31
|
-
sr_name = extract_attribute(subreddit, :display_name)
|
|
32
|
-
params << {sr: sr_name}
|
|
33
|
-
|
|
34
|
-
case kind.to_sym
|
|
35
|
-
when :self
|
|
36
|
-
params[:text] = text_or_url
|
|
37
|
-
when :link
|
|
38
|
-
params[:url] = text_or_url
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
params << {captcha: captcha, iden: identifier} if captcha
|
|
42
|
-
params << options
|
|
43
|
-
|
|
44
|
-
post "/api/submit", params
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Add a comment to a link, reply to a comment or reply to a message.
|
|
48
|
-
# Bit of an all-purpose method, this one.
|
|
49
|
-
#
|
|
50
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment,
|
|
51
|
-
# Redd::Object::PrivateMessage, String] A thing to add a comment to.
|
|
52
|
-
# @param text [String] The text to comment.
|
|
53
|
-
def add_comment(thing, text)
|
|
54
|
-
fullname = extract_fullname(thing)
|
|
55
|
-
post "/api/comment", api_type: "json", text: text, thing_id: fullname
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
alias_method :reply, :add_comment
|
|
59
|
-
|
|
60
|
-
# Delete a thing.
|
|
61
|
-
#
|
|
62
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment,
|
|
63
|
-
# String] A thing to delete.
|
|
64
|
-
def delete(thing)
|
|
65
|
-
fullname = extract_fullname(thing)
|
|
66
|
-
post "/api/del", id: fullname
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Edit a thing.
|
|
70
|
-
#
|
|
71
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment,
|
|
72
|
-
# String] A thing to delete.
|
|
73
|
-
# @param text [String] The new text.
|
|
74
|
-
def edit(thing, text)
|
|
75
|
-
fullname = extract_fullname(thing)
|
|
76
|
-
post "/api/editusertext", api_type: "json",
|
|
77
|
-
thing_id: fullname,
|
|
78
|
-
text: text
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# Hide a link from the logged-in user.
|
|
82
|
-
#
|
|
83
|
-
# @param thing [Redd::Object::Submission, String] A link to hide.
|
|
84
|
-
def hide(thing)
|
|
85
|
-
fullname = extract_fullname(thing)
|
|
86
|
-
post "/api/hide", id: fullname
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
# Unhide a previously hidden link.
|
|
90
|
-
#
|
|
91
|
-
# @param thing [Redd::Object::Submission, String] A link to show.
|
|
92
|
-
def unhide(thing)
|
|
93
|
-
fullname = extract_fullname(thing)
|
|
94
|
-
post "/api/unhide", id: fullname
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# Mark a link as "NSFW" (Not Suitable For Work)
|
|
98
|
-
#
|
|
99
|
-
# @param thing [Redd::Object::Submission, String] A link to mark.
|
|
100
|
-
def mark_as_nsfw(thing)
|
|
101
|
-
fullname = extract_fullname(thing)
|
|
102
|
-
post "/api/marknsfw", id: fullname
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# Remove the NSFW label from the link.
|
|
106
|
-
#
|
|
107
|
-
# @param thing [Redd::Object::Submission, String] A link to mark.
|
|
108
|
-
def unmark_as_nsfw(thing)
|
|
109
|
-
fullname = extract_fullname(thing)
|
|
110
|
-
post "/api/unmarknsfw", id: fullname
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
alias_method :mark_as_safe, :unmark_as_nsfw
|
|
114
|
-
|
|
115
|
-
# Report the link or comment to the subreddit moderators.
|
|
116
|
-
#
|
|
117
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment,
|
|
118
|
-
# String] A link to report.
|
|
119
|
-
def report(thing)
|
|
120
|
-
fullname = extract_fullname(thing)
|
|
121
|
-
post "/api/report", id: fullname
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
# Save a link or comment (if gilded) to the user's account.
|
|
125
|
-
#
|
|
126
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment,
|
|
127
|
-
# String] A link to save.
|
|
128
|
-
# @param category [String] A category to save to (if gilded).
|
|
129
|
-
def save(thing, category = nil)
|
|
130
|
-
fullname = extract_fullname(thing)
|
|
131
|
-
params = {id: fullname}
|
|
132
|
-
params << {category: category} if category
|
|
133
|
-
post "/api/save", params
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
# Remove the link or comment from the user's saved links.
|
|
137
|
-
#
|
|
138
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment,
|
|
139
|
-
# String] A link to unsave.
|
|
140
|
-
def unsave(thing)
|
|
141
|
-
fullname = extract_fullname(thing)
|
|
142
|
-
post "/api/unsave", id: fullname
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
# Upvote the thing.
|
|
146
|
-
#
|
|
147
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment,
|
|
148
|
-
# String] A link or comment to upvote.
|
|
149
|
-
# @see #vote
|
|
150
|
-
def upvote(thing)
|
|
151
|
-
vote(thing, 1)
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
# Downvote the thing.
|
|
155
|
-
#
|
|
156
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment,
|
|
157
|
-
# String] A link or comment to downvote.
|
|
158
|
-
# @see #vote
|
|
159
|
-
def downvote(thing)
|
|
160
|
-
vote(thing, -1)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
# Clear the user's vote on the thing.
|
|
164
|
-
#
|
|
165
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment,
|
|
166
|
-
# String] A link or comment to remove the vote on.
|
|
167
|
-
# @see #vote
|
|
168
|
-
def unvote(thing)
|
|
169
|
-
vote(thing, 0)
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
alias_method :clear_vote, :unvote
|
|
173
|
-
|
|
174
|
-
private
|
|
175
|
-
|
|
176
|
-
# Set a vote on the thing.
|
|
177
|
-
#
|
|
178
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment,
|
|
179
|
-
# String] A link or comment to set a vote on.
|
|
180
|
-
# @note Votes must be cast by humans only! Your script can proxy a
|
|
181
|
-
# user's actions, but it cannot decide what to vote.
|
|
182
|
-
def vote(thing, direction)
|
|
183
|
-
fullname = extract_fullname(thing)
|
|
184
|
-
post "/api/vote", id: fullname, dir: direction
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Redd
|
|
2
|
-
module Client
|
|
3
|
-
class Authenticated
|
|
4
|
-
# Methods to interact with /r/live threads
|
|
5
|
-
module Live
|
|
6
|
-
# Low-priority
|
|
7
|
-
#
|
|
8
|
-
# When was this a thing? Let's just hope this doesn't become popular
|
|
9
|
-
# that quickly before I get to it.
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
module Redd
|
|
2
|
-
module Client
|
|
3
|
-
class Authenticated
|
|
4
|
-
# Methods for moderating subreddits
|
|
5
|
-
module Moderation
|
|
6
|
-
# Approve a submission.
|
|
7
|
-
# @param thing [Redd::Object::Submission] The link to approve.
|
|
8
|
-
def approve(thing)
|
|
9
|
-
fullname = extract_fullname(thing)
|
|
10
|
-
post "/api/approve", id: fullname
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Remove a submission.
|
|
14
|
-
# @param thing [Redd::Object::Submission] The link to remove.
|
|
15
|
-
def remove(thing)
|
|
16
|
-
fullname = extract_fullname(thing)
|
|
17
|
-
post "/api/remove", id: fullname
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Distinguish a link or comment with a sigil to show that it has
|
|
21
|
-
# been created by a moderator.
|
|
22
|
-
#
|
|
23
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment]
|
|
24
|
-
# The link or comment to distinguish.
|
|
25
|
-
# @param how [:yes, :no, :admin, :special] How to distinguish the
|
|
26
|
-
# thing.
|
|
27
|
-
def distinguish(thing, how = :yes)
|
|
28
|
-
fullname = extract_fullname(thing)
|
|
29
|
-
post "/api/distinguish", api_type: "json", id: fullname, how: how
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Remove the sigil that shows a thing was created by a moderator.
|
|
33
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment]
|
|
34
|
-
# The link or comment to undistinguish.
|
|
35
|
-
def undistinguish(thing)
|
|
36
|
-
distinguish(thing, :no)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# Accept a moderator invite from a subreddit.
|
|
40
|
-
# @param subreddit [Redd::Object::Subreddit] The subreddit to accept
|
|
41
|
-
# the invitation from.
|
|
42
|
-
def accept_moderator_invite(subreddit)
|
|
43
|
-
name = extract_attribute(subreddit, :display_name)
|
|
44
|
-
post "/r/#{name}/api/accept_moderator_invite", api_type: "json"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Stop being a contributor of the subreddit.
|
|
48
|
-
# @param subreddit [Redd::Object::Subreddit] The subreddit to stop
|
|
49
|
-
# being a contributor of.
|
|
50
|
-
def leave_contributor_status(subreddit)
|
|
51
|
-
fullname = extract_fullname(subreddit)
|
|
52
|
-
post "/api/leavecontributor", id: fullname
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Stop being a moderator of the subreddit.
|
|
56
|
-
# @param subreddit [Redd::Object::Subreddit] The subreddit to stop
|
|
57
|
-
# being a moderator of.
|
|
58
|
-
def leave_moderator_status(subreddit)
|
|
59
|
-
fullname = extract_fullname(subreddit)
|
|
60
|
-
post "/api/leavemoderator", id: fullname
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
# Stop getting any moderator-related reports on the thing.
|
|
64
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment]
|
|
65
|
-
# The thing to stop getting reports on.
|
|
66
|
-
def ignore_reports(thing)
|
|
67
|
-
fullname = extract_fullname(thing)
|
|
68
|
-
post "/api/ignore_reports", id: fullname
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
# Start getting moderator-related reports on the thing again.
|
|
72
|
-
# @param thing [Redd::Object::Submission, Redd::Object::Comment]
|
|
73
|
-
# The thing to start getting reports on.
|
|
74
|
-
def unignore_reports(thing)
|
|
75
|
-
fullname = extract_fullname(thing)
|
|
76
|
-
post "/api/unignore_reports", id: fullname
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# @!method get_reports
|
|
80
|
-
# @!method get_spam
|
|
81
|
-
# @!method get_modqueue
|
|
82
|
-
# @!method get_unmoderated
|
|
83
|
-
#
|
|
84
|
-
# Get the appropriate listing.
|
|
85
|
-
# @param subreddit [Redd::Object::Subreddit] The subreddit to query.
|
|
86
|
-
# @param params [Hash] A list of params to send with the request.
|
|
87
|
-
#
|
|
88
|
-
# @see #get_submissions
|
|
89
|
-
%w(reports spam modqueue unmoderated).each do |sort|
|
|
90
|
-
define_method :"get_#{sort}" do |subreddit = nil, params = {}|
|
|
91
|
-
get_submissions(sort, subreddit, params)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
private
|
|
96
|
-
|
|
97
|
-
# Get a listing to moderator-related subreddits.
|
|
98
|
-
#
|
|
99
|
-
# @param type [:reports, :spam, :modqueue, :unmoderated] How the
|
|
100
|
-
# results are sorted.
|
|
101
|
-
# @param subreddit [Redd::Object::Subreddit, String] The subreddit to
|
|
102
|
-
# query.
|
|
103
|
-
# @param params [Hash] A list of params to send with the request.
|
|
104
|
-
# @option params [String] :after Return results after the given
|
|
105
|
-
# fullname.
|
|
106
|
-
# @option params [String] :before Return results before the given
|
|
107
|
-
# fullname.
|
|
108
|
-
# @option params [Integer] :count (0) The number of items already seen
|
|
109
|
-
# in the listing.
|
|
110
|
-
# @option params [1..100] :limit (25) The maximum number of things to
|
|
111
|
-
# return.
|
|
112
|
-
# @option params :location No idea what this does.
|
|
113
|
-
# @option params [:links, :comments] :only The type of things to show.
|
|
114
|
-
# @return [Redd::Object::Listing] A listing of submissions or comments.
|
|
115
|
-
#
|
|
116
|
-
def get_submissions(type, subreddit = nil, params = {})
|
|
117
|
-
subreddit_name = extract_attribute(subreddit, :display_name)
|
|
118
|
-
path = "/about/#{type}.json"
|
|
119
|
-
path = path.prepend("/r/#{subreddit_name}") if subreddit_name
|
|
120
|
-
|
|
121
|
-
object_from_response :get, path, params
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|