From 6a4bad6eaa9958676223015e7dec5be3aeab95fe Mon Sep 17 00:00:00 2001 From: wjoe Date: Tue, 7 Feb 2012 13:08:36 +0000 Subject: Historic commit 1.0 (01-Feb-2012 20:43) --- blatweet.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/blatweet.rb b/blatweet.rb index 3ecbad3..b6c7f94 100644 --- a/blatweet.rb +++ b/blatweet.rb @@ -1,5 +1,24 @@ #!/usr/bin/env ruby require 'twitter' +require 'optparse' + +username = nil +number_of_tweets = 1 + +STDIN.gets.split(' ').each{|arg| ARGV << arg} if ARGV == [] +args = ARGV.dup + +options = OptionParser.new do |opts| + opts.banner = "Usage: #{File.basename($0)} -u USERNAME -n NO_OF_TWEETS" + opts.on( "-u", "--username USERNAME", "Twitter username to search for." ) { |u| username = u } + opts.on( "-n", "--number NO_OF_TWEETS", "Number of tweets to return." ) { |n| number_of_tweets = n } + opts.on( '-h', '--help', 'Display this screen' ) { puts opts; exit } +end;options.parse! + +if args == [] + puts options + exit(-1) +end Twitter.configure do |config| config.consumer_key = 'vXaBVIrxiJw2TKVJyI1w' @@ -8,4 +27,8 @@ Twitter.configure do |config| config.oauth_token_secret = 'YxnmXtywSbIvJHyX6pdGhDnkQiR2Z1KJ84DQyzVpUk' end -Twitter.update ARGV[0] +if username + Twitter.search("from:#{username}", :rpp => number_of_tweets, :result_type => "recent").each{|tweet| puts tweet.text} +else + Twitter.update ARGV.join ' ' +end -- cgit v1.2.3