Skip to content

Instantly share code, notes, and snippets.

@KristupasSavickas
Last active March 6, 2016 07:43
Show Gist options
  • Save KristupasSavickas/d546296f061fdf19ed70 to your computer and use it in GitHub Desktop.
Save KristupasSavickas/d546296f061fdf19ed70 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'redditkit'
class User
def initialize
puts "Enter username"
@username = gets.chomp
@user_content = RedditKit.user_content(@username)
puts "Downvote or upvote?"
if gets.chomp == "upvote"
@vote = 1
else
@vote = -1
end
end
def vote(bots)
@user_content.each do |content|
bots.each do |bot|
bot.vote(@content, @vote)
if content.instance_of?(RedditKit::Comment)
text = content.body
text = content.body[0..37] + ("...") if content.body.length > 40
else
text = content.title
text = content.title[0..37] + ("...") if content.title.length > 40
end
puts "#{text}, by #{@username} voted #{@vote} (bot: #{bot.username})"
sleep(1)
end
end
end
end
users = Array.new
users.push(User.new)
while true do
puts "Add users to upvote/downvote?"
if gets.chomp == "y"
users.push(User.new)
else
break
end
end
bots_hash = {} #Format {:username => "password", :username2 => "password"}
bots = Array.new
bots_hash.each_with_index do |(username, password), index|
bots[index] = RedditKit::Client.new(username.to_s, password)
end
puts "Loop started, press ctrl+c to stop"
while true do
users.each do |user|
user.vote(bots)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment