t 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -2
- data/lib/t/cli.rb +43 -36
- data/lib/t/collectable.rb +3 -15
- data/lib/t/delete.rb +9 -4
- data/lib/t/list.rb +11 -6
- data/lib/t/printable.rb +7 -7
- data/lib/t/search.rb +40 -14
- data/lib/t/set.rb +5 -0
- data/lib/t/stream.rb +21 -13
- data/lib/t/utils.rb +16 -0
- data/lib/t/version.rb +1 -1
- data/spec/cli_spec.rb +538 -440
- data/spec/delete_spec.rb +24 -24
- data/spec/fixtures/200_direct_messages.json +27054 -0
- data/spec/fixtures/200_statuses.json +1 -0
- data/spec/fixtures/geo.kml +64 -0
- data/spec/fixtures/geo_no_city.kml +24 -0
- data/spec/fixtures/geo_no_state.kml +16 -0
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search_with_entities.json +1 -0
- data/spec/fixtures/status_no_place.json +72 -0
- data/spec/fixtures/status_with_mention.json +1 -0
- data/spec/fixtures/statuses.json +1 -1
- data/spec/list_spec.rb +94 -100
- data/spec/rcfile_spec.rb +21 -21
- data/spec/search_spec.rb +788 -189
- data/spec/set_spec.rb +19 -19
- data/spec/utils_spec.rb +1 -1
- data/t.gemspec +34 -33
- metadata +22 -5
data/README.md
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
[![Build Status](https://secure.travis-ci.org/sferik/t.png?branch=master)][travis]
|
7
7
|
[![Dependency Status](https://gemnasium.com/sferik/t.png?travis)][gemnasium]
|
8
8
|
[![Pledgie](http://www.pledgie.com/campaigns/17330.png)][pledgie]
|
9
|
+
[![Flattr](http://api.flattr.com/button/flattr-badge-large.png)][flattr]
|
9
10
|
|
10
11
|
#### A command-line power tool for Twitter.
|
11
12
|
|
@@ -15,6 +16,7 @@ offers vastly more commands and capabilities than are available via SMS.
|
|
15
16
|
[travis]: http://travis-ci.org/sferik/t
|
16
17
|
[gemnasium]: https://gemnasium.com/sferik/t
|
17
18
|
[pledgie]: http://www.pledgie.com/campaigns/17330
|
19
|
+
[flattr]: http://flattr.com/thing/815001/sferikt-on-GitHub
|
18
20
|
[sms]: https://support.twitter.com/articles/14020-twitter-sms-command
|
19
21
|
|
20
22
|
## Installation
|
@@ -145,7 +147,7 @@ example, send a user a direct message only if he already follows you:
|
|
145
147
|
t leaders | xargs t unfollow
|
146
148
|
|
147
149
|
#### Unfollow 10 people who haven't tweeted in the longest time
|
148
|
-
t followings -l --sort=
|
150
|
+
t followings -l --sort=tweets | head -10 | awk '{print $1}' | xargs t unfollow
|
149
151
|
|
150
152
|
#### Twitter roulette: randomly follow someone who follows you (who you don't already follow)
|
151
153
|
t groupies | shuf | head -1 | xargs t follow
|
@@ -197,7 +199,7 @@ example, send a user a direct message only if he already follows you:
|
|
197
199
|
|
198
200
|
[search]: https://dev.twitter.com/docs/using-search
|
199
201
|
|
200
|
-
|
202
|
+
## Using T for Backup
|
201
203
|
|
202
204
|
[@jphpsf][jphpsf] wrote a [blog post][blog] explaining how to use `t` to backup
|
203
205
|
your Twitter account.
|
data/lib/t/cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
require 'forwardable'
|
2
3
|
require 'oauth'
|
3
4
|
require 'thor'
|
4
5
|
require 'twitter'
|
@@ -15,23 +16,22 @@ require 't/utils'
|
|
15
16
|
|
16
17
|
module T
|
17
18
|
class CLI < Thor
|
19
|
+
extend Forwardable
|
18
20
|
include T::Collectable
|
19
21
|
include T::Printable
|
20
22
|
include T::Requestable
|
21
23
|
include T::Utils
|
22
24
|
|
23
|
-
DEFAULT_HOST = 'api.twitter.com'
|
24
|
-
DEFAULT_PROTOCOL = 'https'
|
25
25
|
DEFAULT_NUM_RESULTS = 20
|
26
26
|
DIRECT_MESSAGE_HEADINGS = ["ID", "Posted at", "Screen name", "Text"]
|
27
27
|
TREND_HEADINGS = ["WOEID", "Parent ID", "Type", "Name", "Country"]
|
28
28
|
|
29
29
|
check_unknown_options!
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
class_option "host", :aliases => "-H", :type => :string, :default => T::Requestable::DEFAULT_HOST, :desc => "Twitter API server"
|
32
|
+
class_option "no-color", :aliases => "-N", :type => :boolean, :desc => "Disable colorization in output"
|
33
|
+
class_option "no-ssl", :aliases => "-U", :type => :boolean, :default => false, :desc => "Disable SSL"
|
34
|
+
class_option "profile", :aliases => "-P", :type => :string, :default => File.join(File.expand_path("~"), T::RCFile::FILE_NAME), :desc => "Path to RC file", :banner => "FILE"
|
35
35
|
|
36
36
|
def initialize(*)
|
37
37
|
@rcfile = T::RCFile.instance
|
@@ -113,7 +113,7 @@ module T
|
|
113
113
|
end
|
114
114
|
|
115
115
|
desc "block USER [USER...]", "Block users."
|
116
|
-
method_option "id", :aliases => "-i", :type =>
|
116
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
117
117
|
def block(user, *users)
|
118
118
|
users, number = fetch_users(users.unshift(user), options) do |users|
|
119
119
|
client.block(users)
|
@@ -191,7 +191,7 @@ module T
|
|
191
191
|
|
192
192
|
desc "groupies [USER]", "Returns the list of people who follow you but you don't follow back."
|
193
193
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
194
|
-
method_option "id", :aliases => "-i", :type =>
|
194
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
195
195
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
196
196
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
197
197
|
method_option "sort", :aliases => "-s", :type => :string, :enum => %w(favorites followers friends listed screen_name since tweets tweeted), :default => "screen_name", :desc => "Specify the order of the results.", :banner => "ORDER"
|
@@ -225,7 +225,7 @@ module T
|
|
225
225
|
map %w(disciples) => :groupies
|
226
226
|
|
227
227
|
desc "dm USER MESSAGE", "Sends that person a Direct Message."
|
228
|
-
method_option "id", :aliases => "-i", :type =>
|
228
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
229
229
|
def dm(user, message)
|
230
230
|
require 't/core_ext/string'
|
231
231
|
user = if options['id']
|
@@ -239,7 +239,7 @@ module T
|
|
239
239
|
map %w(d m) => :dm
|
240
240
|
|
241
241
|
desc "does_contain [USER/]LIST USER", "Find out whether a list contains a user."
|
242
|
-
method_option "id", :aliases => "-i", :type =>
|
242
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
243
243
|
def does_contain(list, user=nil)
|
244
244
|
owner, list = extract_owner(list, options)
|
245
245
|
if user.nil?
|
@@ -262,7 +262,7 @@ module T
|
|
262
262
|
map %w(dc doescontain) => :does_contain
|
263
263
|
|
264
264
|
desc "does_follow USER [USER]", "Find out whether one user follows another."
|
265
|
-
method_option "id", :aliases => "-i", :type =>
|
265
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
266
266
|
def does_follow(user1, user2=nil)
|
267
267
|
require 't/core_ext/string'
|
268
268
|
user1 = if options['id']
|
@@ -288,7 +288,7 @@ module T
|
|
288
288
|
end
|
289
289
|
map %w(df doesfollow) => :does_follow
|
290
290
|
|
291
|
-
desc "favorite
|
291
|
+
desc "favorite TWEET_ID [TWEET_ID...]", "Marks Tweets as favorites."
|
292
292
|
def favorite(status_id, *status_ids)
|
293
293
|
status_ids.unshift(status_id)
|
294
294
|
status_ids.map!(&:to_i)
|
@@ -305,7 +305,7 @@ module T
|
|
305
305
|
|
306
306
|
desc "favorites [USER]", "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets you favorited."
|
307
307
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
308
|
-
method_option "id", :aliases => "-i", :type =>
|
308
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
309
309
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
310
310
|
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
311
311
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
@@ -327,7 +327,7 @@ module T
|
|
327
327
|
map %w(faves favourites) => :favorites
|
328
328
|
|
329
329
|
desc "follow USER [USER...]", "Allows you to start following users."
|
330
|
-
method_option "id", :aliases => "-i", :type =>
|
330
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
331
331
|
def follow(user, *users)
|
332
332
|
users, number = fetch_users(users.unshift(user), options) do |users|
|
333
333
|
client.follow(users)
|
@@ -339,7 +339,7 @@ module T
|
|
339
339
|
|
340
340
|
desc "followings [USER]", "Returns a list of the people you follow on Twitter."
|
341
341
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
342
|
-
method_option "id", :aliases => "-i", :type =>
|
342
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
343
343
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
344
344
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
345
345
|
method_option "sort", :aliases => "-s", :type => :string, :enum => %w(favorites followers friends listed screen_name since tweets tweeted), :default => "screen_name", :desc => "Specify the order of the results.", :banner => "ORDER"
|
@@ -365,7 +365,7 @@ module T
|
|
365
365
|
|
366
366
|
desc "followers [USER]", "Returns a list of the people who follow you on Twitter."
|
367
367
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
368
|
-
method_option "id", :aliases => "-i", :type =>
|
368
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
369
369
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
370
370
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
371
371
|
method_option "sort", :aliases => "-s", :type => :string, :enum => %w(favorites followers friends listed screen_name since tweets tweeted), :default => "screen_name", :desc => "Specify the order of the results.", :banner => "ORDER"
|
@@ -391,7 +391,7 @@ module T
|
|
391
391
|
|
392
392
|
desc "friends [USER]", "Returns the list of people who you follow and follow you back."
|
393
393
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
394
|
-
method_option "id", :aliases => "-i", :type =>
|
394
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
395
395
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
396
396
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
397
397
|
method_option "sort", :aliases => "-s", :type => :string, :enum => %w(favorites followers friends listed screen_name since tweets tweeted), :default => "screen_name", :desc => "Specify the order of the results.", :banner => "ORDER"
|
@@ -425,7 +425,7 @@ module T
|
|
425
425
|
|
426
426
|
desc "leaders [USER]", "Returns the list of people who you follow but don't follow you back."
|
427
427
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
428
|
-
method_option "id", :aliases => "-i", :type =>
|
428
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
429
429
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
430
430
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
431
431
|
method_option "sort", :aliases => "-s", :type => :string, :enum => %w(favorites followers friends listed screen_name since tweets tweeted), :default => "screen_name", :desc => "Specify the order of the results.", :banner => "ORDER"
|
@@ -459,7 +459,7 @@ module T
|
|
459
459
|
|
460
460
|
desc "lists [USER]", "Returns the lists created by a user."
|
461
461
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
462
|
-
method_option "id", :aliases => "-i", :type =>
|
462
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
463
463
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
464
464
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
465
465
|
method_option "sort", :aliases => "-s", :type => :string, :enum => %w(members mode posted slug subscribers), :default => "slug", :desc => "Specify the order of the results.", :banner => "ORDER"
|
@@ -480,9 +480,7 @@ module T
|
|
480
480
|
end
|
481
481
|
|
482
482
|
desc "matrix", "Unfortunately, no one can be told what the Matrix is. You have to see it for yourself."
|
483
|
-
|
484
|
-
T::Stream.new.matrix
|
485
|
-
end
|
483
|
+
def_delegator :"T::Stream.new", :matrix
|
486
484
|
|
487
485
|
desc "mentions", "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets mentioning you."
|
488
486
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
@@ -500,7 +498,7 @@ module T
|
|
500
498
|
|
501
499
|
desc "open USER", "Opens that user's profile in a web browser."
|
502
500
|
method_option "display-url", :aliases => "-d", :type => :boolean, :default => false, :desc => "Display the requested URL instead of attempting to open it."
|
503
|
-
method_option "id", :aliases => "-i", :type =>
|
501
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
504
502
|
method_option "status", :aliases => "-s", :type => :boolean, :default => false, :desc => "Specify input as a Twitter status ID instead of a screen name."
|
505
503
|
def open(user)
|
506
504
|
require 'launchy'
|
@@ -516,8 +514,8 @@ module T
|
|
516
514
|
end
|
517
515
|
end
|
518
516
|
|
519
|
-
desc "reply
|
520
|
-
method_option "all", :aliases => "-a", :type =>
|
517
|
+
desc "reply TWEET_ID MESSAGE", "Post your Tweet as a reply directed at another person."
|
518
|
+
method_option "all", :aliases => "-a", :type => :boolean, :default => false, :desc => "Reply to all users mentioned in the Tweet."
|
521
519
|
method_option "location", :aliases => "-l", :type => :boolean, :default => false
|
522
520
|
def reply(status_id, message)
|
523
521
|
status = client.status(status_id.to_i, :include_my_retweet => false)
|
@@ -537,7 +535,7 @@ module T
|
|
537
535
|
end
|
538
536
|
|
539
537
|
desc "report_spam USER [USER...]", "Report users for spam."
|
540
|
-
method_option "id", :aliases => "-i", :type =>
|
538
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
541
539
|
def report_spam(user, *users)
|
542
540
|
users, number = fetch_users(users.unshift(user), options) do |users|
|
543
541
|
client.report_spam(users)
|
@@ -546,7 +544,7 @@ module T
|
|
546
544
|
end
|
547
545
|
map %w(report reportspam spam) => :report_spam
|
548
546
|
|
549
|
-
desc "retweet
|
547
|
+
desc "retweet TWEET_ID [TWEET_ID...]", "Sends Tweets to your followers."
|
550
548
|
def retweet(status_id, *status_ids)
|
551
549
|
status_ids.unshift(status_id)
|
552
550
|
status_ids.map!(&:to_i)
|
@@ -563,7 +561,7 @@ module T
|
|
563
561
|
|
564
562
|
desc "retweets [USER]", "Returns the #{DEFAULT_NUM_RESULTS} most recent Retweets by a user."
|
565
563
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
566
|
-
method_option "id", :aliases => "-i", :type =>
|
564
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
567
565
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
568
566
|
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
569
567
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
@@ -594,7 +592,7 @@ module T
|
|
594
592
|
say "#{' ' * options['indent'].to_i}----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|"
|
595
593
|
end
|
596
594
|
|
597
|
-
desc "status
|
595
|
+
desc "status TWEET_ID", "Retrieves detailed information about a Tweet."
|
598
596
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
599
597
|
def status(status_id)
|
600
598
|
status = client.status(status_id.to_i, :include_my_retweet => false)
|
@@ -640,12 +638,21 @@ module T
|
|
640
638
|
|
641
639
|
desc "timeline [USER]", "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets posted by a user."
|
642
640
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
643
|
-
method_option "
|
641
|
+
method_option "exclude", :aliases => "-e", :type => :string, :enum => %w(replies retweets), :desc => "Exclude certain types of Tweets from the results.", :banner => "TYPE"
|
642
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
644
643
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
645
644
|
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
646
645
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
647
646
|
def timeline(user=nil)
|
648
647
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
648
|
+
exclude_opts = case options['exclude']
|
649
|
+
when 'replies'
|
650
|
+
{:exclude_replies => true}
|
651
|
+
when 'retweets'
|
652
|
+
{:include_rts => false}
|
653
|
+
else
|
654
|
+
{}
|
655
|
+
end
|
649
656
|
if user
|
650
657
|
require 't/core_ext/string'
|
651
658
|
user = if options['id']
|
@@ -654,11 +661,11 @@ module T
|
|
654
661
|
user.strip_ats
|
655
662
|
end
|
656
663
|
tweets = collect_with_count(count) do |opts|
|
657
|
-
client.user_timeline(user, opts)
|
664
|
+
client.user_timeline(user, opts.merge(exclude_opts))
|
658
665
|
end
|
659
666
|
else
|
660
667
|
tweets = collect_with_count(count) do |opts|
|
661
|
-
client.home_timeline(opts)
|
668
|
+
client.home_timeline(opts.merge(exclude_opts))
|
662
669
|
end
|
663
670
|
end
|
664
671
|
print_tweets(tweets)
|
@@ -666,7 +673,7 @@ module T
|
|
666
673
|
map %w(tl) => :timeline
|
667
674
|
|
668
675
|
desc "trends [WOEID]", "Returns the top 10 trending topics."
|
669
|
-
method_option "exclude-hashtags", :aliases => "-x", :type =>
|
676
|
+
method_option "exclude-hashtags", :aliases => "-x", :type => :boolean, :default => false, :desc => "Remove all hashtags from the trends list."
|
670
677
|
def trends(woe_id=1)
|
671
678
|
opts = {}
|
672
679
|
opts.merge!(:exclude => "hashtags") if options['exclude-hashtags']
|
@@ -715,7 +722,7 @@ module T
|
|
715
722
|
map %w(locations trendlocations) => :trend_locations
|
716
723
|
|
717
724
|
desc "unfollow USER [USER...]", "Allows you to stop following users."
|
718
|
-
method_option "id", :aliases => "-i", :type =>
|
725
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
719
726
|
def unfollow(user, *users)
|
720
727
|
users, number = fetch_users(users.unshift(user), options) do |users|
|
721
728
|
client.unfollow(users)
|
@@ -744,7 +751,7 @@ module T
|
|
744
751
|
|
745
752
|
desc "users USER [USER...]", "Returns a list of users you specify."
|
746
753
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
747
|
-
method_option "id", :aliases => "-i", :type =>
|
754
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
748
755
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
749
756
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
750
757
|
method_option "sort", :aliases => "-s", :type => :string, :enum => %w(favorites followers friends listed screen_name since tweets tweeted), :default => "screen_name", :desc => "Specify the order of the results.", :banner => "ORDER"
|
@@ -771,7 +778,7 @@ module T
|
|
771
778
|
|
772
779
|
desc "whois USER", "Retrieves profile information for the user."
|
773
780
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
774
|
-
method_option "id", :aliases => "-i", :type =>
|
781
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
775
782
|
def whois(user)
|
776
783
|
require 't/core_ext/string'
|
777
784
|
user = if options['id']
|
data/lib/t/collectable.rb
CHANGED
@@ -6,10 +6,6 @@ module T
|
|
6
6
|
|
7
7
|
MAX_NUM_RESULTS = 200
|
8
8
|
|
9
|
-
def collect_with_count(count, &block)
|
10
|
-
collect_with_number(count, :count, &block)
|
11
|
-
end
|
12
|
-
|
13
9
|
def collect_with_cursor(collection=[], cursor=-1, &block)
|
14
10
|
object = retryable(:tries => 3, :on => Twitter::Error::ServerError, :sleep => 0) do
|
15
11
|
yield(cursor)
|
@@ -27,12 +23,12 @@ module T
|
|
27
23
|
tweets.empty? ? collection.flatten : collect_with_max_id(collection, tweets.last.id - 1, &block)
|
28
24
|
end
|
29
25
|
|
30
|
-
def
|
26
|
+
def collect_with_count(number, &block)
|
31
27
|
opts = {}
|
32
|
-
opts[
|
28
|
+
opts[:count] = MAX_NUM_RESULTS
|
33
29
|
collect_with_max_id do |max_id|
|
34
30
|
opts[:max_id] = max_id unless max_id.nil?
|
35
|
-
opts[
|
31
|
+
opts[:count] = number unless number >= MAX_NUM_RESULTS
|
36
32
|
if number > 0
|
37
33
|
tweets = yield opts
|
38
34
|
number -= tweets.length
|
@@ -41,14 +37,6 @@ module T
|
|
41
37
|
end.flatten.compact
|
42
38
|
end
|
43
39
|
|
44
|
-
def collect_with_per_page(per_page, &block)
|
45
|
-
collect_with_number(per_page, :per_page, &block)
|
46
|
-
end
|
47
|
-
|
48
|
-
def collect_with_rpp(rpp, &block)
|
49
|
-
collect_with_number(rpp, :rpp, &block)
|
50
|
-
end
|
51
|
-
|
52
40
|
def collect_with_page(collection=[], page=1, &block)
|
53
41
|
tweets = retryable(:tries => 3, :on => Twitter::Error::ServerError, :sleep => 0) do
|
54
42
|
yield page
|
data/lib/t/delete.rb
CHANGED
@@ -11,13 +11,18 @@ module T
|
|
11
11
|
|
12
12
|
check_unknown_options!
|
13
13
|
|
14
|
+
class_option "host", :aliases => "-H", :type => :string, :default => T::Requestable::DEFAULT_HOST, :desc => "Twitter API server"
|
15
|
+
class_option "no-color", :aliases => "-N", :type => :boolean, :desc => "Disable colorization in output"
|
16
|
+
class_option "no-ssl", :aliases => "-U", :type => :boolean, :default => false, :desc => "Disable SSL"
|
17
|
+
class_option "profile", :aliases => "-P", :type => :string, :default => File.join(File.expand_path("~"), T::RCFile::FILE_NAME), :desc => "Path to RC file", :banner => "FILE"
|
18
|
+
|
14
19
|
def initialize(*)
|
15
20
|
@rcfile = T::RCFile.instance
|
16
21
|
super
|
17
22
|
end
|
18
23
|
|
19
24
|
desc "block USER [USER...]", "Unblock users."
|
20
|
-
method_option "id", :aliases => "-i", :type =>
|
25
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
21
26
|
method_option "force", :aliases => "-f", :type => :boolean, :default => false
|
22
27
|
def block(user, *users)
|
23
28
|
users, number = fetch_users(users.unshift(user), options) do |users|
|
@@ -51,7 +56,7 @@ module T
|
|
51
56
|
end
|
52
57
|
map %w(d m) => :dm
|
53
58
|
|
54
|
-
desc "favorite
|
59
|
+
desc "favorite TWEET_ID [TWEET_ID...]", "Delete favorites."
|
55
60
|
method_option "force", :aliases => "-f", :type => :boolean, :default => false
|
56
61
|
def favorite(status_id, *status_ids)
|
57
62
|
status_ids.unshift(status_id)
|
@@ -75,7 +80,7 @@ module T
|
|
75
80
|
|
76
81
|
desc "list LIST", "Delete a list."
|
77
82
|
method_option "force", :aliases => "-f", :type => :boolean, :default => false
|
78
|
-
method_option "id", :aliases => "-i", :type =>
|
83
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify list via ID instead of slug."
|
79
84
|
def list(list)
|
80
85
|
if options['id']
|
81
86
|
require 't/core_ext/string'
|
@@ -89,7 +94,7 @@ module T
|
|
89
94
|
say "@#{@rcfile.active_profile[0]} deleted the list \"#{list.name}\"."
|
90
95
|
end
|
91
96
|
|
92
|
-
desc "status
|
97
|
+
desc "status TWEET_ID [TWEET_ID...]", "Delete Tweets."
|
93
98
|
method_option "force", :aliases => "-f", :type => :boolean, :default => false
|
94
99
|
def status(status_id, *status_ids)
|
95
100
|
status_ids.unshift(status_id)
|
data/lib/t/list.rb
CHANGED
@@ -19,13 +19,18 @@ module T
|
|
19
19
|
|
20
20
|
check_unknown_options!
|
21
21
|
|
22
|
+
class_option "host", :aliases => "-H", :type => :string, :default => T::Requestable::DEFAULT_HOST, :desc => "Twitter API server"
|
23
|
+
class_option "no-color", :aliases => "-N", :type => :boolean, :desc => "Disable colorization in output"
|
24
|
+
class_option "no-ssl", :aliases => "-U", :type => :boolean, :default => false, :desc => "Disable SSL"
|
25
|
+
class_option "profile", :aliases => "-P", :type => :string, :default => File.join(File.expand_path("~"), T::RCFile::FILE_NAME), :desc => "Path to RC file", :banner => "FILE"
|
26
|
+
|
22
27
|
def initialize(*)
|
23
28
|
@rcfile = T::RCFile.instance
|
24
29
|
super
|
25
30
|
end
|
26
31
|
|
27
32
|
desc "add LIST USER [USER...]", "Add members to a list."
|
28
|
-
method_option "id", :aliases => "-i", :type =>
|
33
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
29
34
|
def add(list, user, *users)
|
30
35
|
users, number = fetch_users(users.unshift(user), options) do |users|
|
31
36
|
client.list_add_members(list, users)
|
@@ -78,7 +83,7 @@ module T
|
|
78
83
|
|
79
84
|
desc "members [USER/]LIST", "Returns the members of a Twitter list."
|
80
85
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
81
|
-
method_option "id", :aliases => "-i", :type =>
|
86
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
82
87
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
83
88
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
84
89
|
method_option "sort", :aliases => "-s", :type => :string, :enum => %w(favorites followers friends listed screen_name since tweets tweeted), :default => "screen_name", :desc => "Specify the order of the results.", :banner => "ORDER"
|
@@ -92,7 +97,7 @@ module T
|
|
92
97
|
end
|
93
98
|
|
94
99
|
desc "remove LIST USER [USER...]", "Remove members from a list."
|
95
|
-
method_option "id", :aliases => "-i", :type =>
|
100
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify input as Twitter user IDs instead of screen names."
|
96
101
|
def remove(list, user, *users)
|
97
102
|
users, number = fetch_users(users.unshift(user), options) do |users|
|
98
103
|
client.list_remove_members(list, users)
|
@@ -109,14 +114,14 @@ module T
|
|
109
114
|
|
110
115
|
desc "timeline [USER/]LIST", "Show tweet timeline for members of the specified list."
|
111
116
|
method_option "csv", :aliases => "-c", :type => :boolean, :default => false, :desc => "Output in CSV format."
|
112
|
-
method_option "id", :aliases => "-i", :type =>
|
117
|
+
method_option "id", :aliases => "-i", :type => :boolean, :default => false, :desc => "Specify user via ID instead of screen name."
|
113
118
|
method_option "long", :aliases => "-l", :type => :boolean, :default => false, :desc => "Output in long format."
|
114
119
|
method_option "number", :aliases => "-n", :type => :numeric, :default => DEFAULT_NUM_RESULTS, :desc => "Limit the number of results."
|
115
120
|
method_option "reverse", :aliases => "-r", :type => :boolean, :default => false, :desc => "Reverse the order of the sort."
|
116
121
|
def timeline(list)
|
117
122
|
owner, list = extract_owner(list, options)
|
118
|
-
|
119
|
-
tweets =
|
123
|
+
count = options['number'] || DEFAULT_NUM_RESULTS
|
124
|
+
tweets = collect_with_count(count) do |opts|
|
120
125
|
client.list_timeline(owner, list, opts)
|
121
126
|
end
|
122
127
|
print_tweets(tweets)
|