-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwitpow.rb
75 lines (68 loc) · 1.4 KB
/
twitpow.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require 'rubygems'
require 'bundler/setup'
require 'highline/import'
require 'httparty'
require 'yaml'
require 'term/ansicolor'
require 'pstore'
require 'time'
include Term::ANSIColor
current_dir = File.dirname(__FILE__)
require "#{current_dir}/twitterer"
require "#{current_dir}/tweet"
if ARGV[0] == 'history'
tweets = Tweet.new
no_of_tweets = nil
if ARGV[1] == 'search'
query = ARGV[2]
else
no_of_tweets = ARGV[1]
end
tweets.history(no_of_tweets, query)
elsif ARGV[0] == 'friends'
tweets = Tweet.new
tweets.friends
elsif ARGV[0] == 'mentions'
tweets = Tweet.new
tweets.mentions
elsif ARGV[0] == 'update'
text = ARGV[1]
if text && text.size > 0 && text.size <= 140
tweets = Tweet.new
tweets.post(text)
else
extra_chars = text.size - 140
puts "Hey! You're writing an essay? Overshot by #{extra_chars} characters."
end
elsif ARGV[0] == 'reply'
status_id = ARGV[1]
if status_id
tweets = Tweet.new
tweets.reply(status_id)
end
elsif ARGV[0] == 'retweet'
status_id = ARGV[1]
if status_id
tweets = Tweet.new
tweets.retweet(status_id)
end
elsif ARGV[0] == 'user'
screen_name = ARGV[1]
if screen_name
tweets = Tweet.new
tweets.user(screen_name)
end
else
puts """
Usage:
ruby twitpow.rb [options]
Options:
- friends
- mentions
- update [tweet]
- reply [status id]
- retweet [status id]
- history [no of tweets]
- history search [query]
"""
end