NamedPipe

October 10, 2009 at 11:42pm
home

Quick Campfire Insult Bot

#!/usr/bin/ruby
require 'rubygems'
require 'tinder'
require 'hpricot'
require 'open-uri'

campfire = Tinder::Campfire.new ''
campfire.login '', ''
room = campfire.find_room_by_name ''

def insult
	url = "http://www.randominsults.net/"
	doc = Hpricot(open(url))
	doc.search( "//table[@id='AutoNumber1']//tr/td//i" ).first.inner_html
end

puts "bot starting up at " + Time.now.to_s

(1..100).to_a.each do |i|
	room.listen do |m|
		if m[:message].match(/(shit|fuck|damn|ass|asshole|stupid)/i)
			room.speak "Hey #{m[:person]}, #{insult}"
		end
  end
  sleep 3
end

puts "bot shutting down at " + Time.now.to_s