A ruby wrapper for the repl talk gql api.
gem "repltalk"
require "repltalk"
client = ReplTalk::Client.new
Once you have your client initialized, you can start getting users, posts, comments etc.
A few small snippets of examples of what you can do with the repltalk gem
client.get_posts(order: "Top", count: 100).select { |post| post.author.username == "CodingCactus" }
client.get_posts(count: 10, languages: ['ruby']).map { |post| post.url }
client.get_repl("/@CodingCactus/classrooms").fork_count
mentions = 0
client.get_post(33995).get_comments(count: 999999999).each do |comment|
mentions += 1 if comment.content.include?("@CodingCactus")
comment.get_comments.each { |child_comment| mentions += 1 if child_comment.content.include?("@CodingCactus") }
sleep 0.25 # need to be careful with rate limits
end
lang_count = client.get_user("CodingCactus").get_repls(count: 999999).reduce(Hash.new(0)) do |langs, repl|
langs[repl.language.id] += 1
langs
end
#get_user username
Get a user from their username. ReturnsUser
#get_user_by_id id
Get a user from their id. ReturnsUser
#search_user query, :count
Search for users whose username start with the query. Returns array ofUser
s. Need to be logged in, unfortunately#get_post id
Get a post from it's id. ReturnsPost
#get_comment id
Get a comment from it's id. ReturnsComment
#get_repl url
Get a repl from it's url. ReturnsRepl
#get_repl_comment id
Get a repl comment from its id. ReturnsReplComment
#get_board name
Get a board from it's name. ReturnsBoard
#get_posts :board, :order, :count, :after, :search
Get posts from repltalk. Returns array ofPost
s#create_post board_name, title, content, :repl_id, :show_hosted
Create a repl talk post. ReturnsPost
#get_explore_featured_repls
Get the featured repls on explore. Returns array ofRepl
s#get_trending_tags :count
Get the tags which are trending on explore. Returns array ofTag
s#get_tag id
Get a tag. ReturnsTag
#id
User's id#username
User's username#name
User's full name#pfp
URL of the user's pfp#bio
User's bio#timestamp
When the account was made#is_hacker
Whether the user has the hacker plan#roles
User's roles. Returns an array ofRole
s#languages
Languages that the user has used. Returns array ofLanguage
s#get_posts :order, :count, :after
Get the user's posts. Returns array ofPost
s#get_comments :order, :count, :after
Get the user's comments. Returns array ofComment
sget_repls :count, :order, :direction, :before, :after, :pinnedReplsFirst, :showUnnamed
Get the user's repls. Returns array ofRepl
s
#id
Post's id#url
Post's url#repl
Repl attached to the post. Returns nil if there is none. Else returnsRepl
#board
Board that the post is from. ReturnsBoard
#title
Post's title#author
Post's author. ReturnsUser
#content
Post's content#preview
Preview of the post's content.#timestamp
When the post was posted#vote_count
How many votes there post has#comment_count
How many comments the post has#answer
The comment that has been marked as the answer. Returnsnil
if there is none, elseComment
#is_answered
Whether an answer has been selected#is_answerable
Whether you are able to answer the post#is_announcement
Whether the post in marked as an announcement#is_pinned
Whether the post is pinned#is_locked
Whether the post is locked#is_hidden
Whether the post is hidden (unlisted)#get_upvotes :count
Get the users that have upvoted the post. Count defaults to 10. Returns array orUser
s#get_comments :order, :count, :after
Get the post's comments. Returns array ofComment
s#create_comment content
Comment on the post. ReturnsComment
#edit :title, :content, :repl_id, :show_hosted
Edit the post. ReturnsPost
#delete
Delete the post#report reason
Report the post
#id
Comment's id#url
Comment's url#author
Comment's author. ReturnsUser
#content
Comment's content#post_id
Id of the post that the comment is on#is_answer
Whether the comment has been selected as the answer to a post#vote_count
How many votes the comment has#timestamp
When the comment was made#get_post
Get the post that the comment was made on. ReturnsPost
#get_comments
Get the children comments of the comment. Returns array ofComment
s#get_parent
Get the parent comment of a child comment. Returnsnil
if it isn't a child, elseComment
#create_comment content
reply to the comment. ReturnsComment
#edit content
Edit the comment. ReturnsComment
#delete
Delete the comment#report reason
Report the comment
#id
Repl's id#url
Repl's URL#title
Repl's name#author
Repl's author. ReturnsUser
#description
Repl's description#timestamp
When the repl was made#size
How many bytes the repl is#run_count
How many times the repl has been run#fork_count
How many times the repl has been forked#language
Repl's language. ReturnsLanguage
#image_url
Repl image's url#origin_url
Url of the repl from which this repl was forked#is_private
Whether the repl is private#is_always_on
Whether the repl is always on#tags
Tags tagged on the repl. Returns array ofTag
s#reactions
Reactions reacted on the repl. Returns array ofReaction
s#get_forks
Repl's forks. Returns array ofRepl
s#get_comments
Repl's comments. Returns array ofReplComment
s#create_comment content
Comment on the repl#add_reaction type
Add a reaction to the repl#remove_reaction type
Remove a reaction from the repl#publish description, image_url, tags, :enable_comments
Publish the repl. Use this to publish an update too#unpublish
Unpublish the repl
#id
Comment's id#content
Comment's content#author
Comment's author. ReturnsUser
#repl
Repl the comment was made on. ReturnsRepl
#replies
Comment's replies. Returns array ofReplComment
s#create_comment content
Reply to the repl comment#edit content
Edit the repl comment#delete
Delete the repl comment
#id
Tag's id (name)#repl_count
How many repls are listed under the tag#creator_count
How many different users are listed under the tag#is_trending
Whether the tag is trending#repls_tagged_today_count
How many repls have been published with the tag today#get_repls :count, :after
Get the top 10 repls that have the tag. Returns array ofRepl
s
#id
Reaction's id#type
Reaction's type (heart, eyes etc.)#count
How many people have reacted with this reaction on the repl
#id
Language's id (like 'python3' or 'html')#key
Language's key#name
Language's name (like 'Python' or 'HTML, CSS, JS')#tagline
Language's tagline#category
Category that the language is in#icon
URL of the language's icon
#name
Role's name#key
Role's key#tagline
Role's tagline
#id
Board's id#name
Board's name#color
Board's color#description
Board's description