t 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +28 -18
- data/lib/t/cli.rb +167 -166
- data/lib/t/delete.rb +12 -12
- data/lib/t/list.rb +26 -26
- data/lib/t/printable.rb +12 -2
- data/lib/t/rcfile.rb +11 -11
- data/lib/t/requestable.rb +5 -5
- data/lib/t/search.rb +14 -14
- data/lib/t/set.rb +15 -14
- data/lib/t/version.rb +1 -1
- data/spec/cli_spec.rb +154 -150
- data/spec/delete_spec.rb +11 -11
- data/spec/list_spec.rb +25 -24
- data/spec/rcfile_spec.rb +29 -15
- data/spec/search_spec.rb +19 -14
- data/spec/set_spec.rb +15 -15
- data/t.gemspec +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
### A command-line power tool for Twitter.
|
3
3
|
|
4
4
|
The CLI attempts to mimic the [Twitter SMS commands][sms] wherever possible,
|
5
|
-
however it offers
|
5
|
+
however it offers vastly more commands and capabilities than are available via
|
6
|
+
SMS.
|
6
7
|
|
7
8
|
[travis]: http://travis-ci.org/sferik/t
|
8
9
|
[gemnasium]: https://gemnasium.com/sferik/t
|
@@ -25,9 +26,10 @@ secret, which you can use to authorize your Twitter account.
|
|
25
26
|
|
26
27
|
t authorize -c YOUR_CONSUMER_KEY -s YOUR_CONSUMER_SECRET
|
27
28
|
|
28
|
-
This will
|
29
|
-
|
30
|
-
|
29
|
+
This will direct you to a URL where you can authenticate to Twitter and then
|
30
|
+
enter the returned PIN back into the terminal. Assuming that works, you'll be
|
31
|
+
authorized to use `t` as that user. To authorize multiple accounts, simply
|
32
|
+
repeat the last step while signed in to Twitter as a different user.
|
31
33
|
|
32
34
|
You can see a list of all the accounts you've authorized.
|
33
35
|
|
@@ -37,15 +39,18 @@ You can see a list of all the accounts you've authorized.
|
|
37
39
|
UDfNTpOz5ZDG4a6w7dIWj
|
38
40
|
uuP7Xbl2mEfGMiDu1uIyFN
|
39
41
|
gem
|
40
|
-
thG9EfWoADtIr6NjbL9ON (
|
42
|
+
thG9EfWoADtIr6NjbL9ON (active)
|
41
43
|
|
42
|
-
Notice that one account is marked as the
|
43
|
-
`set` subcommand, passing either just the username, if it's
|
44
|
-
username and consumer key pair, like so:
|
44
|
+
Notice that one account is marked as the active. To change the active account
|
45
|
+
use the `set` subcommand, passing either just the username, if it's
|
46
|
+
unambiguous, or the username and consumer key pair, like so:
|
45
47
|
|
46
|
-
t set
|
48
|
+
t set active sferik UDfNTpOz5ZDG4a6w7dIWj
|
47
49
|
|
48
|
-
Account information is stored in the YAML-formatted file `~/.trc`.
|
50
|
+
Account information is stored in the YAML-formatted file `~/.trc`. **Note**:
|
51
|
+
Anyone with access to this file can masquerade as you on Twitter, so it's
|
52
|
+
important to keep it secure, just as you would treat your SSH private key. For
|
53
|
+
this reason, the file is hidden and has the permission bits set to 0600.
|
49
54
|
|
50
55
|
## <a name="examples"></a>Usage Examples
|
51
56
|
Typing `t help` will give you a list of all the available commands. You can
|
@@ -58,7 +63,8 @@ type `t help TASK` to get help for a specific command.
|
|
58
63
|
|
59
64
|
**Note**: If your tweet includes special characters (e.g. `!`), make sure to
|
60
65
|
wrap it in single quotes instead of double quotes, so those characters are not
|
61
|
-
interpreted by your shell.
|
66
|
+
interpreted by your shell. However, if you use single quotes, your Tweet can't
|
67
|
+
contain any apostrophes.
|
62
68
|
|
63
69
|
### <a name="stats"></a>Retrieve stats about users
|
64
70
|
t users -l @sferik @gem
|
@@ -66,31 +72,35 @@ interpreted by your shell.
|
|
66
72
|
### <a name="follow"></a>Follow users
|
67
73
|
t follow @sferik @gem
|
68
74
|
|
69
|
-
### <a name="does-follow"></a>
|
75
|
+
### <a name="does-follow"></a>Find out if one user follows another
|
70
76
|
t does_follow @ev @sferik
|
71
77
|
|
72
|
-
**Note**:
|
73
|
-
|
78
|
+
**Note**: If the first user doesn't follow the second, `t` will exit with a
|
79
|
+
non-zero exit code. This allows you to execute conditional commands, for
|
80
|
+
example:
|
74
81
|
|
75
82
|
t does_follow @ev @sferik && t dm @ev "What's up, bro?"
|
76
83
|
|
77
|
-
### <a name="friends"></a>List your friends (ordered by number of followers)
|
84
|
+
### <a name="friends"></a>List all your friends (ordered by number of followers)
|
78
85
|
t friends -lf
|
79
86
|
|
80
|
-
### <a name="leaders"></a>List your leaders (people you follow who don't follow you back)
|
87
|
+
### <a name="leaders"></a>List all your leaders (people you follow who don't follow you back)
|
81
88
|
t leaders -lf
|
82
89
|
|
83
90
|
### <a name="unfollow"></a>Unfollow everyone you follow who doesn't follow you back
|
84
91
|
t leaders | xargs t unfollow
|
85
92
|
|
86
|
-
### <a name="follow"></a>Follow
|
93
|
+
### <a name="follow"></a>Follow everyone who follows you (who you don't already follow)
|
87
94
|
t disciples | xargs t follow
|
88
95
|
|
89
96
|
### <a name="follow-roulette"></a>Follow roulette: randomly follow someone who follows you
|
90
97
|
t disciples | shuf | head -1 | xargs t follow
|
91
98
|
|
99
|
+
### <a name="timeline"></a>Output the last 200 tweets in your timeline to a CSV file
|
100
|
+
t timeline -n 200 --csv > timeline.csv
|
101
|
+
|
92
102
|
### <a name="favorite"></a>Favorite the last 10 tweets that mention you
|
93
|
-
t mentions -
|
103
|
+
t mentions -n 10 -l | awk '{print $1}' | xargs t favorite
|
94
104
|
|
95
105
|
### <a name="list-create"></a>Create a list
|
96
106
|
t list create presidents
|
data/lib/t/cli.rb
CHANGED
@@ -46,9 +46,10 @@ module T
|
|
46
46
|
|
47
47
|
check_unknown_options!
|
48
48
|
|
49
|
-
option
|
50
|
-
option
|
51
|
-
option
|
49
|
+
option "host", :aliases => "-H", :type => :string, :default => DEFAULT_HOST, :desc => "Twitter API server"
|
50
|
+
option "no-color", :alias => "-N", :type => :boolean, :banner => "Disable colorization in output"
|
51
|
+
option "no-ssl", :aliases => "-U", :type => :boolean, :default => false, :desc => "Disable SSL"
|
52
|
+
option "profile", :aliases => "-P", :type => :string, :default => File.join(File.expand_path("~"), RCFile::FILE_NAME), :desc => "Path to RC file", :banner => "FILE"
|
52
53
|
|
53
54
|
def initialize(*)
|
54
55
|
super
|
@@ -61,16 +62,16 @@ module T
|
|
61
62
|
@rcfile.profiles.each do |profile|
|
62
63
|
say profile[0]
|
63
64
|
profile[1].keys.each do |key|
|
64
|
-
say " #{key}#{@rcfile.
|
65
|
+
say " #{key}#{@rcfile.active_profile[0] == profile[0] && @rcfile.active_profile[1] == key ? " (active)" : nil}"
|
65
66
|
end
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
69
70
|
desc "authorize", "Allows an application to request user authorization"
|
70
|
-
method_option
|
71
|
-
method_option
|
72
|
-
method_option
|
73
|
-
method_option
|
71
|
+
method_option "consumer-key", :aliases => "-c", :required => true, :desc => "This can be found at https://dev.twitter.com/apps"
|
72
|
+
method_option "consumer-secret", :aliases => "-s", :required => true, :desc => "This can be found at https://dev.twitter.com/apps"
|
73
|
+
method_option "display-url", :aliases => "-d", :type => :boolean, :default => false, :desc => "Display the authorization URL instead of attempting to open it."
|
74
|
+
method_option "prompt", :aliases => "-p", :type => :boolean, :default => true
|
74
75
|
def authorize
|
75
76
|
request_token = consumer.get_request_token
|
76
77
|
url = generate_authorize_url(request_token)
|
@@ -85,27 +86,27 @@ module T
|
|
85
86
|
ask "Press [Enter] to open the Twitter app authorization page."
|
86
87
|
say
|
87
88
|
end
|
88
|
-
Launchy.open(url, :dry_run => options['
|
89
|
+
Launchy.open(url, :dry_run => options['display-url'])
|
89
90
|
pin = ask "Paste in the supplied PIN:"
|
90
91
|
access_token = request_token.get_access_token(:oauth_verifier => pin.chomp)
|
91
92
|
oauth_response = access_token.get('/1/account/verify_credentials.json')
|
92
93
|
screen_name = oauth_response.body.match(/"screen_name"\s*:\s*"(.*?)"/).captures.first
|
93
94
|
@rcfile.path = options['profile'] if options['profile']
|
94
95
|
@rcfile[screen_name] = {
|
95
|
-
options['
|
96
|
+
options['consumer-key'] => {
|
96
97
|
'username' => screen_name,
|
97
|
-
'consumer_key' => options['
|
98
|
-
'consumer_secret' => options['
|
98
|
+
'consumer_key' => options['consumer-key'],
|
99
|
+
'consumer_secret' => options['consumer-secret'],
|
99
100
|
'token' => access_token.token,
|
100
101
|
'secret' => access_token.secret,
|
101
102
|
}
|
102
103
|
}
|
103
|
-
@rcfile.
|
104
|
+
@rcfile.active_profile = {'username' => screen_name, 'consumer_key' => options['consumer-key']}
|
104
105
|
say "Authorization successful."
|
105
106
|
end
|
106
107
|
|
107
108
|
desc "block USER [USER...]", "Block users."
|
108
|
-
method_option
|
109
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
109
110
|
def block(user, *users)
|
110
111
|
users.unshift(user)
|
111
112
|
if options['id']
|
@@ -119,16 +120,16 @@ module T
|
|
119
120
|
end
|
120
121
|
end
|
121
122
|
number = users.length
|
122
|
-
say "@#{@rcfile.
|
123
|
+
say "@#{@rcfile.active_profile[0]} blocked #{number} #{number == 1 ? 'user' : 'users'}."
|
123
124
|
say
|
124
125
|
say "Run `#{File.basename($0)} delete block #{users.map{|user| "@#{user.screen_name}"}.join(' ')}` to unblock."
|
125
126
|
end
|
126
127
|
|
127
128
|
desc "direct_messages", "Returns the #{DEFAULT_NUM_RESULTS} most recent Direct Messages sent to you."
|
128
|
-
method_option
|
129
|
-
method_option
|
130
|
-
method_option
|
131
|
-
method_option
|
129
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
130
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
131
|
+
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
132
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
132
133
|
def direct_messages
|
133
134
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
134
135
|
direct_messages = client.direct_messages(:count => count, :include_entities => false)
|
@@ -157,10 +158,10 @@ module T
|
|
157
158
|
map %w(directmessages dms) => :direct_messages
|
158
159
|
|
159
160
|
desc "direct_messages_sent", "Returns the #{DEFAULT_NUM_RESULTS} most recent Direct Messages sent to you."
|
160
|
-
method_option
|
161
|
-
method_option
|
162
|
-
method_option
|
163
|
-
method_option
|
161
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
162
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
163
|
+
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
164
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
164
165
|
def direct_messages_sent
|
165
166
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
166
167
|
direct_messages = client.direct_messages_sent(:count => count, :include_entities => false)
|
@@ -189,17 +190,17 @@ module T
|
|
189
190
|
map %w(directmessagessent sent_messages sentmessages sms) => :direct_messages_sent
|
190
191
|
|
191
192
|
desc "disciples [USER]", "Returns the list of people who follow you but you don't follow back."
|
192
|
-
method_option
|
193
|
-
method_option
|
194
|
-
method_option
|
195
|
-
method_option
|
196
|
-
method_option
|
197
|
-
method_option
|
198
|
-
method_option
|
199
|
-
method_option
|
200
|
-
method_option
|
201
|
-
method_option
|
202
|
-
method_option
|
193
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
194
|
+
method_option "favorites", :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by number of favorites."
|
195
|
+
method_option "followers", :aliases => "-f", :type => :boolean, :default => false, :desc => "Sort by number of followers."
|
196
|
+
method_option "friends", :aliases => "-e", :type => :boolean, :default => false, :desc => "Sort by number of friends."
|
197
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
198
|
+
method_option "listed", :aliases => "-s", :type => :boolean, :default => false, :desc => "Sort by number of list memberships."
|
199
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
200
|
+
method_option "posted", :aliases => "-p", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter account was posted."
|
201
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
202
|
+
method_option "tweets", :aliases => "-t", :type => :boolean, :default => false, :desc => "Sort by number of Tweets."
|
203
|
+
method_option "unsorted", :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
|
203
204
|
def disciples(user=nil)
|
204
205
|
if user
|
205
206
|
user = if options['id']
|
@@ -224,7 +225,7 @@ module T
|
|
224
225
|
end
|
225
226
|
|
226
227
|
desc "dm USER MESSAGE", "Sends that person a Direct Message."
|
227
|
-
method_option
|
228
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
228
229
|
def dm(user, message)
|
229
230
|
user = if options['id']
|
230
231
|
user.to_i
|
@@ -232,17 +233,17 @@ module T
|
|
232
233
|
user.strip_ats
|
233
234
|
end
|
234
235
|
direct_message = client.direct_message_create(user, message, :include_entities => false)
|
235
|
-
say "Direct Message sent from @#{@rcfile.
|
236
|
+
say "Direct Message sent from @#{@rcfile.active_profile[0]} to @#{direct_message.recipient.screen_name} (#{time_ago_in_words(direct_message.created_at)} ago)."
|
236
237
|
end
|
237
238
|
map %w(d m) => :dm
|
238
239
|
|
239
240
|
desc "does_contain [USER/]LIST USER", "Find out whether a list contains a user."
|
240
|
-
method_option
|
241
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
241
242
|
def does_contain(list, user=nil)
|
242
243
|
owner, list = list.split('/')
|
243
244
|
if list.nil?
|
244
245
|
list = owner
|
245
|
-
owner = @rcfile.
|
246
|
+
owner = @rcfile.active_profile[0]
|
246
247
|
else
|
247
248
|
owner = if options['id']
|
248
249
|
client.user(owner.to_i, :include_entities => false).screen_name
|
@@ -251,7 +252,7 @@ module T
|
|
251
252
|
end
|
252
253
|
end
|
253
254
|
if user.nil?
|
254
|
-
user = @rcfile.
|
255
|
+
user = @rcfile.active_profile[0]
|
255
256
|
else
|
256
257
|
user = if options['id']
|
257
258
|
user = client.user(user.to_i, :include_entities => false).screen_name
|
@@ -269,7 +270,7 @@ module T
|
|
269
270
|
map %w(dc doescontain) => :does_contain
|
270
271
|
|
271
272
|
desc "does_follow USER [USER]", "Find out whether one user follows another."
|
272
|
-
method_option
|
273
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
273
274
|
def does_follow(user1, user2=nil)
|
274
275
|
user1 = if options['id']
|
275
276
|
client.user(user1.to_i, :include_entities => false).screen_name
|
@@ -277,7 +278,7 @@ module T
|
|
277
278
|
user1.strip_ats
|
278
279
|
end
|
279
280
|
if user2.nil?
|
280
|
-
user2 = @rcfile.
|
281
|
+
user2 = @rcfile.active_profile[0]
|
281
282
|
else
|
282
283
|
user2 = if options['id']
|
283
284
|
client.user(user2.to_i, :include_entities => false).screen_name
|
@@ -304,18 +305,18 @@ module T
|
|
304
305
|
end
|
305
306
|
end
|
306
307
|
number = favorites.length
|
307
|
-
say "@#{@rcfile.
|
308
|
+
say "@#{@rcfile.active_profile[0]} favorited #{number} #{number == 1 ? 'tweet' : 'tweets'}."
|
308
309
|
say
|
309
310
|
say "Run `#{File.basename($0)} delete favorite #{status_ids.join(' ')}` to unfavorite."
|
310
311
|
end
|
311
312
|
map %w(fave favourite) => :favorite
|
312
313
|
|
313
314
|
desc "favorites [USER]", "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets you favorited."
|
314
|
-
method_option
|
315
|
-
method_option
|
316
|
-
method_option
|
317
|
-
method_option
|
318
|
-
method_option
|
315
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
316
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
317
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
318
|
+
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
319
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
319
320
|
def favorites(user=nil)
|
320
321
|
if user
|
321
322
|
user = if options['id']
|
@@ -331,7 +332,7 @@ module T
|
|
331
332
|
map %w(faves favourites) => :favorites
|
332
333
|
|
333
334
|
desc "follow USER [USER...]", "Allows you to start following users."
|
334
|
-
method_option
|
335
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
335
336
|
def follow(user, *users)
|
336
337
|
users.unshift(user)
|
337
338
|
if options['id']
|
@@ -345,23 +346,23 @@ module T
|
|
345
346
|
end
|
346
347
|
end
|
347
348
|
number = users.length
|
348
|
-
say "@#{@rcfile.
|
349
|
+
say "@#{@rcfile.active_profile[0]} is now following #{number} more #{number == 1 ? 'user' : 'users'}."
|
349
350
|
say
|
350
351
|
say "Run `#{File.basename($0)} unfollow #{users.map{|user| "@#{user.screen_name}"}.join(' ')}` to stop."
|
351
352
|
end
|
352
353
|
|
353
354
|
desc "followings [USER]", "Returns a list of the people you follow on Twitter."
|
354
|
-
method_option
|
355
|
-
method_option
|
356
|
-
method_option
|
357
|
-
method_option
|
358
|
-
method_option
|
359
|
-
method_option
|
360
|
-
method_option
|
361
|
-
method_option
|
362
|
-
method_option
|
363
|
-
method_option
|
364
|
-
method_option
|
355
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
356
|
+
method_option "favorites", :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by number of favorites."
|
357
|
+
method_option "followers", :aliases => "-f", :type => :boolean, :default => false, :desc => "Sort by number of followers."
|
358
|
+
method_option "friends", :aliases => "-e", :type => :boolean, :default => false, :desc => "Sort by number of friends."
|
359
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
360
|
+
method_option "listed", :aliases => "-s", :type => :boolean, :default => false, :desc => "Sort by number of list memberships."
|
361
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
362
|
+
method_option "posted", :aliases => "-p", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter account was posted."
|
363
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
364
|
+
method_option "tweets", :aliases => "-t", :type => :boolean, :default => false, :desc => "Sort by number of Tweets."
|
365
|
+
method_option "unsorted", :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
|
365
366
|
def followings(user=nil)
|
366
367
|
if user
|
367
368
|
user = if options['id']
|
@@ -382,17 +383,17 @@ module T
|
|
382
383
|
end
|
383
384
|
|
384
385
|
desc "followers [USER]", "Returns a list of the people who follow you on Twitter."
|
385
|
-
method_option
|
386
|
-
method_option
|
387
|
-
method_option
|
388
|
-
method_option
|
389
|
-
method_option
|
390
|
-
method_option
|
391
|
-
method_option
|
392
|
-
method_option
|
393
|
-
method_option
|
394
|
-
method_option
|
395
|
-
method_option
|
386
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
387
|
+
method_option "favorites", :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by number of favorites."
|
388
|
+
method_option "followers", :aliases => "-f", :type => :boolean, :default => false, :desc => "Sort by number of followers."
|
389
|
+
method_option "friends", :aliases => "-e", :type => :boolean, :default => false, :desc => "Sort by number of friends."
|
390
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
391
|
+
method_option "listed", :aliases => "-s", :type => :boolean, :default => false, :desc => "Sort by number of list memberships."
|
392
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
393
|
+
method_option "posted", :aliases => "-p", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter account was posted."
|
394
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
395
|
+
method_option "tweets", :aliases => "-t", :type => :boolean, :default => false, :desc => "Sort by number of Tweets."
|
396
|
+
method_option "unsorted", :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
|
396
397
|
def followers(user=nil)
|
397
398
|
if user
|
398
399
|
user = if options['id']
|
@@ -413,17 +414,17 @@ module T
|
|
413
414
|
end
|
414
415
|
|
415
416
|
desc "friends [USER]", "Returns the list of people who you follow and follow you back."
|
416
|
-
method_option
|
417
|
-
method_option
|
418
|
-
method_option
|
419
|
-
method_option
|
420
|
-
method_option
|
421
|
-
method_option
|
422
|
-
method_option
|
423
|
-
method_option
|
424
|
-
method_option
|
425
|
-
method_option
|
426
|
-
method_option
|
417
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
418
|
+
method_option "favorites", :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by number of favorites."
|
419
|
+
method_option "followers", :aliases => "-f", :type => :boolean, :default => false, :desc => "Sort by number of followers."
|
420
|
+
method_option "friends", :aliases => "-e", :type => :boolean, :default => false, :desc => "Sort by number of friends."
|
421
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
422
|
+
method_option "listed", :aliases => "-s", :type => :boolean, :default => false, :desc => "Sort by number of list memberships."
|
423
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
424
|
+
method_option "posted", :aliases => "-p", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter account was posted."
|
425
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
426
|
+
method_option "tweets", :aliases => "-t", :type => :boolean, :default => false, :desc => "Sort by number of Tweets."
|
427
|
+
method_option "unsorted", :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
|
427
428
|
def friends(user=nil)
|
428
429
|
if user
|
429
430
|
user = if options['id']
|
@@ -448,17 +449,17 @@ module T
|
|
448
449
|
end
|
449
450
|
|
450
451
|
desc "leaders [USER]", "Returns the list of people who you follow but don't follow you back."
|
451
|
-
method_option
|
452
|
-
method_option
|
453
|
-
method_option
|
454
|
-
method_option
|
455
|
-
method_option
|
456
|
-
method_option
|
457
|
-
method_option
|
458
|
-
method_option
|
459
|
-
method_option
|
460
|
-
method_option
|
461
|
-
method_option
|
452
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
453
|
+
method_option "favorites", :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by number of favorites."
|
454
|
+
method_option "followers", :aliases => "-f", :type => :boolean, :default => false, :desc => "Sort by number of followers."
|
455
|
+
method_option "friends", :aliases => "-e", :type => :boolean, :default => false, :desc => "Sort by number of friends."
|
456
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
457
|
+
method_option "listed", :aliases => "-s", :type => :boolean, :default => false, :desc => "Sort by number of list memberships."
|
458
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
459
|
+
method_option "posted", :aliases => "-p", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter account was posted."
|
460
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
461
|
+
method_option "tweets", :aliases => "-t", :type => :boolean, :default => false, :desc => "Sort by number of Tweets."
|
462
|
+
method_option "unsorted", :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
|
462
463
|
def leaders(user=nil)
|
463
464
|
if user
|
464
465
|
user = if options['id']
|
@@ -483,15 +484,15 @@ module T
|
|
483
484
|
end
|
484
485
|
|
485
486
|
desc "lists [USER]", "Returns the lists created by a user."
|
486
|
-
method_option
|
487
|
-
method_option
|
488
|
-
method_option
|
489
|
-
method_option
|
490
|
-
method_option
|
491
|
-
method_option
|
492
|
-
method_option
|
493
|
-
method_option
|
494
|
-
method_option
|
487
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
488
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
489
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
490
|
+
method_option "members", :aliases => "-m", :type => :boolean, :default => false, :desc => "Sort by number of members."
|
491
|
+
method_option "mode", :aliases => "-o", :type => :boolean, :default => false, :desc => "Sort by mode."
|
492
|
+
method_option "posted", :aliases => "-p", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter list was posted."
|
493
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
494
|
+
method_option "subscribers", :aliases => "-s", :type => :boolean, :default => false, :desc => "Sort by number of subscribers."
|
495
|
+
method_option "unsorted", :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
|
495
496
|
def lists(user=nil)
|
496
497
|
if user
|
497
498
|
user = if options['id']
|
@@ -507,10 +508,10 @@ module T
|
|
507
508
|
end
|
508
509
|
|
509
510
|
desc "mentions", "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets mentioning you."
|
510
|
-
method_option
|
511
|
-
method_option
|
512
|
-
method_option
|
513
|
-
method_option
|
511
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
512
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
513
|
+
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
514
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
514
515
|
def mentions
|
515
516
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
516
517
|
statuses = client.mentions(:count => count, :include_entities => false)
|
@@ -519,24 +520,24 @@ module T
|
|
519
520
|
map %w(replies) => :mentions
|
520
521
|
|
521
522
|
desc "open USER", "Opens that user's profile in a web browser."
|
522
|
-
method_option
|
523
|
-
method_option
|
524
|
-
method_option
|
523
|
+
method_option "display-url", :aliases => "-d", :type => :boolean, :default => false, :desc => "Display the requested URL instead of attempting to open it."
|
524
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
525
|
+
method_option "status", :aliases => "-s", :type => :boolean, :default => false, :desc => "Specify input as a Twitter status ID instead of a screen name."
|
525
526
|
def open(user)
|
526
527
|
if options['id']
|
527
528
|
user = client.user(user.to_i, :include_entities => false)
|
528
|
-
Launchy.open("https://twitter.com/#{user.screen_name}", :dry_run => options['
|
529
|
+
Launchy.open("https://twitter.com/#{user.screen_name}", :dry_run => options['display-url'])
|
529
530
|
elsif options['status']
|
530
531
|
status = client.status(user.to_i, :include_entities => false, :include_my_retweet => false)
|
531
|
-
Launchy.open("https://twitter.com/#{status.user.screen_name}/status/#{status.id}", :dry_run => options['
|
532
|
+
Launchy.open("https://twitter.com/#{status.user.screen_name}/status/#{status.id}", :dry_run => options['display-url'])
|
532
533
|
else
|
533
|
-
Launchy.open("https://twitter.com/#{user.strip_ats}", :dry_run => options['
|
534
|
+
Launchy.open("https://twitter.com/#{user.strip_ats}", :dry_run => options['display-url'])
|
534
535
|
end
|
535
536
|
end
|
536
537
|
|
537
538
|
desc "reply STATUS_ID MESSAGE", "Post your Tweet as a reply directed at another person."
|
538
|
-
method_option
|
539
|
-
method_option
|
539
|
+
method_option "all", :aliases => "-a", :type => "boolean", :default => false, :desc => "Reply to all users mentioned in the Tweet."
|
540
|
+
method_option "location", :aliases => "-l", :type => :boolean, :default => false
|
540
541
|
def reply(status_id, message)
|
541
542
|
status_id = status_id.strip_commas
|
542
543
|
status = client.status(status_id.to_i, :include_entities => false, :include_my_retweet => false)
|
@@ -547,13 +548,13 @@ module T
|
|
547
548
|
opts = {:in_reply_to_status_id => status.id, :include_entities => false, :trim_user => true}
|
548
549
|
opts.merge!(:lat => location.lat, :long => location.lng) if options['location']
|
549
550
|
reply = client.update("#{users.join(' ')} #{message}", opts)
|
550
|
-
say "Reply created by @#{@rcfile.
|
551
|
+
say "Reply created by @#{@rcfile.active_profile[0]} to #{users.join(' ')} (#{time_ago_in_words(reply.created_at)} ago)."
|
551
552
|
say
|
552
553
|
say "Run `#{File.basename($0)} delete status #{reply.id}` to delete."
|
553
554
|
end
|
554
555
|
|
555
556
|
desc "report_spam USER [USER...]", "Report users for spam."
|
556
|
-
method_option
|
557
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
557
558
|
def report_spam(user, *users)
|
558
559
|
users.unshift(user)
|
559
560
|
if options['id']
|
@@ -567,7 +568,7 @@ module T
|
|
567
568
|
end
|
568
569
|
end
|
569
570
|
number = users.length
|
570
|
-
say "@#{@rcfile.
|
571
|
+
say "@#{@rcfile.active_profile[0]} reported #{number} #{number == 1 ? 'user' : 'users'}."
|
571
572
|
end
|
572
573
|
map %w(report reportspam spam) => :report_spam
|
573
574
|
|
@@ -581,18 +582,18 @@ module T
|
|
581
582
|
end
|
582
583
|
end
|
583
584
|
number = retweets.length
|
584
|
-
say "@#{@rcfile.
|
585
|
+
say "@#{@rcfile.active_profile[0]} retweeted #{number} #{number == 1 ? 'tweet' : 'tweets'}."
|
585
586
|
say
|
586
587
|
say "Run `#{File.basename($0)} delete status #{status_ids.join(' ')}` to undo."
|
587
588
|
end
|
588
589
|
map %w(rt) => :retweet
|
589
590
|
|
590
591
|
desc "retweets [USER]", "Returns the #{DEFAULT_NUM_RESULTS} most recent Retweets by a user."
|
591
|
-
method_option
|
592
|
-
method_option
|
593
|
-
method_option
|
594
|
-
method_option
|
595
|
-
method_option
|
592
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
593
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
594
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
595
|
+
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
596
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
596
597
|
def retweets(user=nil)
|
597
598
|
if user
|
598
599
|
user = if options['id']
|
@@ -613,7 +614,7 @@ module T
|
|
613
614
|
end
|
614
615
|
|
615
616
|
desc "status STATUS_ID", "Retrieves detailed information about a Tweet."
|
616
|
-
method_option
|
617
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
617
618
|
def status(status_id)
|
618
619
|
status_id = status_id.strip_commas
|
619
620
|
status = client.status(status_id.to_i, :include_entities => false, :include_my_retweet => false)
|
@@ -648,18 +649,18 @@ module T
|
|
648
649
|
end
|
649
650
|
|
650
651
|
desc "suggest [USER]", "Returns a listing of Twitter users' accounts you might enjoy following."
|
651
|
-
method_option
|
652
|
-
method_option
|
653
|
-
method_option
|
654
|
-
method_option
|
655
|
-
method_option
|
656
|
-
method_option
|
657
|
-
method_option
|
658
|
-
method_option
|
659
|
-
method_option
|
660
|
-
method_option
|
661
|
-
method_option
|
662
|
-
method_option
|
652
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
653
|
+
method_option "favorites", :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by number of favorites."
|
654
|
+
method_option "followers", :aliases => "-f", :type => :boolean, :default => false, :desc => "Sort by number of followers."
|
655
|
+
method_option "friends", :aliases => "-e", :type => :boolean, :default => false, :desc => "Sort by number of friends."
|
656
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
657
|
+
method_option "listed", :aliases => "-s", :type => :boolean, :default => false, :desc => "Sort by number of list memberships."
|
658
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
659
|
+
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
660
|
+
method_option "posted", :aliases => "-p", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter account was posted."
|
661
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
662
|
+
method_option "tweets", :aliases => "-t", :type => :boolean, :default => false, :desc => "Sort by number of Tweets."
|
663
|
+
method_option "unsorted", :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
|
663
664
|
def suggest(user=nil)
|
664
665
|
if user
|
665
666
|
user = if options['id']
|
@@ -674,11 +675,11 @@ module T
|
|
674
675
|
end
|
675
676
|
|
676
677
|
desc "timeline [USER]", "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets posted by a user."
|
677
|
-
method_option
|
678
|
-
method_option
|
679
|
-
method_option
|
680
|
-
method_option
|
681
|
-
method_option
|
678
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
679
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
680
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
681
|
+
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
682
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
682
683
|
def timeline(user=nil)
|
683
684
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
684
685
|
if user
|
@@ -696,10 +697,10 @@ module T
|
|
696
697
|
map %w(tl) => :timeline
|
697
698
|
|
698
699
|
desc "trends [WOEID]", "Returns the top 10 trending topics."
|
699
|
-
method_option
|
700
|
+
method_option "exclude-hashtags", :aliases => "-x", :type => "boolean", :default => false, :desc => "Remove all hashtags from the trends list."
|
700
701
|
def trends(woe_id=1)
|
701
702
|
opts = {}
|
702
|
-
opts.merge!(:exclude => "hashtags") if options['
|
703
|
+
opts.merge!(:exclude => "hashtags") if options['exclude-hashtags']
|
703
704
|
trends = client.trends(woe_id, opts)
|
704
705
|
if STDOUT.tty?
|
705
706
|
print_in_columns(trends.map(&:name))
|
@@ -711,10 +712,10 @@ module T
|
|
711
712
|
end
|
712
713
|
|
713
714
|
desc "trends_locations", "Returns the locations for which Twitter has trending topic information."
|
714
|
-
method_option
|
715
|
-
method_option
|
716
|
-
method_option
|
717
|
-
method_option
|
715
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
716
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
717
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
718
|
+
method_option "unsorted", :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
|
718
719
|
def trend_locations
|
719
720
|
places = client.trend_locations
|
720
721
|
places = places.sort_by{|places| places.name.downcase} unless options['unsorted']
|
@@ -746,7 +747,7 @@ module T
|
|
746
747
|
map %w(locations trendlocations) => :trend_locations
|
747
748
|
|
748
749
|
desc "unfollow USER [USER...]", "Allows you to stop following users."
|
749
|
-
method_option
|
750
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
750
751
|
def unfollow(user, *users)
|
751
752
|
users.unshift(user)
|
752
753
|
if options['id']
|
@@ -760,35 +761,35 @@ module T
|
|
760
761
|
end
|
761
762
|
end
|
762
763
|
number = users.length
|
763
|
-
say "@#{@rcfile.
|
764
|
+
say "@#{@rcfile.active_profile[0]} is no longer following #{number} #{number == 1 ? 'user' : 'users'}."
|
764
765
|
say
|
765
766
|
say "Run `#{File.basename($0)} follow #{users.map{|user| "@#{user.screen_name}"}.join(' ')}` to follow again."
|
766
767
|
end
|
767
768
|
|
768
769
|
desc "update MESSAGE", "Post a Tweet."
|
769
|
-
method_option
|
770
|
+
method_option "location", :aliases => "-l", :type => :boolean, :default => false
|
770
771
|
def update(message)
|
771
772
|
opts = {:include_entities => false, :trim_user => true}
|
772
773
|
opts.merge!(:lat => location.lat, :long => location.lng) if options['location']
|
773
774
|
status = client.update(message, opts)
|
774
|
-
say "Tweet created by @#{@rcfile.
|
775
|
+
say "Tweet created by @#{@rcfile.active_profile[0]} (#{time_ago_in_words(status.created_at)} ago)."
|
775
776
|
say
|
776
777
|
say "Run `#{File.basename($0)} delete status #{status.id}` to delete."
|
777
778
|
end
|
778
779
|
map %w(post tweet) => :update
|
779
780
|
|
780
781
|
desc "users USER [USER...]", "Returns a list of users you specify."
|
781
|
-
method_option
|
782
|
-
method_option
|
783
|
-
method_option
|
784
|
-
method_option
|
785
|
-
method_option
|
786
|
-
method_option
|
787
|
-
method_option
|
788
|
-
method_option
|
789
|
-
method_option
|
790
|
-
method_option
|
791
|
-
method_option
|
782
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
783
|
+
method_option "favorites", :aliases => "-v", :type => :boolean, :default => false, :desc => "Sort by number of favorites."
|
784
|
+
method_option "followers", :aliases => "-f", :type => :boolean, :default => false, :desc => "Sort by number of followers."
|
785
|
+
method_option "friends", :aliases => "-e", :type => :boolean, :default => false, :desc => "Sort by number of friends."
|
786
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
787
|
+
method_option "listed", :aliases => "-s", :type => :boolean, :default => false, :desc => "Sort by number of list memberships."
|
788
|
+
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
789
|
+
method_option "posted", :aliases => "-p", :type => :boolean, :default => false, :desc => "Sort by the time when Twitter account was posted."
|
790
|
+
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
791
|
+
method_option "tweets", :aliases => "-t", :type => :boolean, :default => false, :desc => "Sort by number of Tweets."
|
792
|
+
method_option "unsorted", :aliases => "-u", :type => :boolean, :default => false, :desc => "Output is not sorted."
|
792
793
|
def users(user, *users)
|
793
794
|
users.unshift(user)
|
794
795
|
if options['id']
|
@@ -808,8 +809,8 @@ module T
|
|
808
809
|
map %w(-v --version) => :version
|
809
810
|
|
810
811
|
desc "whois USER", "Retrieves profile information for the user."
|
811
|
-
method_option
|
812
|
-
method_option
|
812
|
+
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
813
|
+
method_option "id", :aliases => "-i", :type => "boolean", :default => false, :desc => "Specify user via ID instead of screen name."
|
813
814
|
def whois(user)
|
814
815
|
user = if options['id']
|
815
816
|
user.to_i
|
@@ -859,8 +860,8 @@ module T
|
|
859
860
|
|
860
861
|
def consumer
|
861
862
|
OAuth::Consumer.new(
|
862
|
-
options['
|
863
|
-
options['
|
863
|
+
options['consumer-key'],
|
864
|
+
options['consumer-secret'],
|
864
865
|
:site => base_url
|
865
866
|
)
|
866
867
|
end
|