summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwjoe <joe@lc8n.com>2012-02-07 13:08:36 +0000
committerwjoe <joe@lc8n.com>2012-02-07 13:08:36 +0000
commit6a4bad6eaa9958676223015e7dec5be3aeab95fe (patch)
treea3c192bb4fb93ad9ee036a765fac4e38552a9464
parentee589a7c34dcc3f92e9fd702d7cacd41747827f9 (diff)
Historic commit 1.0 (01-Feb-2012 20:43)
-rw-r--r--blatweet.rb25
1 files changed, 24 insertions, 1 deletions
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