Skip to content

Instantly share code, notes, and snippets.

@jonallured
Created March 26, 2016 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonallured/406704a32e9d16be23fb to your computer and use it in GitHub Desktop.
Save jonallured/406704a32e9d16be23fb to your computer and use it in GitHub Desktop.
The Breakfast Club written and directed by John Hughes
require 'net/http'
class BratBot
def initialize(name, bot_id, delay)
@name, @bot_id, @delay = name, bot_id, delay
end
def speak
loop { sleep delay; puts post }
end
private
def post
"#{@name}\t#{line}"
end
def line
Net::HTTP.get 'metabot.hashrocket.com', "/api/bots/#{@bot_id}/speak"
end
def delay
@delay + rand(10)
end
end
bots = [
BratBot.new('criminal ', '6896939740144635912', 25),
BratBot.new('princess ', '5587304389607132289', 20),
BratBot.new('athlete ', '3699341739317680363', 30),
BratBot.new('brain ', '6219189898565847883', 30),
BratBot.new('basketcase', '7785473481237220068', 60),
]
threads = bots.map { |bot| Thread.new { bot.speak } }
threads.each { |thread| thread.join }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment