Project

snooby

0.01
No commit activity in last 3 years
No release in over 3 years
Snooby wraps the reddit API in happy, convenient Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

What is Snooby?

Snooby is a wrapper around the reddit API written in Ruby. It aims to make automating any part of the reddit experience as simple and clear-cut as possible, while still providing ample functionality.

Install

gem install snooby

Examples

Here's one way you might go about implementing a very simple bot that constantly monitors new comments to scold users of crass language.

require 'snooby'

probot = Snooby::Client.new('ProfanityBot, v1.0')
probot.authorize!('ProfanityBot', 'hunter2')

while true
  probot.r('all').comments.each do |com|
    if com.body =~ /(vile|rotten|words)/
      com.reply("#{$&.capitalize} is a terrible word, #{com.author}!")
    end
  end
end

That covers most of the core features, but here's a look at a few more in closer detail.

reddit = Snooby::Client.new

reddit.user('andrewsmith1986').about['comment_karma'] # => 548027
reddit.u('violentacrez').trophies.size # => 46

reddit.subreddit('askscience').posts[0].selftext # => We see lots of people...
reddit.r('pics').message('Ban imgur.', "Wouldn't that be lulzy?")

frontpage = reddit.r # note the lack of parameters
frontpage.posts[-1].reply('Welcome to the front page.')

# Downvote everything I've ever said. (Note: most of your votes won't count.)
reddit.u('HazierPhonics').comments(1000).each { |c| c.downvote }

# Similarly, upvote everything on the front page of /r/askscience. (Same disclaimer.)
reddit.r('askscience').posts.each { |p| p.upvote }

The code is thoroughly documented and is the best place to start with questions.

TODO

  • Moderation
  • Much more thorough configuration file
  • Granular caching
  • Elegant solution to the "more comments" problem