Module: RedditKit::Client::Moderation
- Included in:
- RedditKit::Client
- Defined in:
- lib/redditkit/client/moderation.rb
Overview
Methods for moderating subreddits.
Instance Method Summary collapse
-
#accept_moderator_invitation(subreddit) ⇒ Object
Accepts an invitation to become a moderator of a subreddit.
-
#approve(link) ⇒ Object
Approves an unmoderated link.
-
#ban(user, subreddit) ⇒ Object
Ban a user.
-
#contributors_to_subreddit(subreddit) ⇒ Array<OpenStruct>
Get the contributors to a subreddit.
-
#distinguish(comment, how = 'yes') ⇒ Object
Distinguishes a comment as being posted by a moderator or admin.
-
#ignore_reports(object) ⇒ Object
Ignores the reports on a link or comment.
-
#moderation_log(subreddit) ⇒ RedditKit::PaginatedResponse
Gets the moderation log for a subreddit.
-
#moderators_of_subreddit(subreddit) ⇒ Array<OpenStruct>
Get the moderators of a subreddit.
-
#remove(object) ⇒ Object
Removes a link or comment.
-
#reset_subreddit_header(subreddit) ⇒ Object
Resets a subreddit’s header image.
-
#resign_as_contributor(subreddit) ⇒ Object
Resign as a contributor to a subreddit.
-
#resign_as_moderator(subreddit) ⇒ Object
Resign as a moderator of a subreddit.
-
#set_contest_mode(link, contest_mode = true) ⇒ Object
Sets a post as have its contest mode enabled or disabled.
-
#set_sticky_post(link, sticky = true) ⇒ Object
Sets a post as sticky within its parent subreddit.
-
#unban(user, subreddit) ⇒ Object
Lift the ban on a user.
-
#unignore_reports(object) ⇒ Object
Unignores the reports on a link or comment.
Instance Method Details
#accept_moderator_invitation(subreddit) ⇒ Object
Accepts an invitation to become a moderator of a subreddit.
111 112 113 114 |
# File 'lib/redditkit/client/moderation.rb', line 111 def accept_moderator_invitation(subreddit) subreddit_name = extract_string(subreddit, :display_name) post('api/accept_moderator_invite', { :r => subreddit_name }) end |
#approve(link) ⇒ Object
Approves an unmoderated link.
29 30 31 32 |
# File 'lib/redditkit/client/moderation.rb', line 29 def approve(link) full_name = extract_full_name link post('api/approve', { :id => full_name, :api_type => :json }) end |
#ban(user, subreddit) ⇒ Object
If a subreddit’s name is passed as the :subreddit option, a second HTTP request will be made to get the RedditKit::Subreddit object.
Ban a user. This requires moderator privileges on the specified subreddit.
14 15 16 |
# File 'lib/redditkit/client/moderation.rb', line 14 def ban(user, subreddit) ban_or_unban_user true, user, subreddit end |
#contributors_to_subreddit(subreddit) ⇒ Array<OpenStruct>
Get the contributors to a subreddit.
104 105 106 |
# File 'lib/redditkit/client/moderation.rb', line 104 def contributors_to_subreddit(subreddit) members_in_subreddit subreddit, 'contributors' end |
#distinguish(comment, how = 'yes') ⇒ Object
admin and special values may only be used if the current user has the right privileges.
Distinguishes a comment as being posted by a moderator or admin.
63 64 65 66 67 68 |
# File 'lib/redditkit/client/moderation.rb', line 63 def distinguish(comment, how = 'yes') full_name = extract_full_name comment parameters = { :id => full_name, :api_type => :json } post("api/distinguish/#{how}", parameters) end |
#ignore_reports(object) ⇒ Object
Ignores the reports on a link or comment.
45 46 47 48 |
# File 'lib/redditkit/client/moderation.rb', line 45 def ignore_reports(object) full_name = extract_full_name object post('api/ignore_reports', { :id => full_name, :api_type => :json }) end |
#moderation_log(subreddit) ⇒ RedditKit::PaginatedResponse
Gets the moderation log for a subreddit.
144 145 146 147 |
# File 'lib/redditkit/client/moderation.rb', line 144 def moderation_log(subreddit) display_name = extract_string subreddit, :display_name objects_from_response(:get, "r/#{display_name}/about/log.json", nil) end |
#moderators_of_subreddit(subreddit) ⇒ Array<OpenStruct>
Get the moderators of a subreddit.
96 97 98 |
# File 'lib/redditkit/client/moderation.rb', line 96 def moderators_of_subreddit(subreddit) members_in_subreddit subreddit, 'moderators' end |
#remove(object) ⇒ Object
Removes a link or comment.
37 38 39 40 |
# File 'lib/redditkit/client/moderation.rb', line 37 def remove(object) full_name = extract_full_name object post('api/remove', { :id => full_name, :api_type => :json }) end |
#reset_subreddit_header(subreddit) ⇒ Object
Resets a subreddit’s header image.
135 136 137 138 |
# File 'lib/redditkit/client/moderation.rb', line 135 def reset_subreddit_header(subreddit) subreddit_name = extract_string(subreddit, :display_name) post('api/delete_sr_header', { :r => subreddit_name }) end |
#resign_as_contributor(subreddit) ⇒ Object
Resign as a contributor to a subreddit.
119 120 121 122 |
# File 'lib/redditkit/client/moderation.rb', line 119 def resign_as_contributor(subreddit) full_name = extract_full_name subreddit post('api/leavecontributor', { :id => full_name }) end |
#resign_as_moderator(subreddit) ⇒ Object
Resign as a moderator of a subreddit.
127 128 129 130 |
# File 'lib/redditkit/client/moderation.rb', line 127 def resign_as_moderator(subreddit) full_name = extract_full_name subreddit post('api/leavemoderator', { :id => full_name }) end |
#set_contest_mode(link, contest_mode = true) ⇒ Object
Sets a post as have its contest mode enabled or disabled.
74 75 76 77 78 79 |
# File 'lib/redditkit/client/moderation.rb', line 74 def set_contest_mode(link, contest_mode = true) full_name = extract_full_name link set_as_contest = contest_mode ? 'True' : 'False' post('api/set_contest_mode', { :id => full_name, :state => set_as_contest, :api_type => :json }) end |
#set_sticky_post(link, sticky = true) ⇒ Object
Sets a post as sticky within its parent subreddit. This will replace the existing sticky post, if there is one.
85 86 87 88 89 90 |
# File 'lib/redditkit/client/moderation.rb', line 85 def set_sticky_post(link, sticky = true) full_name = extract_full_name link set_as_sticky = sticky ? 'True' : 'False' post('api/set_subreddit_sticky', { :id => full_name, :state => set_as_sticky, :api_type => :json }) end |
#unban(user, subreddit) ⇒ Object
Lift the ban on a user. This requires moderator privileges on the specified subreddit.
22 23 24 |
# File 'lib/redditkit/client/moderation.rb', line 22 def unban(user, subreddit) ban_or_unban_user false, user, subreddit end |
#unignore_reports(object) ⇒ Object
Unignores the reports on a link or comment.
53 54 55 56 |
# File 'lib/redditkit/client/moderation.rb', line 53 def unignore_reports(object) full_name = extract_full_name object post('api/unignore_reports', { :id => full_name, :api_type => :json }) end |