snoo 0.0.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.
@@ -0,0 +1,151 @@
1
+ module Snoo
2
+ # Methods for interacting with links and comments, such as leaving a comment, voting, etc
3
+ #
4
+ # @author (see Snoo)
5
+ module LinksComments
6
+
7
+ # Posts a comment to the site
8
+ #
9
+ # @param text [String] The comment text, formatted as markdown
10
+ # @param id [String] The parent object id. Should be a comment or link
11
+ # @return (see #clear_sessions)
12
+ def comment text, id
13
+ logged_in?
14
+ post('/api/comment', body: { text: text, thing_id: id, uh: @modhash})
15
+ end
16
+
17
+ # Deletes a thing from the site
18
+ #
19
+ # @param id [String] The thing to target.
20
+ # @return (see #clear_sessions)
21
+ def delete id
22
+ logged_in?
23
+ post('/api/del', body: { id: id, uh: @modhash })
24
+ end
25
+
26
+ # Edits a thing.
27
+ # Can be a self post body, or a comment
28
+ #
29
+ # @param (see #comment)
30
+ # @return (see #clear_sessions)
31
+ def edit text, id
32
+ logged_in?
33
+ post('/api/editusertext', body: {text: text, thing_id: id, uh: @modhash})
34
+ end
35
+
36
+ # Hides a thing
37
+ #
38
+ # @param (see #delete)
39
+ # @return (see #clear_sessions)
40
+ def hide id
41
+ logged_in?
42
+ post('/api/hide', body: {id: id, uh: @modhash})
43
+ end
44
+
45
+ # Get a listing of things which have the provided URL.
46
+ # You can use a plain url, or a reddit link id to get reposts of said link
47
+ # @note Using {Listings#search} is probably better for url lookups
48
+ #
49
+ # @param opts [Hash] An options hash
50
+ # @option opts [String] :id The id of a reddit thing to look up. Specify either this or a url, not both
51
+ # @option opts [String] :url The url to search for matching things. Specify either this or an id, not both
52
+ # @option opts [Fixnum] :limit The number of things to return. Go too high and the API will ignore you
53
+ # @return (see #clear_sessions)
54
+ def info opts = {}
55
+ raise ArgumentError, 'url or id, not both' if opts[:id] && opts[:url]
56
+ query = { limit: 100 }
57
+ query.merge! opts
58
+ get('/api/info.json', query: query)
59
+ end
60
+
61
+ # Marks a post NSFW. Currently, this only works on links
62
+ #
63
+ # @param (see #delete)
64
+ # @return (see #clear_sessions)
65
+ def mark_nsfw id
66
+ logged_in?
67
+ post('/api/marknsfw', body: {id: id, uh: @modhash})
68
+ end
69
+
70
+ # Reports a comment or link
71
+ #
72
+ # @param (see #delete)
73
+ # @reutrn (see #comment)
74
+ def report id
75
+ logged_in?
76
+ post('/api/report', body: {id: id, uh: @modhash})
77
+ end
78
+
79
+ # Saves a link
80
+ #
81
+ # @param (see #delete)
82
+ # @return (see #clear_sessions)
83
+ def save id
84
+ logged_in?
85
+ post('/api/save', body: { id: id, uh: @modhash})
86
+ end
87
+
88
+ # Submit a link or self post
89
+ #
90
+ # @param title [String] Title of the post
91
+ # @param subreddit [String] The subreddit in which we are posting
92
+ # @param (see #info)
93
+ # @option opts [String] :url The url for the post. If this is specified, it will not be a self post, and `text` will be ignored
94
+ # @option opts [String] :text The self-post text. Can be formatted in markdown
95
+ # @return (see #clear_sessions)
96
+ def submit title, subreddit, opts = {}
97
+ logged_in?
98
+ raise ArgumentError, 'url or text, not both' if opts[:url] && opts[:text]
99
+ post = {
100
+ title: title,
101
+ sr: subreddit,
102
+ uh: @modhash,
103
+ kind: (opts[:url] ? "link" : "self")
104
+ }
105
+ post.merge! opts
106
+ post('/api/submit', body: post)
107
+ end
108
+
109
+ # Unhide a thing
110
+ #
111
+ # @param (see #delete)
112
+ # @return (see #clear_sessions)
113
+ def unhide id
114
+ logged_in?
115
+ post('/api/unhide', body: {id: id, uh: @modhash})
116
+ end
117
+
118
+ # Un-mark NSFW a thing.
119
+ #
120
+ # @param (see #delete)
121
+ # @return (see #clear_sessions)
122
+ def unmark_nsfw id
123
+ logged_in?
124
+ post('/api/unmarknsfw', body: {id: id, uh: @modhash})
125
+ end
126
+
127
+ # Vote on a comment or link
128
+ #
129
+ # @param direction [-1, 0, 1] The direction to vote in. -1 is a downvote, 1 is an upvote, 0 cancels any vote
130
+ # @param id [String] The thing to target.
131
+ # @return (see #clear_sessions)
132
+ def vote direction, id
133
+ logged_in?
134
+ raise ArgumentError, "direction needs to be one of -1, 0, or 1 (was #{direction}" unless (-1..1).include?(direction)
135
+ post('/api/vote', body: {id: id, dir: direction, uh: @modhash})
136
+ end
137
+
138
+ # Upvote
139
+ # An alias for `vote 1, id`
140
+ #
141
+
142
+ # Downvote
143
+ # An alias for `vote -1, id`
144
+ #
145
+
146
+ # Sidevote (clear your vote)
147
+ # An alias for `vote 0, id`
148
+ #
149
+
150
+ end
151
+ end
@@ -0,0 +1,89 @@
1
+ module Snoo
2
+ # Methods for getting thing listings. Comments, links, etc
3
+ #
4
+ # @author (see Snoo)
5
+ module Listings
6
+
7
+ # Get a comment listing from the site
8
+ #
9
+ # @param link_id [String] The link id of the comment thread. Must always be present
10
+ # @param (see LinksComments#info)
11
+ # @option opts [String] :comment_id The parent comment of a thread.
12
+ # @option opts [Fixnum] :context The context of the thread, that is, how far above the `comment_id` to return
13
+ # @option opts [Fixnum] :limit (100) The total number of comments to return. If you have gold this can include the whole thread, but is buggy. Recommend no more than 1000
14
+ # @option opts [Fixnum] :depth How deep to render a comment thread.
15
+ # @option opts [old, new, hot, top, controversial, best] :sort The sort used.
16
+ # @return (see #clear_sessions)
17
+ def get_comments link_id, opts = {}
18
+ sorts = %w{old new hot top controversial best}
19
+ raise ArgumentError, "sort cannot be #{sort}" unless sorts.include?(opts[:sort]) or opts[:sort].nil?
20
+ query = { limit: 100 }
21
+ query.merge! opts
22
+ url = "/comments/%s%s.json" % [link_id, ('/' + opts[:comment_id] if opts[:comment_id])]
23
+ get(url, query: query)
24
+ end
25
+
26
+ # Gets a listing of links from reddit.
27
+ #
28
+ # @param (see LinksComments#info)
29
+ # @option opts [String] :subreddit The subreddit targeted. Can be psuedo-subreddits like `all` or `mod`. If blank, the front page
30
+ # @option opts [new, controversial, top] :page The page to view.
31
+ # @option opts [new, rising] :sort The sorting method. Only relevant on the `new` page
32
+ # @option opts [hour, day, week, month, year] :t The timeframe. Only relevant on some pages, such as `top`. Leave empty for all time
33
+ # @option opts [1..100] :limit The number of things to return.
34
+ # @option opts [String] :after Get things *after* this thing id
35
+ # @option opts [String] :before Get things *before* this thing id
36
+ # @return (see #clear_sessions)
37
+ def get_listing opts = {}
38
+ pages = %w{new controversial top}
39
+ sorts = %w{new rising}
40
+ times = %w{hour day week month year}
41
+ # Invalid Page
42
+ raise ArgumentError, "page must be #{pages * ', '}, is #{opts[:page]}" unless pages.include?(opts[:page]) or opts[:page].nil?
43
+ # Invalid Sort
44
+ raise ArgumentError, "sort must be one of #{sorts * ', '}, is #{opts[:sort]}" unless sorts.include?(opts[:sort]) or opts[:sort].nil?
45
+ # Sort on useless page
46
+ raise ArgumentError, "sort can only be used on page = 'new'" if opts[:page] != 'new' && opts[:sort]
47
+ # Invalid time
48
+ raise ArgumentError, "time can only be one of #{times * ', '}, is #{opts[:time]}" unless times.include?(opts[:time]) or opts[:time].nil?
49
+ # Invalid limit
50
+ raise ArgumentError, "limit cannot be outside 1..100, is #{opts[:limit]}" unless (1..100).include?(opts[:limit]) or opts[:limit].nil?
51
+
52
+ # Build the basic url
53
+ url = "%s/%s.json" % [('/r/' + opts[:subreddit] if opts[:subreddit] ), (opts[:page] if opts[:page])]
54
+ # Delete subreddit and page from the hash, they dont belong in the query
55
+ [:subreddit, :page].each {|k| opts.delete k}
56
+ query = opts
57
+ # Make the request
58
+ get(url, query: query)
59
+ end
60
+
61
+ # Search reddit
62
+ #
63
+ # @param query [String] The search query.
64
+ # @param (see LinksComments#info)
65
+ # @option opts [true, false] :restrict_sr Restrict to the calling subreddit
66
+ # @option opts [String] :subreddit The calling subreddit.
67
+ # @option opts [1..100] :limit The amount of results to return
68
+ # @option opts [String] :before Return things *before* this id
69
+ # @option opts [String] :after Return things *after* this id
70
+ # @option opts [relevance, new, top] :sort The sorting of the results.
71
+ # @option opts [cloudsearch, lucene] :syntax The search syntax.
72
+ # @return (see #clear_sessions)
73
+ def search query, opts = {}
74
+ raise ArgumentError, 'restrict_subreddit needs to be boolean' unless [true, false].include?(opts[:restrict_sr]) or opts[:restrict_sr].nil?
75
+ raise ArgumentError, "limit needs to be 1..100, is #{opts[:limit]}" unless (1..100).include?(opts[:limit]) or opts[:limit].nil?
76
+ raise ArgumentError, "sort needs to be one of relevance, new, top, is #{opts[:sort]}" unless %w{relevance new top}.include?(opts[:sort]) or opts[:sort].nil?
77
+ raise ArgumentError, "syntax needs to be one of cloudsearch, lucene; is #{opts[:syntax]}" if %w{cloudsearch lucene}.include?(opts[:syntax])
78
+
79
+ # This supports searches with and without a subreddit
80
+ url = "%s/search.json" % (opts[:subreddit] if opts[:subreddit])
81
+
82
+ # Construct the query
83
+ httpquery = {q: query}
84
+ httpquery.merge! opts
85
+
86
+ get(url, query: httpquery)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,61 @@
1
+ module Snoo
2
+ # Methods for moderating on reddit, including tasks such as removing, approving, and distinguishing
3
+ #
4
+ # @author (see Snoo)
5
+ module Moderation
6
+
7
+ # Approve a thing
8
+ #
9
+ # @param id [String] Thing targeted
10
+ # @return (see #clear_sessions)
11
+ def approve id
12
+ logged_in?
13
+ post('/api/approve', body: {id: id, uh: @modhash})
14
+ end
15
+
16
+ # Distinguish a thing
17
+ #
18
+ # @param (see #approve)
19
+ # @param how [yes, no, admin, special] Determines how to distinguish something. Only works for the permissions you have.
20
+ # @return (see #clear_sessions)
21
+ def distinguish id, how
22
+ logged_in?
23
+ hows = %w{yes no admin special}
24
+ raise ArgumentError, "how should be one of #{hows * ', '}, is #{how}" if hows.include?(how)
25
+ post('/api/distinguish', body: {id: id, how: how, uh: @modhash})
26
+ end
27
+
28
+ # Removes you from a subreddits list of contributors
29
+ # @note (see #clear_sessions)
30
+ #
31
+ # @param id [String] The subreddit id
32
+ # @return (see #clear_sessions)
33
+ def leave_contributor id
34
+ logged_in?
35
+ post('/api/leavecontributor', body: {id: id, uh: @modhash})
36
+ end
37
+
38
+ # Removes you from a subreddits moderators
39
+ # @note (see #clear_sessions)
40
+ #
41
+ # @param (see #leave_contributor)
42
+ # @return (see #clear_sessions)
43
+ def leave_moderator id
44
+ logged_in?
45
+ post('/api/leavemoderator', body: {id: id, uh: @modhash})
46
+ end
47
+
48
+ # Removes a thing
49
+ #
50
+ # @param (see #approve)
51
+ # @param spam [true, false] Mark this removal as a spam removal (and train the spamfilter)
52
+ # @return (see #clear_sessions)
53
+ def remove id, spam
54
+ logged_in?
55
+ spams = [true, false]
56
+ raise ArgumentError, "spam should be boolean, is #{spam}" unless spams.include?(spam)
57
+ post('/api/remove', body: {id: id, spam: spam, uh: @modhash})
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,69 @@
1
+ module Snoo
2
+ # Methods for interacting with private messages
3
+ #
4
+ # @author (see Snoo)
5
+ module PM
6
+
7
+ # Block a user from sending you messages
8
+ #
9
+ # @param id [String] the user id.
10
+ # @return (see #clear_sessions)
11
+ def block_pm id
12
+ logged_in?
13
+ post('/api/block', body: {id: id, uh: @modhash})
14
+ end
15
+
16
+ # Send a private message
17
+ # To reply to PM, use {LinksComments#comment}, with the PM id as the link id
18
+ #
19
+ # @param to [String] The username you are sending to
20
+ # @param subject [String] The subject of the message
21
+ # @param text [String] The message body
22
+ # @return (see #clear_sessions)
23
+ def send_pm to, subject, text
24
+ logged_in?
25
+ post('/api/compose.json', body: {to: to, subject: subject, text: text, uh: @modhash})
26
+ end
27
+
28
+ # Mark a PM as read
29
+ #
30
+ # @param id [String] The message id
31
+ # @return (see #clear_sessions)
32
+ def mark_read id
33
+ logged_in?
34
+ post('/api/read_message', body: {id: id, uh: @modhash})
35
+ end
36
+
37
+ # Mark a PM as unread
38
+ #
39
+ # @param (see #mark_read)
40
+ # @return (see #clear_sessions)
41
+ def mark_unread id
42
+ logged_in?
43
+ post('/api/unread_message', body: {id: id, uh: @modhash})
44
+ end
45
+
46
+ # Gets a listing of PMs
47
+ #
48
+ # @param where [inbox, unread, sent] Where to get messages from
49
+ # @param (see LinksComments#info)
50
+ # @option opts [true, false] :mark (false) Mark the messages requested as read?
51
+ # @option opts [1..100] :limit The total number of messages to get
52
+ # @option opts [String] :before Get all comments *before* this id
53
+ # @option opts [String] :after Get all comments *after* this
54
+ # @return (see #clear_sessions)
55
+ def get_messages where = "inbox", opts = {},
56
+ bools = [true, false]
57
+ wheres = %w{inbox unread sent}
58
+ raise ArgumentError, "where must be #{wheres * ', '}, is #{where}" unless wheres.include?(where)
59
+ raise ArgumentError, "mark must be boolean, is #{opts[:mark]}" unless bools.include?(opts[:mark]) or opts[:mark].nil?
60
+ raise ArgumentError, "limit must be 1..100, is #{opts[:limit]}" unless (1..100).include?(opts[:limit]) or opts[:limit].nil?
61
+
62
+ query = {
63
+ mark: false
64
+ }
65
+ query.merge! opts
66
+ get("/message/#{where}.json", query: query)
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,242 @@
1
+ module Snoo
2
+ # Methods for administering a subreddit, as well as looking up subreddits (subreddit search)
3
+ #
4
+ # @author (see Snoo)
5
+ module Subreddit
6
+
7
+ # Deletes the header image of a subreddit
8
+ #
9
+ # @param subreddit [String] The subreddit targeted
10
+ # @return (see #clear_sessions)
11
+ def delete_header subreddit
12
+ logged_in?
13
+ post('/api/delete_sr_header', body: {r: subreddit, uh: @modhash})
14
+ end
15
+
16
+ # Deletes an image from a subreddit. This is for css, not removing posts
17
+ #
18
+ # @param (see #delete_header)
19
+ # @param image_name [String] the image to delete from the subreddit. Can be obtained via {#get_stylesheet}
20
+ # @return (see #clear_sessions)
21
+ def delete_image subreddit, image_name
22
+ logged_in?
23
+ post('/api/delete_sr_image', body: {r: subreddit, img_name: image_name, uh: @modhash})
24
+ end
25
+
26
+ # @todo test if every param is actually required
27
+ # Sets subreddit settings.
28
+ #
29
+ # @param (see #delete_header)
30
+ # @param (see LinksComments#info)
31
+ # @option opts [String] :title The subreddit's title
32
+ # @option opts [String] :public_description The subreddit's public description
33
+ # @option opts [String] :description The subreddit's sidebar
34
+ # @option opts [String] :lang (en) The default language. ISO language code
35
+ # @option opts [public, private, restricted] :type (public) The subreddits type
36
+ # @option opts [any, link, self] :link_type (any) The type of posts allowed on this subreddit
37
+ # @option opts [true, false] :allow_top (true) Allow this subreddit to appear on the front page
38
+ # @option opts [true, false] :show_media (true) show thumbnails and media embeds
39
+ # @option opts [String] :header-title The header mouse-over text
40
+ # @option opts [true, false] :over_18 (false) If the subreddit requires over 18 access
41
+ # @return (see #clear_sessions)
42
+ def subreddit_settings subreddit, opts = {}
43
+ logged_in?
44
+ bool = [true, false]
45
+ raise ArgumentError, "type must be one of public, private, restricted, is #{opts[:type]}" unless %w{public private restricted}.include?(opts[:type]) or opts[:type].nil?
46
+ raise ArgumentError, "post_type must be one of any, link, self; is #{opts[:link_type]}" unless %w{any link self}.include?(opts[:link_type]) or opts[:link_type].nil?
47
+ raise ArgumentError, "allow_frontpage must be boolean" unless bool.include?(opts[:allow_top]) or opts[:allow_top].nil?
48
+ raise ArgumentError, "show_media must be boolean" unless bool.include?(opts[:show_media]) or opts[:show_media].nil?
49
+ raise ArgumentError, "adult must be boolean" unless bool.include?(opts[:over_18]) or opts[:over_18].nil?
50
+ params = {
51
+ type: 'public',
52
+ link_type: 'any',
53
+ lang: 'en',
54
+ r: subreddit,
55
+ uh: @modhash,
56
+ allow_top: true,
57
+ show_media: true,
58
+ over_18: false,
59
+ }
60
+ params.merge! opts
61
+ post('/api/site_admin', body: params)
62
+ end
63
+
64
+ # Set the subreddit stylesheet
65
+ #
66
+ # @param stylesheet [String] The stylesheet for the subreddit. Overwrites the current one
67
+ # @param (see #delete_header)
68
+ # @return (see #clear_sessions)
69
+ def set_stylesheet stylesheet, subreddit
70
+ logged_in?
71
+ post('/api/subreddit_stylesheet', body: {op: "save", stylesheet_contents: stylesheet, uh: @modhash})
72
+ end
73
+
74
+ # Subscribe to a subreddit
75
+ #
76
+ # @param (see #delete_header)
77
+ # @param action [sub, unsub] Subscribe or unsubscribe
78
+ # @return (see #clear_sessions)
79
+ def subscribe subreddit, action = "sub"
80
+ logged_in?
81
+ raise ArgumentError, "action must be one of sub, unsub; is #{action}" unless %w{sub unsub}.include?(action)
82
+ post('/api/subscribe', body: {action: action, sr: subreddit, uh: @modhash})
83
+ end
84
+
85
+ # Unsubscribe from a subreddit
86
+ # This is an alias for `subscribe "unsub"`
87
+ #
88
+ # @param (see #delete_header)
89
+ # @return (see #clear_sessions)
90
+ def unsubscribe subreddit
91
+ subscribe("unsub", subreddit)
92
+ end
93
+
94
+
95
+ # Get subreddit info
96
+ #
97
+ # @param (see #delete_header)
98
+ # @return (see #clear_sessions)
99
+ def subreddit_info subreddit
100
+ get("/r/#{subreddit}/about.json")
101
+ end
102
+
103
+ # Get subreddit stylesheet and images
104
+ #
105
+ # @param (see #delete_header)
106
+ # @return (see #clear_sessions)
107
+ def get_stylesheet subreddit
108
+ logged_in?
109
+ get("/r/#{subreddit}/about/stylesheet.json")
110
+ end
111
+
112
+ # Get subreddits I have
113
+ #
114
+ # @param (see LinksComments#info)
115
+ # @option opts [subscriber, contributor, moderator] :condition The permission level to return subreddits from
116
+ # @option opts [1..100] :limit The number of results to return
117
+ # @option opts [String] :after Return subreddits *after* this id
118
+ # @option opts [String] :before Return subreddits *before* this id
119
+ # @return (see #clear_sessions)
120
+ def my_reddits opts = {}
121
+ logged_in?
122
+ raise ArgumentError, "condition must be one of subscriber, contributor, moderator; is #{opts[:condition]}" unless %w{subscriber contributor moderator}.include?(opts[:condition]) or opts[:condition].nil?
123
+ raise ArgumentError, "limit must be within 1..100; is #{opts[:limit]}" unless (1..100).include?(opts[:limit]) or opts[:limit].nil?
124
+ url = "/reddits/mine/%s.json" % (opts[:condition] if opts[:condition])
125
+ opts.delete! :condition
126
+ query = ops
127
+ get(url, query: query)
128
+ end
129
+
130
+ # Get a list of subreddits
131
+ #
132
+ # @param (see LinksComments#info)
133
+ # @option opts [popular, new, banned] :condition The type of subreddits to return
134
+ # @option opts [1..100] :limit The number of results to return
135
+ # @option opts [String] :after Return subreddits *after* this id.
136
+ # @option opts [String] :before Return subreddits *before* this id.
137
+ # @return (see #clear_sessions)
138
+ def get_reddits opts = {}
139
+ raise ArgumentError, "condition must be one of popular, new, banned; is #{opts[:condition]}" unless %w{popular new banned}.include?(opts[:condition]) or opts[:condition].nil?
140
+ raise ArgumentError, "limit must be within 1..100; is #{opts[:limit]}" unless (1..100).include?(opts[:limit]) or opts[:limit].nil?
141
+
142
+ url = "/reddits/%s.json" % (opts[:condition] if opts[:condition])
143
+ opts.delete! :condition
144
+ query = opts
145
+
146
+ get(url, query: query)
147
+ end
148
+
149
+ # Search subreddits
150
+ #
151
+ # @param q [String] The search query
152
+ # @param (see LinksComments#info)
153
+ # @option opts [1..100] :limit The number of results to return
154
+ # @option opts [String] :after Return subreddits *after* this id.
155
+ # @option opts [String] :before Return subreddits *before* this id.
156
+ # @return (see #clear_sessions)
157
+ def search_reddits q, opts = {}
158
+ raise ArgumentError, "limit must be within 1..100; is #{opts[:limit]}" unless (1..100).include?(opts[:limit]) or opts[:limit].nil?
159
+
160
+ query = {q: q}
161
+ query.merge! opts
162
+ get('/reddits/search.json', query: query)
163
+ end
164
+
165
+ # Add a moderator to the subreddit
166
+ #
167
+ # @param container [String] The subreddit id. Must be a subreddit id (begins with t5_)
168
+ # @param user [String] The user
169
+ # @param (see #delete_header)
170
+ # @return (see #clear_sessions)
171
+ def add_moderator container, user, subreddit
172
+ friend_wrapper api_container = container, api_name = user, api_subreddit = subreddit, api_type = "moderator"
173
+ end
174
+
175
+ # Add a contributor to the subreddit
176
+ #
177
+ # @param (see #add_moderator)
178
+ # @return (see #clear_sessions)
179
+ def add_contributor container, user, subreddit
180
+ friend_wrapper api_container = container, api_name = user, api_subreddit = subreddit, api_type = "contributor"
181
+ end
182
+
183
+ # Ban a user from a subreddit
184
+ #
185
+ # @param (see #add_moderator)
186
+ # @return (see #clear_sessions)
187
+ def ban_user container, user, subreddit
188
+ friend_wrapper api_container = container, api_name = user, api_subreddit = subreddit, api_type ="banned"
189
+ end
190
+
191
+ # Remove a moderator from a subreddit
192
+ #
193
+ # @param id [String] The user id
194
+ # @param (see #add_moderator)
195
+ # @return (see #clear_sessions)
196
+ def remove_moderator id, container, user, subreddit
197
+ unfriend_wrapper api_id = id, api_container = container, api_name = user, api_subreddit = subreddit, api_type = "moderator"
198
+ end
199
+
200
+ # Remove a contributor from a subreddit
201
+ #
202
+ # @param (see #remove_moderator)
203
+ # @return (see #clear_sessions)
204
+ def remove_contributor id, container, user, subreddit
205
+ unfriend_wrapper api_id = id, api_container = container, api_name = user, api_subreddit = subreddit, api_type = "contributor"
206
+ end
207
+
208
+ # Unban a user from a subreddit
209
+ #
210
+ # @param (see #remove_moderator)
211
+ # @return (see #clear_sessions)
212
+ def unban_user id, container, user, subreddit
213
+ unfriend_wrapper api_id = id, api_container = container, api_name = user, api_subreddit = subreddit, api_type = "banned"
214
+ end
215
+
216
+ # List moderators of a subreddit
217
+ #
218
+ # @param (see #delete_header)
219
+ # @return (see #clear_sessions)
220
+ def get_moderators subreddit
221
+ get("/r/#{subreddit}/about/moderators.json")
222
+ end
223
+
224
+ # List contributors of a subreddit
225
+ #
226
+ # @param (see #delete_header)
227
+ # @param (see #clear_sessions)
228
+ def get_contributors subreddit
229
+ logged_in?
230
+ get("/r/#{subreddit}/about/contributors.json")
231
+ end
232
+
233
+ # List banned users of a subreddit
234
+ #
235
+ # @param (see #delete_header)
236
+ # @param (see #clear_sessions)
237
+ def get_banned_users subreddit
238
+ logged_in?
239
+ get("/r/#{subreddit}/about/banned.json")
240
+ end
241
+ end
242
+ end