summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blatweet.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/blatweet.rb b/blatweet.rb
index b6c7f94..cef1f83 100644
--- a/blatweet.rb
+++ b/blatweet.rb
@@ -4,6 +4,7 @@ require 'optparse'
username = nil
number_of_tweets = 1
+output = ''
STDIN.gets.split(' ').each{|arg| ARGV << arg} if ARGV == []
args = ARGV.dup
@@ -27,8 +28,15 @@ Twitter.configure do |config|
config.oauth_token_secret = 'YxnmXtywSbIvJHyX6pdGhDnkQiR2Z1KJ84DQyzVpUk'
end
-if username
- Twitter.search("from:#{username}", :rpp => number_of_tweets, :result_type => "recent").each{|tweet| puts tweet.text}
-else
- Twitter.update ARGV.join ' '
+begin
+ if username
+ Twitter.search("from:#{username}", :rpp => number_of_tweets, :result_type => "recent").each{|tweet| output += "#{tweet.text}\n"}
+ puts output
+ else
+ Twitter.update ARGV.join ' '
+ end
+rescue Twitter::Error => e
+ puts e.message
+rescue StandardError => e
+ puts e.message
end