Skip to content

Instantly share code, notes, and snippets.

@nickmartini
Created July 24, 2009 16:17
Show Gist options
  • Save nickmartini/154391 to your computer and use it in GitHub Desktop.
Save nickmartini/154391 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'eventmachine'
require 'twitter'
require 'logger'
#this is me being too lazy to rewrite all of the sequel methods
AL_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../..")
require '../bebot/helpers/bebot'
class Twatbot
include BebotHelper
attr_accessor :interval, :fags
def initialize
@interval = 1800
@logger = Logger.new(STDOUT)
@logger.datetime_format = "%Y-%m-%d %H:%M:%S"
@logger.level = Logger::DEBUG
@logger.info "Created new twatbot."
end
def get_twat
@next_fag = @fags[rand(@fags.size - 1)]
msg = find_message_for(@next_fag)
#check out this leet way to make sure we dont post urls!!!!!!!!!!!
#needs more 'goto' calls
if msg =~ /http/i
msg = find_message_for(@next_fag)
end
msg
end
def twat
begin
twatter = Twitter::Client.new(:login => 'SIR FUCKSALOT', :password => 'I LIKE BIG BUTTS AND I CANNOT LIE')
twatter.status(:post, get_twat).text
rescue
"FUCK ME RUNNING, TWITTER FUCKIN' CRASHED!"
end
end
def start
@logger.info "Twatting started, first twat in #{@interval} seconds."
EM.run {
EM.add_periodic_timer(@interval) do
nap = rand(900)
@logger.info "Twatted: '#{twat}' from #{@next_fag}"
@logger.debug "Sleeping for #{nap + @interval} seconds. Next twat @ #{Time.now + @interval + nap}}"
sleep nap
end
}
end
end
b = Twatbot.new
b.fags = ["nick", "alex", "B^]", "charlie"]
b.interval = 1800
b.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment