t 2.8.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -1
- data/LICENSE.md +1 -1
- data/README.md +3 -2
- data/bin/t +1 -1
- data/lib/t.rb +2 -1
- data/lib/t/cli.rb +219 -215
- data/lib/t/collectable.rb +2 -2
- data/lib/t/delete.rb +28 -16
- data/lib/t/identicon.rb +49 -0
- data/lib/t/list.rb +21 -21
- data/lib/t/printable.rb +41 -3
- data/lib/t/rcfile.rb +10 -0
- data/lib/t/search.rb +49 -49
- data/lib/t/set.rb +10 -10
- data/lib/t/stream.rb +33 -33
- data/lib/t/utils.rb +1 -1
- data/lib/t/version.rb +1 -1
- data/t.gemspec +7 -8
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abfdf14a94b1051279ded1673b41f3ac9bebf0b9
|
4
|
+
data.tar.gz: b698c0a8e8f02fee6a8731cc92f215ba4889e1c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d72e7b4becf49eb70f035a7b942ccf3b0e31d128f8a1ca8c807c019b23afcb2aefa4e0743b63d02cde3b2dd1549d67ddc3581b60b30d104fc88c71a4edb822e
|
7
|
+
data.tar.gz: 9d064b925bd0ca951cce9c94350f456ff20beef4386b4575e900384127f90145e0164a62153fa40c9c4f059f937a56112bd5a783ab83fb72235be9cbec93a570
|
data/CONTRIBUTING.md
CHANGED
@@ -44,5 +44,5 @@ Ideally, a bug report should include a pull request with failing specs.
|
|
44
44
|
9. [Submit a pull request.][pr]
|
45
45
|
|
46
46
|
[fork]: http://help.github.com/fork-a-repo/
|
47
|
-
[branch]: http://
|
47
|
+
[branch]: http://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
|
48
48
|
[pr]: http://help.github.com/send-pull-requests/
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -286,7 +286,8 @@ implementations:
|
|
286
286
|
|
287
287
|
* Ruby 1.9.3
|
288
288
|
* Ruby 2.0.0
|
289
|
-
* Ruby 2.1
|
289
|
+
* Ruby 2.1
|
290
|
+
* Ruby 2.2
|
290
291
|
|
291
292
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
292
293
|
|
@@ -307,7 +308,7 @@ If you are running t on a remote computer you can use the flag --display-uri dur
|
|
307
308
|
t authorize --display-uri
|
308
309
|
|
309
310
|
## Copyright
|
310
|
-
Copyright (c) 2011-
|
311
|
+
Copyright (c) 2011-2015 Erik Michaels-Ober. See [LICENSE][] for details.
|
311
312
|
Application icon by [@nvk][nvk].
|
312
313
|
|
313
314
|
[license]: https://github.com/sferik/t/blob/master/LICENSE.md
|
data/bin/t
CHANGED
@@ -31,7 +31,7 @@ rescue Twitter::Error::BadRequest => error
|
|
31
31
|
'Run `t authorize` to authorize.'
|
32
32
|
rescue Twitter::Error::Forbidden, Twitter::Error::Unauthorized => error
|
33
33
|
if error.message == 'Error processing your OAuth request: Read-only application cannot POST' ||
|
34
|
-
|
34
|
+
error.message == 'This application is not allowed to access or delete your direct messages'
|
35
35
|
$stderr.puts(%q(Make sure to set your Twitter application's Access Level to "Read, Write and Access direct messages".))
|
36
36
|
require 'thor'
|
37
37
|
Thor::Shell::Basic.new.ask 'Press [Enter] to open the Twitter Developer site.'
|
data/lib/t.rb
CHANGED
@@ -5,7 +5,8 @@ module T
|
|
5
5
|
class << self
|
6
6
|
# Convert time to local time by applying the `utc_offset` setting.
|
7
7
|
def local_time(time)
|
8
|
-
|
8
|
+
time = time.dup
|
9
|
+
utc_offset ? (time.utc + utc_offset) : time.localtime
|
9
10
|
end
|
10
11
|
|
11
12
|
# UTC offset in seconds to apply time instances before displaying.
|
data/lib/t/cli.rb
CHANGED
@@ -30,8 +30,8 @@ module T
|
|
30
30
|
|
31
31
|
check_unknown_options!
|
32
32
|
|
33
|
-
class_option 'color', :
|
34
|
-
class_option 'profile', :
|
33
|
+
class_option 'color', aliases: '-C', type: :string, enum: %w(icon auto never), default: 'auto', desc: 'Control how color is used in output'
|
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
|
@@ -50,7 +50,7 @@ module T
|
|
50
50
|
end
|
51
51
|
|
52
52
|
desc 'authorize', 'Allows an application to request user authorization'
|
53
|
-
method_option 'display-uri', :
|
53
|
+
method_option 'display-uri', aliases: '-d', type: :boolean, desc: 'Display the authorization URL instead of attempting to open it.'
|
54
54
|
def authorize
|
55
55
|
@rcfile.path = options['profile'] if options['profile']
|
56
56
|
if @rcfile.empty?
|
@@ -78,10 +78,10 @@ module T
|
|
78
78
|
say
|
79
79
|
end
|
80
80
|
require 'launchy'
|
81
|
-
open_or_print('https://apps.twitter.com', :
|
81
|
+
open_or_print('https://apps.twitter.com', dry_run: options['display-uri'])
|
82
82
|
key = ask 'Enter your API key:'
|
83
83
|
secret = ask 'Enter your API secret:'
|
84
|
-
consumer = OAuth::Consumer.new(key, secret, :
|
84
|
+
consumer = OAuth::Consumer.new(key, secret, site: Twitter::REST::Client::BASE_URL)
|
85
85
|
request_token = consumer.get_request_token
|
86
86
|
uri = generate_authorize_uri(consumer, request_token)
|
87
87
|
say
|
@@ -93,9 +93,9 @@ module T
|
|
93
93
|
say
|
94
94
|
ask 'Press [Enter] to open the Twitter app authorization page.'
|
95
95
|
say
|
96
|
-
open_or_print(uri, :
|
96
|
+
open_or_print(uri, dry_run: options['display-uri'])
|
97
97
|
pin = ask 'Enter the supplied PIN:'
|
98
|
-
access_token = request_token.get_access_token(:
|
98
|
+
access_token = request_token.get_access_token(oauth_verifier: pin.chomp)
|
99
99
|
oauth_response = access_token.get('/1.1/account/verify_credentials.json?skip_status=true')
|
100
100
|
screen_name = oauth_response.body.match(/"screen_name"\s*:\s*"(.*?)"/).captures.first
|
101
101
|
@rcfile[screen_name] = {
|
@@ -105,14 +105,14 @@ module T
|
|
105
105
|
'consumer_secret' => secret,
|
106
106
|
'token' => access_token.token,
|
107
107
|
'secret' => access_token.secret,
|
108
|
-
}
|
108
|
+
},
|
109
109
|
}
|
110
110
|
@rcfile.active_profile = {'username' => screen_name, 'consumer_key' => key}
|
111
111
|
say 'Authorization successful.'
|
112
112
|
end
|
113
113
|
|
114
114
|
desc 'block USER [USER...]', 'Block users.'
|
115
|
-
method_option 'id', :
|
115
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
116
116
|
def block(user, *users)
|
117
117
|
blocked_users, number = fetch_users(users.unshift(user), options) do |users_to_block|
|
118
118
|
client.block(users_to_block)
|
@@ -123,12 +123,12 @@ module T
|
|
123
123
|
end
|
124
124
|
|
125
125
|
desc 'direct_messages', "Returns the #{DEFAULT_NUM_RESULTS} most recent Direct Messages sent to you."
|
126
|
-
method_option 'csv', :
|
127
|
-
method_option 'decode_uris', :
|
128
|
-
method_option 'long', :
|
129
|
-
method_option 'number', :
|
130
|
-
method_option 'relative_dates', :
|
131
|
-
method_option 'reverse', :
|
126
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
127
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
128
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
129
|
+
method_option 'number', aliases: '-n', type: :numeric, default: DEFAULT_NUM_RESULTS, desc: 'Limit the number of results.'
|
130
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
131
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
132
132
|
def direct_messages
|
133
133
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
134
134
|
opts = {}
|
@@ -155,15 +155,15 @@ module T
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
end
|
158
|
-
map %w
|
158
|
+
map %w(directmessages dms) => :direct_messages
|
159
159
|
|
160
160
|
desc 'direct_messages_sent', "Returns the #{DEFAULT_NUM_RESULTS} most recent Direct Messages you've sent."
|
161
|
-
method_option 'csv', :
|
162
|
-
method_option 'decode_uris', :
|
163
|
-
method_option 'long', :
|
164
|
-
method_option 'number', :
|
165
|
-
method_option 'relative_dates', :
|
166
|
-
method_option 'reverse', :
|
161
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
162
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
163
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
164
|
+
method_option 'number', aliases: '-n', type: :numeric, default: DEFAULT_NUM_RESULTS, desc: 'Limit the number of results.'
|
165
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
166
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
167
167
|
def direct_messages_sent
|
168
168
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
169
169
|
opts = {}
|
@@ -190,20 +190,20 @@ module T
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end
|
193
|
-
map %w
|
193
|
+
map %w(directmessagessent sent_messages sentmessages sms) => :direct_messages_sent
|
194
194
|
|
195
195
|
desc 'dm USER MESSAGE', 'Sends that person a Direct Message.'
|
196
|
-
method_option 'id', :
|
196
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
197
197
|
def dm(user, message)
|
198
198
|
require 't/core_ext/string'
|
199
199
|
user = options['id'] ? user.to_i : user.strip_ats
|
200
200
|
direct_message = client.create_direct_message(user, message)
|
201
201
|
say "Direct Message sent from @#{@rcfile.active_profile[0]} to @#{direct_message.recipient.screen_name}."
|
202
202
|
end
|
203
|
-
map %w
|
203
|
+
map %w(d m) => :dm
|
204
204
|
|
205
205
|
desc 'does_contain [USER/]LIST USER', 'Find out whether a list contains a user.'
|
206
|
-
method_option 'id', :
|
206
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
207
207
|
def does_contain(user_list, user = nil)
|
208
208
|
owner, list_name = extract_owner(user_list, options)
|
209
209
|
if user.nil?
|
@@ -218,10 +218,10 @@ module T
|
|
218
218
|
abort "No, #{list_name} does not contain @#{user}."
|
219
219
|
end
|
220
220
|
end
|
221
|
-
map %w
|
221
|
+
map %w(dc doescontain) => :does_contain
|
222
222
|
|
223
223
|
desc 'does_follow USER [USER]', 'Find out whether one user follows another.'
|
224
|
-
method_option 'id', :
|
224
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
225
225
|
def does_follow(user1, user2 = nil)
|
226
226
|
abort 'No, you are not following yourself.' if user2.nil? && user1 == @rcfile.active_profile[0].downcase
|
227
227
|
abort "No, @#{user1} is not following themself." if user1 == user2
|
@@ -247,14 +247,14 @@ module T
|
|
247
247
|
abort "No, @#{user1} does not follow @#{user2}."
|
248
248
|
end
|
249
249
|
end
|
250
|
-
map %w
|
250
|
+
map %w(df doesfollow) => :does_follow
|
251
251
|
|
252
252
|
desc 'favorite TWEET_ID [TWEET_ID...]', 'Marks Tweets as favorites.'
|
253
253
|
def favorite(status_id, *status_ids)
|
254
254
|
status_ids.unshift(status_id)
|
255
255
|
status_ids.collect!(&:to_i)
|
256
256
|
require 'retryable'
|
257
|
-
favorites = retryable(:
|
257
|
+
favorites = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
258
258
|
client.favorite(status_ids)
|
259
259
|
end
|
260
260
|
number = favorites.length
|
@@ -262,18 +262,18 @@ module T
|
|
262
262
|
say
|
263
263
|
say "Run `#{File.basename($PROGRAM_NAME)} delete favorite #{status_ids.join(' ')}` to unfavorite."
|
264
264
|
end
|
265
|
-
map %w
|
265
|
+
map %w(fave favourite) => :favorite
|
266
266
|
|
267
267
|
desc 'favorites [USER]', "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets you favorited."
|
268
|
-
method_option 'csv', :
|
269
|
-
method_option 'decode_uris', :
|
270
|
-
method_option 'id', :
|
271
|
-
method_option 'long', :
|
272
|
-
method_option 'max_id', :
|
273
|
-
method_option 'number', :
|
274
|
-
method_option 'relative_dates', :
|
275
|
-
method_option 'reverse', :
|
276
|
-
method_option 'since_id', :
|
268
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
269
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
270
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
271
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
272
|
+
method_option 'max_id', aliases: '-m', type: :numeric, desc: 'Returns only the results with an ID less than the specified ID.'
|
273
|
+
method_option 'number', aliases: '-n', type: :numeric, default: DEFAULT_NUM_RESULTS, desc: 'Limit the number of results.'
|
274
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
275
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
276
|
+
method_option 'since_id', aliases: '-s', type: :numeric, desc: 'Returns only the results with an ID greater than the specified ID.'
|
277
277
|
def favorites(user = nil)
|
278
278
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
279
279
|
opts = {}
|
@@ -291,10 +291,10 @@ module T
|
|
291
291
|
end
|
292
292
|
print_tweets(tweets)
|
293
293
|
end
|
294
|
-
map %w
|
294
|
+
map %w(faves favourites) => :favorites
|
295
295
|
|
296
296
|
desc 'follow USER [USER...]', 'Allows you to start following users.'
|
297
|
-
method_option 'id', :
|
297
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
298
298
|
def follow(user, *users)
|
299
299
|
followed_users, number = fetch_users(users.unshift(user), options) do |users_to_follow|
|
300
300
|
client.follow(users_to_follow)
|
@@ -305,13 +305,13 @@ module T
|
|
305
305
|
end
|
306
306
|
|
307
307
|
desc 'followings [USER]', 'Returns a list of the people you follow on Twitter.'
|
308
|
-
method_option 'csv', :
|
309
|
-
method_option 'id', :
|
310
|
-
method_option 'long', :
|
311
|
-
method_option 'relative_dates', :
|
312
|
-
method_option 'reverse', :
|
313
|
-
method_option 'sort', :
|
314
|
-
method_option 'unsorted', :
|
308
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
309
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
310
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
311
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
312
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
313
|
+
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'
|
314
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
315
315
|
def followings(user = nil)
|
316
316
|
if user
|
317
317
|
require 't/core_ext/string'
|
@@ -319,20 +319,20 @@ module T
|
|
319
319
|
end
|
320
320
|
following_ids = client.friend_ids(user).to_a
|
321
321
|
require 'retryable'
|
322
|
-
users = retryable(:
|
322
|
+
users = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
323
323
|
client.users(following_ids)
|
324
324
|
end
|
325
325
|
print_users(users)
|
326
326
|
end
|
327
327
|
|
328
328
|
desc 'followings_following USER [USER]', 'Displays your friends who follow the specified user.'
|
329
|
-
method_option 'csv', :
|
330
|
-
method_option 'id', :
|
331
|
-
method_option 'long', :
|
332
|
-
method_option 'relative_dates', :
|
333
|
-
method_option 'reverse', :
|
334
|
-
method_option 'sort', :
|
335
|
-
method_option 'unsorted', :
|
329
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
330
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
331
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
332
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
333
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
334
|
+
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'
|
335
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
336
336
|
def followings_following(user1, user2 = nil)
|
337
337
|
require 't/core_ext/string'
|
338
338
|
user1 = options['id'] ? user1.to_i : user1.strip_ats
|
@@ -345,21 +345,21 @@ module T
|
|
345
345
|
following_ids = Thread.new { client.friend_ids(user2).to_a }
|
346
346
|
followings_following_ids = follower_ids.value & following_ids.value
|
347
347
|
require 'retryable'
|
348
|
-
users = retryable(:
|
348
|
+
users = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
349
349
|
client.users(followings_following_ids)
|
350
350
|
end
|
351
351
|
print_users(users)
|
352
352
|
end
|
353
|
-
map %w
|
353
|
+
map %w(ff followingsfollowing) => :followings_following
|
354
354
|
|
355
355
|
desc 'followers [USER]', 'Returns a list of the people who follow you on Twitter.'
|
356
|
-
method_option 'csv', :
|
357
|
-
method_option 'id', :
|
358
|
-
method_option 'long', :
|
359
|
-
method_option 'relative_dates', :
|
360
|
-
method_option 'reverse', :
|
361
|
-
method_option 'sort', :
|
362
|
-
method_option 'unsorted', :
|
356
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
357
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
358
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
359
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
360
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
361
|
+
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'
|
362
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
363
363
|
def followers(user = nil)
|
364
364
|
if user
|
365
365
|
require 't/core_ext/string'
|
@@ -367,20 +367,20 @@ module T
|
|
367
367
|
end
|
368
368
|
follower_ids = client.follower_ids(user).to_a
|
369
369
|
require 'retryable'
|
370
|
-
users = retryable(:
|
370
|
+
users = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
371
371
|
client.users(follower_ids)
|
372
372
|
end
|
373
373
|
print_users(users)
|
374
374
|
end
|
375
375
|
|
376
376
|
desc 'friends [USER]', 'Returns the list of people who you follow and follow you back.'
|
377
|
-
method_option 'csv', :
|
378
|
-
method_option 'id', :
|
379
|
-
method_option 'long', :
|
380
|
-
method_option 'relative_dates', :
|
381
|
-
method_option 'reverse', :
|
382
|
-
method_option 'sort', :
|
383
|
-
method_option 'unsorted', :
|
377
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
378
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
379
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
380
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
381
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
382
|
+
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'
|
383
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
384
384
|
def friends(user = nil)
|
385
385
|
user = if user
|
386
386
|
require 't/core_ext/string'
|
@@ -392,20 +392,20 @@ module T
|
|
392
392
|
follower_ids = Thread.new { client.follower_ids(user).to_a }
|
393
393
|
friend_ids = following_ids.value & follower_ids.value
|
394
394
|
require 'retryable'
|
395
|
-
users = retryable(:
|
395
|
+
users = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
396
396
|
client.users(friend_ids)
|
397
397
|
end
|
398
398
|
print_users(users)
|
399
399
|
end
|
400
400
|
|
401
401
|
desc 'groupies [USER]', "Returns the list of people who follow you but you don't follow back."
|
402
|
-
method_option 'csv', :
|
403
|
-
method_option 'id', :
|
404
|
-
method_option 'long', :
|
405
|
-
method_option 'relative_dates', :
|
406
|
-
method_option 'reverse', :
|
407
|
-
method_option 'sort', :
|
408
|
-
method_option 'unsorted', :
|
402
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
403
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
404
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
405
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
406
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
407
|
+
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'
|
408
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
409
409
|
def groupies(user = nil)
|
410
410
|
user = if user
|
411
411
|
require 't/core_ext/string'
|
@@ -417,22 +417,22 @@ module T
|
|
417
417
|
following_ids = Thread.new { client.friend_ids(user).to_a }
|
418
418
|
groupie_ids = (follower_ids.value - following_ids.value)
|
419
419
|
require 'retryable'
|
420
|
-
users = retryable(:
|
420
|
+
users = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
421
421
|
client.users(groupie_ids)
|
422
422
|
end
|
423
423
|
print_users(users)
|
424
424
|
end
|
425
|
-
map %w
|
425
|
+
map %w(disciples) => :groupies
|
426
426
|
|
427
427
|
desc 'intersection USER [USER...]', 'Displays the intersection of users followed by the specified users.'
|
428
|
-
method_option 'csv', :
|
429
|
-
method_option 'id', :
|
430
|
-
method_option 'long', :
|
431
|
-
method_option 'relative_dates', :
|
432
|
-
method_option 'reverse', :
|
433
|
-
method_option 'sort', :
|
434
|
-
method_option 'type', :
|
435
|
-
method_option 'unsorted', :
|
428
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
429
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
430
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
431
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
432
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
433
|
+
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'
|
434
|
+
method_option 'type', aliases: '-t', type: :string, enum: %w(followers followings), default: 'followings', desc: 'Specify the typo of intersection.'
|
435
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
436
436
|
def intersection(first_user, *users)
|
437
437
|
users.push(first_user)
|
438
438
|
# If only one user is specified, compare to the authenticated user
|
@@ -449,21 +449,21 @@ module T
|
|
449
449
|
end
|
450
450
|
intersection = sets.reduce(:&)
|
451
451
|
require 'retryable'
|
452
|
-
users = retryable(:
|
452
|
+
users = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
453
453
|
client.users(intersection)
|
454
454
|
end
|
455
455
|
print_users(users)
|
456
456
|
end
|
457
|
-
map %w
|
457
|
+
map %w(overlap) => :intersection
|
458
458
|
|
459
459
|
desc 'leaders [USER]', "Returns the list of people who you follow but don't follow you back."
|
460
|
-
method_option 'csv', :
|
461
|
-
method_option 'id', :
|
462
|
-
method_option 'long', :
|
463
|
-
method_option 'relative_dates', :
|
464
|
-
method_option 'reverse', :
|
465
|
-
method_option 'sort', :
|
466
|
-
method_option 'unsorted', :
|
460
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
461
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
462
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
463
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
464
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
465
|
+
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'
|
466
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
467
467
|
def leaders(user = nil)
|
468
468
|
user = if user
|
469
469
|
require 't/core_ext/string'
|
@@ -475,20 +475,20 @@ module T
|
|
475
475
|
follower_ids = Thread.new { client.follower_ids(user).to_a }
|
476
476
|
leader_ids = (following_ids.value - follower_ids.value)
|
477
477
|
require 'retryable'
|
478
|
-
users = retryable(:
|
478
|
+
users = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
479
479
|
client.users(leader_ids)
|
480
480
|
end
|
481
481
|
print_users(users)
|
482
482
|
end
|
483
483
|
|
484
484
|
desc 'lists [USER]', 'Returns the lists created by a user.'
|
485
|
-
method_option 'csv', :
|
486
|
-
method_option 'id', :
|
487
|
-
method_option 'long', :
|
488
|
-
method_option 'relative_dates', :
|
489
|
-
method_option 'reverse', :
|
490
|
-
method_option 'sort', :
|
491
|
-
method_option 'unsorted', :
|
485
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
486
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
487
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
488
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
489
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
490
|
+
method_option 'sort', aliases: '-s', type: :string, enum: %w(members mode since slug subscribers), default: 'slug', desc: 'Specify the order of the results.', banner: 'ORDER'
|
491
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
492
492
|
def lists(user = nil)
|
493
493
|
lists = if user
|
494
494
|
require 't/core_ext/string'
|
@@ -502,7 +502,7 @@ module T
|
|
502
502
|
|
503
503
|
desc 'matrix', 'Unfortunately, no one can be told what the Matrix is. You have to see it for yourself.'
|
504
504
|
def matrix
|
505
|
-
opts = {:
|
505
|
+
opts = {count: MAX_SEARCH_RESULTS, include_entities: false}
|
506
506
|
tweets = client.search('lang:ja', opts)
|
507
507
|
tweets.each do |tweet|
|
508
508
|
say(tweet.text.gsub(/[^\u3000\u3040-\u309f]/, '').reverse, [:bold, :green, :on_black], false)
|
@@ -510,12 +510,12 @@ module T
|
|
510
510
|
end
|
511
511
|
|
512
512
|
desc 'mentions', "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets mentioning you."
|
513
|
-
method_option 'csv', :
|
514
|
-
method_option 'decode_uris', :
|
515
|
-
method_option 'long', :
|
516
|
-
method_option 'number', :
|
517
|
-
method_option 'relative_dates', :
|
518
|
-
method_option 'reverse', :
|
513
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
514
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
515
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
516
|
+
method_option 'number', aliases: '-n', type: :numeric, default: DEFAULT_NUM_RESULTS, desc: 'Limit the number of results.'
|
517
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
518
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
519
519
|
def mentions
|
520
520
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
521
521
|
opts = {}
|
@@ -525,10 +525,10 @@ module T
|
|
525
525
|
end
|
526
526
|
print_tweets(tweets)
|
527
527
|
end
|
528
|
-
map %w
|
528
|
+
map %w(replies) => :mentions
|
529
529
|
|
530
530
|
desc 'mute USER [USER...]', 'Mute users.'
|
531
|
-
method_option 'id', :
|
531
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
532
532
|
def mute(user, *users)
|
533
533
|
muted_users, number = fetch_users(users.unshift(user), options) do |users_to_mute|
|
534
534
|
client.mute(users_to_mute)
|
@@ -539,37 +539,37 @@ module T
|
|
539
539
|
end
|
540
540
|
|
541
541
|
desc 'muted [USER]', 'Returns a list of the people you have muted on Twitter.'
|
542
|
-
method_option 'csv', :
|
543
|
-
method_option 'long', :
|
544
|
-
method_option 'relative_dates', :
|
545
|
-
method_option 'reverse', :
|
546
|
-
method_option 'sort', :
|
547
|
-
method_option 'unsorted', :
|
542
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
543
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
544
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
545
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
546
|
+
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'
|
547
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
548
548
|
def muted
|
549
549
|
muted_ids = client.muted_ids.to_a
|
550
550
|
require 'retryable'
|
551
|
-
muted_users = retryable(:
|
551
|
+
muted_users = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
552
552
|
client.users(muted_ids)
|
553
553
|
end
|
554
554
|
print_users(muted_users)
|
555
555
|
end
|
556
|
-
map %w
|
556
|
+
map %w(mutes) => :muted
|
557
557
|
|
558
558
|
desc 'open USER', "Opens that user's profile in a web browser."
|
559
|
-
method_option 'display-uri', :
|
560
|
-
method_option 'id', :
|
561
|
-
method_option 'status', :
|
559
|
+
method_option 'display-uri', aliases: '-d', type: :boolean, desc: 'Display the requested URL instead of attempting to open it.'
|
560
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
561
|
+
method_option 'status', aliases: '-s', type: :boolean, desc: 'Specify input as a Twitter status ID instead of a screen name.'
|
562
562
|
def open(user)
|
563
563
|
require 'launchy'
|
564
564
|
if options['id']
|
565
565
|
user = client.user(user.to_i)
|
566
|
-
open_or_print(user.uri, :
|
566
|
+
open_or_print(user.uri, dry_run: options['display-uri'])
|
567
567
|
elsif options['status']
|
568
|
-
status = client.status(user.to_i, :
|
569
|
-
open_or_print(status.uri, :
|
568
|
+
status = client.status(user.to_i, include_my_retweet: false)
|
569
|
+
open_or_print(status.uri, dry_run: options['display-uri'])
|
570
570
|
else
|
571
571
|
require 't/core_ext/string'
|
572
|
-
open_or_print("https://twitter.com/#{user.strip_ats}", :
|
572
|
+
open_or_print("https://twitter.com/#{user.strip_ats}", dry_run: options['display-uri'])
|
573
573
|
end
|
574
574
|
end
|
575
575
|
|
@@ -577,7 +577,7 @@ module T
|
|
577
577
|
def reach(tweet_id)
|
578
578
|
require 't/core_ext/string'
|
579
579
|
require 'set'
|
580
|
-
status_thread = Thread.new { client.status(tweet_id.to_i, :
|
580
|
+
status_thread = Thread.new { client.status(tweet_id.to_i, include_my_retweet: false) }
|
581
581
|
threads = []
|
582
582
|
client.retweeters_ids(tweet_id.to_i).each do |retweeter_id|
|
583
583
|
threads << Thread.new(retweeter_id) do |user_id|
|
@@ -595,11 +595,11 @@ module T
|
|
595
595
|
end
|
596
596
|
|
597
597
|
desc 'reply TWEET_ID MESSAGE', 'Post your Tweet as a reply directed at another person.'
|
598
|
-
method_option 'all', :
|
599
|
-
method_option 'location', :
|
600
|
-
method_option 'file', :
|
598
|
+
method_option 'all', aliases: '-a', type: :boolean, desc: 'Reply to all users mentioned in the Tweet.'
|
599
|
+
method_option 'location', aliases: '-l', type: :string, default: nil, desc: "Add location information. If the optional 'latitude,longitude' parameter is not supplied, looks up location by IP address."
|
600
|
+
method_option 'file', aliases: '-f', type: :string, desc: 'The path to an image to attach to your tweet.'
|
601
601
|
def reply(status_id, message)
|
602
|
-
status = client.status(status_id.to_i, :
|
602
|
+
status = client.status(status_id.to_i, include_my_retweet: false)
|
603
603
|
users = Array(status.user.screen_name)
|
604
604
|
if options['all']
|
605
605
|
users += extract_mentioned_screen_names(status.full_text)
|
@@ -608,7 +608,7 @@ module T
|
|
608
608
|
users.delete(@rcfile.active_profile[0])
|
609
609
|
require 't/core_ext/string'
|
610
610
|
users.collect!(&:prepend_at)
|
611
|
-
opts = {:
|
611
|
+
opts = {in_reply_to_status_id: status.id, trim_user: true}
|
612
612
|
add_location!(options, opts)
|
613
613
|
reply = if options['file']
|
614
614
|
client.update_with_media("#{users.join(' ')} #{message}", File.new(File.expand_path(options['file'])), opts)
|
@@ -621,38 +621,38 @@ module T
|
|
621
621
|
end
|
622
622
|
|
623
623
|
desc 'report_spam USER [USER...]', 'Report users for spam.'
|
624
|
-
method_option 'id', :
|
624
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
625
625
|
def report_spam(user, *users)
|
626
626
|
_, number = fetch_users(users.unshift(user), options) do |users_to_report|
|
627
627
|
client.report_spam(users_to_report)
|
628
628
|
end
|
629
629
|
say "@#{@rcfile.active_profile[0]} reported #{pluralize(number, 'user')}."
|
630
630
|
end
|
631
|
-
map %w
|
631
|
+
map %w(report reportspam spam) => :report_spam
|
632
632
|
|
633
633
|
desc 'retweet TWEET_ID [TWEET_ID...]', 'Sends Tweets to your followers.'
|
634
634
|
def retweet(status_id, *status_ids)
|
635
635
|
status_ids.unshift(status_id)
|
636
636
|
status_ids.collect!(&:to_i)
|
637
637
|
require 'retryable'
|
638
|
-
retweets = retryable(:
|
639
|
-
client.retweet(status_ids, :
|
638
|
+
retweets = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
639
|
+
client.retweet(status_ids, trim_user: true)
|
640
640
|
end
|
641
641
|
number = retweets.length
|
642
642
|
say "@#{@rcfile.active_profile[0]} retweeted #{pluralize(number, 'tweet')}."
|
643
643
|
say
|
644
644
|
say "Run `#{File.basename($PROGRAM_NAME)} delete status #{retweets.collect(&:id).join(' ')}` to undo."
|
645
645
|
end
|
646
|
-
map %w
|
646
|
+
map %w(rt) => :retweet
|
647
647
|
|
648
648
|
desc 'retweets [USER]', "Returns the #{DEFAULT_NUM_RESULTS} most recent Retweets by a user."
|
649
|
-
method_option 'csv', :
|
650
|
-
method_option 'decode_uris', :
|
651
|
-
method_option 'id', :
|
652
|
-
method_option 'long', :
|
653
|
-
method_option 'number', :
|
654
|
-
method_option 'relative_dates', :
|
655
|
-
method_option 'reverse', :
|
649
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
650
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
651
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
652
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
653
|
+
method_option 'number', aliases: '-n', type: :numeric, default: DEFAULT_NUM_RESULTS, desc: 'Limit the number of results.'
|
654
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
655
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
656
656
|
def retweets(user = nil)
|
657
657
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
658
658
|
opts = {}
|
@@ -670,15 +670,15 @@ module T
|
|
670
670
|
end
|
671
671
|
print_tweets(tweets)
|
672
672
|
end
|
673
|
-
map %w
|
673
|
+
map %w(rts) => :retweets
|
674
674
|
|
675
675
|
desc 'retweets_of_me', "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets of the authenticated user that have been retweeted by others."
|
676
|
-
method_option 'csv', :
|
677
|
-
method_option 'decode_uris', :
|
678
|
-
method_option 'long', :
|
679
|
-
method_option 'number', :
|
680
|
-
method_option 'relative_dates', :
|
681
|
-
method_option 'reverse', :
|
676
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
677
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
678
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
679
|
+
method_option 'number', aliases: '-n', type: :numeric, default: DEFAULT_NUM_RESULTS, desc: 'Limit the number of results.'
|
680
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
681
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
682
682
|
def retweets_of_me
|
683
683
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
684
684
|
opts = {}
|
@@ -688,22 +688,22 @@ module T
|
|
688
688
|
end
|
689
689
|
print_tweets(tweets)
|
690
690
|
end
|
691
|
-
map %w
|
691
|
+
map %w(retweetsofme) => :retweets_of_me
|
692
692
|
|
693
693
|
desc 'ruler', 'Prints a 140-character ruler'
|
694
|
-
method_option 'indent', :
|
694
|
+
method_option 'indent', aliases: '-i', type: :numeric, default: 0, desc: 'The number of spaces to print before the ruler.'
|
695
695
|
def ruler
|
696
696
|
markings = '----|'.chars.cycle.take(140).join
|
697
697
|
say "#{' ' * options['indent'].to_i}#{markings}"
|
698
698
|
end
|
699
699
|
|
700
700
|
desc 'status TWEET_ID', 'Retrieves detailed information about a Tweet.'
|
701
|
-
method_option 'csv', :
|
702
|
-
method_option 'decode_uris', :
|
703
|
-
method_option 'long', :
|
704
|
-
method_option 'relative_dates', :
|
701
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
702
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
703
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
704
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
705
705
|
def status(status_id) # rubocop:disable CyclomaticComplexity
|
706
|
-
opts = {:
|
706
|
+
opts = {include_my_retweet: false}
|
707
707
|
opts[:include_entities] = !!options['decode_uris']
|
708
708
|
status = client.status(status_id.to_i, opts)
|
709
709
|
location = if status.place?
|
@@ -747,16 +747,16 @@ module T
|
|
747
747
|
end
|
748
748
|
|
749
749
|
desc 'timeline [USER]', "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets posted by a user."
|
750
|
-
method_option 'csv', :
|
751
|
-
method_option 'decode_uris', :
|
752
|
-
method_option 'exclude', :
|
753
|
-
method_option 'id', :
|
754
|
-
method_option 'long', :
|
755
|
-
method_option 'max_id', :
|
756
|
-
method_option 'number', :
|
757
|
-
method_option 'relative_dates', :
|
758
|
-
method_option 'reverse', :
|
759
|
-
method_option 'since_id', :
|
750
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
751
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
752
|
+
method_option 'exclude', aliases: '-e', type: :string, enum: %w(replies retweets), desc: 'Exclude certain types of Tweets from the results.', banner: 'TYPE'
|
753
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
754
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
755
|
+
method_option 'max_id', aliases: '-m', type: :numeric, desc: 'Returns only the results with an ID less than the specified ID.'
|
756
|
+
method_option 'number', aliases: '-n', type: :numeric, default: DEFAULT_NUM_RESULTS, desc: 'Limit the number of results.'
|
757
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
758
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
759
|
+
method_option 'since_id', aliases: '-s', type: :numeric, desc: 'Returns only the results with an ID greater than the specified ID.'
|
760
760
|
def timeline(user = nil)
|
761
761
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
762
762
|
opts = {}
|
@@ -778,24 +778,24 @@ module T
|
|
778
778
|
end
|
779
779
|
print_tweets(tweets)
|
780
780
|
end
|
781
|
-
map %w
|
781
|
+
map %w(tl) => :timeline
|
782
782
|
|
783
783
|
desc 'trends [WOEID]', 'Returns the top 10 trending topics.'
|
784
|
-
method_option 'exclude-hashtags', :
|
784
|
+
method_option 'exclude-hashtags', aliases: '-x', type: :boolean, desc: 'Remove all hashtags from the trends list.'
|
785
785
|
def trends(woe_id = 1)
|
786
786
|
opts = {}
|
787
|
-
opts.merge!(:
|
787
|
+
opts.merge!(exclude: 'hashtags') if options['exclude-hashtags']
|
788
788
|
trends = client.trends(woe_id, opts)
|
789
789
|
print_attribute(trends, :name)
|
790
790
|
end
|
791
791
|
|
792
792
|
desc 'trend_locations', 'Returns the locations for which Twitter has trending topic information.'
|
793
|
-
method_option 'csv', :
|
794
|
-
method_option 'long', :
|
795
|
-
method_option 'relative_dates', :
|
796
|
-
method_option 'reverse', :
|
797
|
-
method_option 'sort', :
|
798
|
-
method_option 'unsorted', :
|
793
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
794
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
795
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
796
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
797
|
+
method_option 'sort', aliases: '-s', type: :string, enum: %w(country name parent type woeid), default: 'name', desc: 'Specify the order of the results.', banner: 'ORDER'
|
798
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
799
799
|
def trend_locations
|
800
800
|
places = client.trend_locations
|
801
801
|
places = case options['sort']
|
@@ -827,10 +827,10 @@ module T
|
|
827
827
|
print_attribute(places, :name)
|
828
828
|
end
|
829
829
|
end
|
830
|
-
map %w
|
830
|
+
map %w(locations trendlocations) => :trend_locations
|
831
831
|
|
832
832
|
desc 'unfollow USER [USER...]', 'Allows you to stop following users.'
|
833
|
-
method_option 'id', :
|
833
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
834
834
|
def unfollow(user, *users)
|
835
835
|
unfollowed_users, number = fetch_users(users.unshift(user), options) do |users_to_unfollow|
|
836
836
|
client.unfollow(users_to_unfollow)
|
@@ -841,11 +841,11 @@ module T
|
|
841
841
|
end
|
842
842
|
|
843
843
|
desc 'update [MESSAGE]', 'Post a Tweet.'
|
844
|
-
method_option 'location', :
|
845
|
-
method_option 'file', :
|
844
|
+
method_option 'location', aliases: '-l', type: :string, default: nil, desc: "Add location information. If the optional 'latitude,longitude' parameter is not supplied, looks up location by IP address."
|
845
|
+
method_option 'file', aliases: '-f', type: :string, desc: 'The path to an image to attach to your tweet.'
|
846
846
|
def update(message = nil)
|
847
847
|
message = T::Editor.gets if message.nil? || message.empty?
|
848
|
-
opts = {:
|
848
|
+
opts = {trim_user: true}
|
849
849
|
add_location!(options, opts)
|
850
850
|
status = if options['file']
|
851
851
|
client.update_with_media(message, File.new(File.expand_path(options['file'])), opts)
|
@@ -856,41 +856,41 @@ module T
|
|
856
856
|
say
|
857
857
|
say "Run `#{File.basename($PROGRAM_NAME)} delete status #{status.id}` to delete."
|
858
858
|
end
|
859
|
-
map %w
|
859
|
+
map %w(post tweet) => :update
|
860
860
|
|
861
861
|
desc 'users USER [USER...]', 'Returns a list of users you specify.'
|
862
|
-
method_option 'csv', :
|
863
|
-
method_option 'id', :
|
864
|
-
method_option 'long', :
|
865
|
-
method_option 'relative_dates', :
|
866
|
-
method_option 'reverse', :
|
867
|
-
method_option 'sort', :
|
868
|
-
method_option 'unsorted', :
|
862
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
863
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
864
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
865
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
866
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
867
|
+
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'
|
868
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
869
869
|
def users(user, *users)
|
870
870
|
users.unshift(user)
|
871
871
|
require 't/core_ext/string'
|
872
872
|
options['id'] ? users.collect!(&:to_i) : users.collect!(&:strip_ats)
|
873
873
|
require 'retryable'
|
874
|
-
users = retryable(:
|
874
|
+
users = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
875
875
|
client.users(users)
|
876
876
|
end
|
877
877
|
print_users(users)
|
878
878
|
end
|
879
|
-
map %w
|
879
|
+
map %w(stats) => :users
|
880
880
|
|
881
881
|
desc 'version', 'Show version.'
|
882
882
|
def version
|
883
883
|
require 't/version'
|
884
884
|
say T::Version
|
885
885
|
end
|
886
|
-
map %w
|
886
|
+
map %w(-v --version) => :version
|
887
887
|
|
888
888
|
desc 'whois USER', 'Retrieves profile information for the user.'
|
889
|
-
method_option 'csv', :
|
890
|
-
method_option 'decode_uris', :
|
891
|
-
method_option 'id', :
|
892
|
-
method_option 'long', :
|
893
|
-
method_option 'relative_dates', :
|
889
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
890
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
891
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
892
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
893
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
894
894
|
def whois(user) # rubocop:disable CyclomaticComplexity
|
895
895
|
require 't/core_ext/string'
|
896
896
|
opts = {}
|
@@ -917,16 +917,20 @@ module T
|
|
917
917
|
print_table(array)
|
918
918
|
end
|
919
919
|
end
|
920
|
-
map %w
|
920
|
+
map %w(user) => :whois
|
921
921
|
|
922
922
|
desc 'whoami', 'Retrieves profile information for the authenticated user.'
|
923
|
-
method_option 'csv', :
|
924
|
-
method_option 'decode_uris', :
|
925
|
-
method_option 'long', :
|
926
|
-
method_option 'relative_dates', :
|
923
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
924
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
925
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
926
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
927
927
|
def whoami
|
928
|
-
|
929
|
-
|
928
|
+
if @rcfile.active_profile && @rcfile.active_profile[0]
|
929
|
+
user = @rcfile.active_profile[0]
|
930
|
+
whois(user)
|
931
|
+
else
|
932
|
+
$stderr.puts "You haven't authorized an account, run `t authorize` to get started."
|
933
|
+
end
|
930
934
|
end
|
931
935
|
|
932
936
|
desc 'delete SUBCOMMAND ...ARGS', 'Delete Tweets, Direct Messages, etc.'
|
@@ -969,17 +973,17 @@ module T
|
|
969
973
|
value =~ /"(.*?)"/
|
970
974
|
"#{key}=#{CGI.escape(Regexp.last_match[1])}"
|
971
975
|
end.join('&')
|
972
|
-
"#{Twitter::REST::Client::
|
976
|
+
"#{Twitter::REST::Client::BASE_URL}#{request.path}?#{params}"
|
973
977
|
end
|
974
978
|
|
975
979
|
def pin_auth_parameters
|
976
|
-
{:
|
980
|
+
{oauth_callback: 'oob'}
|
977
981
|
end
|
978
982
|
|
979
983
|
def add_location!(options, opts)
|
980
984
|
return nil unless options['location']
|
981
985
|
lat, lng = options['location'] == 'location' ? [location.lat, location.lng] : options['location'].split(',').collect(&:to_f)
|
982
|
-
opts.merge!(:
|
986
|
+
opts.merge!(lat: lat, long: lng)
|
983
987
|
end
|
984
988
|
|
985
989
|
def location
|