#!/usr/bin/env ruby require 'rubygems' require 'twitter' #Load Configuration from ~/.twitter begin config = YAML::load(open(ENV['HOME'] + '/.twitter')) rescue puts "\tUsage: tweet i like to eat cheese" puts "\t(or just type tweet to get all your tweets)" puts "\n\n\tConfiguration File Missing" puts "\tExample:\n" puts "\t\tlogin: mylogin" puts "\t\tpassword: mypassword" puts "\tput in ~/.twitter\n\n" exit end #initialize twitter library twitter = Twitter::Base.new(config['login'], config['password']) #check auth begin twitter.verify_credentials rescue puts "Authentication Failed." exit end #tweet or post if ARGV.size == 0 twitter.timeline(:friends).each do |s| puts "#{s.user.name}: #{s.text}" end else message = ARGV.join(' ').gsub(/"/, '') status = twitter.post(message) puts "Tweet Posted: http://twitter.com/#{status.user.name}/statuses/#{status.id}\n" end