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.
105 106 107 108 |
# File 'lib/redditkit/client/moderation.rb', line 105 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.
98 99 100 |
# File 'lib/redditkit/client/moderation.rb', line 98 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.
138 139 140 141 |
# File 'lib/redditkit/client/moderation.rb', line 138 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.
90 91 92 |
# File 'lib/redditkit/client/moderation.rb', line 90 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.
129 130 131 132 |
# File 'lib/redditkit/client/moderation.rb', line 129 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.
113 114 115 116 |
# File 'lib/redditkit/client/moderation.rb', line 113 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.
121 122 123 124 |
# File 'lib/redditkit/client/moderation.rb', line 121 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 |
# File 'lib/redditkit/client/moderation.rb', line 74 def set_contest_mode(link, contest_mode = true) set_boolean_on_link 'api/set_contest_mode', link, contest_mode 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.
82 83 84 |
# File 'lib/redditkit/client/moderation.rb', line 82 def set_sticky_post(link, sticky = true) set_boolean_on_link 'api/set_subreddit_sticky', link, sticky 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 |