t 2.8.0 → 2.9.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.
- 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
data/lib/t/collectable.rb
CHANGED
@@ -8,7 +8,7 @@ module T
|
|
8
8
|
MAX_PAGE = 51
|
9
9
|
|
10
10
|
def collect_with_max_id(collection = [], max_id = nil, &block)
|
11
|
-
tweets = retryable(:
|
11
|
+
tweets = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
12
12
|
yield(max_id)
|
13
13
|
end
|
14
14
|
return collection if tweets.nil?
|
@@ -31,7 +31,7 @@ module T
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def collect_with_page(collection = ::Set.new, page = 1, previous = nil, &block) # rubocop:disable ParameterLists
|
34
|
-
tweets = retryable(:
|
34
|
+
tweets = Retryable.retryable(tries: 3, on: Twitter::Error, sleep: 0) do
|
35
35
|
block.call(page)
|
36
36
|
end
|
37
37
|
return collection if tweets.nil? || tweets == previous || page >= MAX_PAGE
|
data/lib/t/delete.rb
CHANGED
@@ -17,8 +17,8 @@ module T
|
|
17
17
|
end
|
18
18
|
|
19
19
|
desc 'block USER [USER...]', 'Unblock users.'
|
20
|
-
method_option 'id', :
|
21
|
-
method_option 'force', :
|
20
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
21
|
+
method_option 'force', aliases: '-f', type: :boolean
|
22
22
|
def block(user, *users)
|
23
23
|
unblocked_users, number = fetch_users(users.unshift(user), options) do |users_to_unblock|
|
24
24
|
client.unblock(users_to_unblock)
|
@@ -29,7 +29,7 @@ module T
|
|
29
29
|
end
|
30
30
|
|
31
31
|
desc 'dm [DIRECT_MESSAGE_ID] [DIRECT_MESSAGE_ID...]', 'Delete the last Direct Message sent.'
|
32
|
-
method_option 'force', :
|
32
|
+
method_option 'force', aliases: '-f', type: :boolean
|
33
33
|
def dm(direct_message_id, *direct_message_ids)
|
34
34
|
direct_message_ids.unshift(direct_message_id)
|
35
35
|
require 't/core_ext/string'
|
@@ -48,10 +48,10 @@ module T
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
|
-
map %w
|
51
|
+
map %w(d m) => :dm
|
52
52
|
|
53
53
|
desc 'favorite TWEET_ID [TWEET_ID...]', 'Delete favorites.'
|
54
|
-
method_option 'force', :
|
54
|
+
method_option 'force', aliases: '-f', type: :boolean
|
55
55
|
def favorite(status_id, *status_ids)
|
56
56
|
status_ids.unshift(status_id)
|
57
57
|
require 't/core_ext/string'
|
@@ -63,18 +63,18 @@ module T
|
|
63
63
|
end
|
64
64
|
else
|
65
65
|
status_ids.each do |status_id_to_unfavorite|
|
66
|
-
status = client.status(status_id_to_unfavorite, :
|
66
|
+
status = client.status(status_id_to_unfavorite, include_my_retweet: false)
|
67
67
|
return unless yes? "Are you sure you want to remove @#{status.user.screen_name}'s status: \"#{status.full_text}\" from your favorites? [y/N]"
|
68
68
|
client.unfavorite(status_id_to_unfavorite)
|
69
69
|
say "@#{@rcfile.active_profile[0]} unfavorited @#{status.user.screen_name}'s status: \"#{status.full_text}\""
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
|
-
map %w
|
73
|
+
map %w(fave favourite) => :favorite
|
74
74
|
|
75
75
|
desc 'list LIST', 'Delete a list.'
|
76
|
-
method_option 'force', :
|
77
|
-
method_option 'id', :
|
76
|
+
method_option 'force', aliases: '-f', type: :boolean
|
77
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify list via ID instead of slug.'
|
78
78
|
def list(list)
|
79
79
|
if options['id']
|
80
80
|
require 't/core_ext/string'
|
@@ -89,8 +89,8 @@ module T
|
|
89
89
|
end
|
90
90
|
|
91
91
|
desc 'mute USER [USER...]', 'Unmute users.'
|
92
|
-
method_option 'id', :
|
93
|
-
method_option 'force', :
|
92
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
93
|
+
method_option 'force', aliases: '-f', type: :boolean
|
94
94
|
def mute(user, *users)
|
95
95
|
unmuted_users, number = fetch_users(users.unshift(user), options) do |users_to_unmute|
|
96
96
|
client.unmute(users_to_unmute)
|
@@ -100,26 +100,38 @@ module T
|
|
100
100
|
say "Run `#{File.basename($PROGRAM_NAME)} mute #{unmuted_users.collect { |unmuted_user| "@#{unmuted_user.screen_name}" }.join(' ')}` to mute."
|
101
101
|
end
|
102
102
|
|
103
|
+
desc 'account SCREEN_NAME [CONSUMER_KEY]', 'delete account or consumer key from t'
|
104
|
+
def account(account, key = nil)
|
105
|
+
if key && @rcfile.profiles[account].keys.length == 1
|
106
|
+
continue = ask 'There is only one API key associated with this account, removing it will disable all functionality, are you sure you want to delete it? [y/N]'
|
107
|
+
return if continue.downcase != 'y'
|
108
|
+
elsif key
|
109
|
+
return @rcfile.delete_key(account, key)
|
110
|
+
else
|
111
|
+
@rcfile.delete_profile(account)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
103
115
|
desc 'status TWEET_ID [TWEET_ID...]', 'Delete Tweets.'
|
104
|
-
method_option 'force', :
|
116
|
+
method_option 'force', aliases: '-f', type: :boolean
|
105
117
|
def status(status_id, *status_ids)
|
106
118
|
status_ids.unshift(status_id)
|
107
119
|
require 't/core_ext/string'
|
108
120
|
status_ids.collect!(&:to_i)
|
109
121
|
if options['force']
|
110
|
-
tweets = client.destroy_status(status_ids, :
|
122
|
+
tweets = client.destroy_status(status_ids, trim_user: true)
|
111
123
|
tweets.each do |status|
|
112
124
|
say "@#{@rcfile.active_profile[0]} deleted the Tweet: \"#{status.full_text}\""
|
113
125
|
end
|
114
126
|
else
|
115
127
|
status_ids.each do |status_id_to_delete|
|
116
|
-
status = client.status(status_id_to_delete, :
|
128
|
+
status = client.status(status_id_to_delete, include_my_retweet: false)
|
117
129
|
return unless yes? "Are you sure you want to permanently delete @#{status.user.screen_name}'s status: \"#{status.full_text}\"? [y/N]"
|
118
|
-
client.destroy_status(status_id_to_delete, :
|
130
|
+
client.destroy_status(status_id_to_delete, trim_user: true)
|
119
131
|
say "@#{@rcfile.active_profile[0]} deleted the Tweet: \"#{status.full_text}\""
|
120
132
|
end
|
121
133
|
end
|
122
134
|
end
|
123
|
-
map %w
|
135
|
+
map %w(post tweet update) => :status
|
124
136
|
end
|
125
137
|
end
|
data/lib/t/identicon.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module T
|
2
|
+
class Identicon
|
3
|
+
# Six-bit number (0-63)
|
4
|
+
attr_accessor :bits
|
5
|
+
|
6
|
+
# Eight-bit number (0-255)
|
7
|
+
attr_accessor :color
|
8
|
+
|
9
|
+
def initialize(number)
|
10
|
+
# Bottom six bits
|
11
|
+
@bits = number & 0x3f
|
12
|
+
|
13
|
+
# Next highest eight bits
|
14
|
+
@fcolor = (number >> 6) & 0xff
|
15
|
+
|
16
|
+
# Next highest eight bits
|
17
|
+
@bcolor = (number >> 14) & 0xff
|
18
|
+
end
|
19
|
+
|
20
|
+
def lines
|
21
|
+
["#{bg @bits[0]} #{bg @bits[1]} #{bg @bits[0]} #{reset}",
|
22
|
+
"#{bg @bits[2]} #{bg @bits[3]} #{bg @bits[2]} #{reset}",
|
23
|
+
"#{bg @bits[4]} #{bg @bits[5]} #{bg @bits[4]} #{reset}"]
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def reset
|
29
|
+
"\033[0m"
|
30
|
+
end
|
31
|
+
|
32
|
+
def bg(bit)
|
33
|
+
bit == 0 ? "\033[48;5;#{@bcolor}m" : "\033[48;5;#{@fcolor}m"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class << Identicon
|
38
|
+
def for_user_name(string)
|
39
|
+
Identicon.new(digest(string))
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def digest(string)
|
45
|
+
require 'digest'
|
46
|
+
Digest::MD5.digest(string).chars.inject(0) { |a, e| (a << 8) | e.ord }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/t/list.rb
CHANGED
@@ -23,7 +23,7 @@ module T
|
|
23
23
|
end
|
24
24
|
|
25
25
|
desc 'add LIST USER [USER...]', 'Add members to a list.'
|
26
|
-
method_option 'id', :
|
26
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
27
27
|
def add(list_name, user, *users)
|
28
28
|
added_users, number = fetch_users(users.unshift(user), options) do |users_to_add|
|
29
29
|
client.add_list_members(list_name, users_to_add)
|
@@ -39,16 +39,16 @@ module T
|
|
39
39
|
end
|
40
40
|
|
41
41
|
desc 'create LIST [DESCRIPTION]', 'Create a new list.'
|
42
|
-
method_option 'private', :
|
42
|
+
method_option 'private', aliases: '-p', type: :boolean
|
43
43
|
def create(list_name, description = nil)
|
44
|
-
opts = description ? {:
|
45
|
-
opts.merge!(:
|
44
|
+
opts = description ? {description: description} : {}
|
45
|
+
opts.merge!(mode: 'private') if options['private']
|
46
46
|
client.create_list(list_name, opts)
|
47
47
|
say "@#{@rcfile.active_profile[0]} created the list \"#{list_name}\"."
|
48
48
|
end
|
49
49
|
|
50
50
|
desc 'information [USER/]LIST', 'Retrieves detailed information about a Twitter list.'
|
51
|
-
method_option 'csv', :
|
51
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
52
52
|
def information(user_list)
|
53
53
|
owner, list_name = extract_owner(user_list, options)
|
54
54
|
list = client.list(owner, list_name)
|
@@ -71,15 +71,15 @@ module T
|
|
71
71
|
print_table(array)
|
72
72
|
end
|
73
73
|
end
|
74
|
-
map %w
|
74
|
+
map %w(details) => :information
|
75
75
|
|
76
76
|
desc 'members [USER/]LIST', 'Returns the members of a Twitter list.'
|
77
|
-
method_option 'csv', :
|
78
|
-
method_option 'id', :
|
79
|
-
method_option 'long', :
|
80
|
-
method_option 'reverse', :
|
81
|
-
method_option 'sort', :
|
82
|
-
method_option 'unsorted', :
|
77
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
78
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
79
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
80
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
81
|
+
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'
|
82
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
83
83
|
def members(user_list)
|
84
84
|
owner, list_name = extract_owner(user_list, options)
|
85
85
|
users = client.list_members(owner, list_name).to_a
|
@@ -87,7 +87,7 @@ module T
|
|
87
87
|
end
|
88
88
|
|
89
89
|
desc 'remove LIST USER [USER...]', 'Remove members from a list.'
|
90
|
-
method_option 'id', :
|
90
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify input as Twitter user IDs instead of screen names.'
|
91
91
|
def remove(list_name, user, *users)
|
92
92
|
removed_users, number = fetch_users(users.unshift(user), options) do |users_to_remove|
|
93
93
|
client.remove_list_members(list_name, users_to_remove)
|
@@ -103,13 +103,13 @@ module T
|
|
103
103
|
end
|
104
104
|
|
105
105
|
desc 'timeline [USER/]LIST', 'Show tweet timeline for members of the specified list.'
|
106
|
-
method_option 'csv', :
|
107
|
-
method_option 'decode_uris', :
|
108
|
-
method_option 'id', :
|
109
|
-
method_option 'long', :
|
110
|
-
method_option 'number', :
|
111
|
-
method_option 'relative_dates', :
|
112
|
-
method_option 'reverse', :
|
106
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
107
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
108
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
109
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
110
|
+
method_option 'number', aliases: '-n', type: :numeric, default: DEFAULT_NUM_RESULTS, desc: 'Limit the number of results.'
|
111
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
112
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
113
113
|
def timeline(user_list)
|
114
114
|
owner, list_name = extract_owner(user_list, options)
|
115
115
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
@@ -120,6 +120,6 @@ module T
|
|
120
120
|
end
|
121
121
|
print_tweets(tweets)
|
122
122
|
end
|
123
|
-
map %w
|
123
|
+
map %w(tl) => :timeline
|
124
124
|
end
|
125
125
|
end
|
data/lib/t/printable.rb
CHANGED
@@ -104,7 +104,7 @@ module T
|
|
104
104
|
Kernel.send(element.class.name.to_sym, format[index] % element)
|
105
105
|
end
|
106
106
|
end
|
107
|
-
print_table(array, :
|
107
|
+
print_table(array, truncate: true)
|
108
108
|
else
|
109
109
|
print_table(array)
|
110
110
|
end
|
@@ -112,15 +112,53 @@ module T
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def print_message(from_user, message)
|
115
|
+
require 'htmlentities'
|
116
|
+
|
115
117
|
case options['color']
|
118
|
+
when 'icon'
|
119
|
+
print_identicon(from_user, message)
|
120
|
+
say
|
121
|
+
say
|
116
122
|
when 'auto'
|
117
123
|
say(" @#{from_user}", [:bold, :yellow])
|
124
|
+
print_wrapped(HTMLEntities.new.decode(message), indent: 3)
|
125
|
+
say
|
118
126
|
else
|
119
127
|
say(" @#{from_user}")
|
128
|
+
print_wrapped(HTMLEntities.new.decode(message), indent: 3)
|
129
|
+
say
|
120
130
|
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def print_identicon(from_user, message)
|
121
134
|
require 'htmlentities'
|
122
|
-
|
123
|
-
|
135
|
+
require 't/identicon'
|
136
|
+
icon = Identicon.for_user_name(from_user)
|
137
|
+
|
138
|
+
# Save 6 chars for icon, ensure at least 3 lines long
|
139
|
+
lines = wrapped(HTMLEntities.new.decode(message), indent: 2, width: terminal_width - (6 + 5))
|
140
|
+
lines.unshift(set_color(" @#{from_user}", :bold, :yellow))
|
141
|
+
lines.push(*(3 - lines.length).times.map { '' })
|
142
|
+
|
143
|
+
$stdout.puts lines.zip(icon.lines).map { |x, i| " #{i || ' '}#{x}" }
|
144
|
+
end
|
145
|
+
|
146
|
+
def wrapped(message, options = {})
|
147
|
+
indent = options[:indent] || 0
|
148
|
+
width = options[:width] || terminal_width - indent
|
149
|
+
paras = message.split("\n\n")
|
150
|
+
|
151
|
+
paras.map! do |unwrapped|
|
152
|
+
unwrapped.strip.squeeze(' ').gsub(/.{1,#{width}}(?:\s|\Z)/) { ($& + 5.chr).gsub(/\n\005/, "\n").gsub(/\005/, "\n") }
|
153
|
+
end
|
154
|
+
|
155
|
+
lines = paras.inject([]) do |memo, para|
|
156
|
+
memo.concat(para.split("\n").map { |line| line.insert(0, ' ' * indent) })
|
157
|
+
memo.push ''
|
158
|
+
end
|
159
|
+
|
160
|
+
lines.pop
|
161
|
+
lines
|
124
162
|
end
|
125
163
|
|
126
164
|
def print_tweets(tweets)
|
data/lib/t/rcfile.rb
CHANGED
@@ -96,6 +96,16 @@ module T
|
|
96
96
|
send(:initialize)
|
97
97
|
end
|
98
98
|
|
99
|
+
def delete_profile(profile)
|
100
|
+
profiles.delete(profile)
|
101
|
+
write
|
102
|
+
end
|
103
|
+
|
104
|
+
def delete_key(profile, key)
|
105
|
+
profiles[profile].delete(key)
|
106
|
+
write
|
107
|
+
end
|
108
|
+
|
99
109
|
private
|
100
110
|
|
101
111
|
def active_profile?
|
data/lib/t/search.rb
CHANGED
@@ -25,14 +25,14 @@ module T
|
|
25
25
|
end
|
26
26
|
|
27
27
|
desc 'all QUERY', "Returns the #{DEFAULT_NUM_RESULTS} most recent Tweets that match the specified query."
|
28
|
-
method_option 'csv', :
|
29
|
-
method_option 'decode_uris', :
|
30
|
-
method_option 'long', :
|
31
|
-
method_option 'number', :
|
32
|
-
method_option 'relative_dates', :
|
28
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
29
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
30
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
31
|
+
method_option 'number', aliases: '-n', type: :numeric, default: DEFAULT_NUM_RESULTS
|
32
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
33
33
|
def all(query)
|
34
34
|
count = options['number'] || DEFAULT_NUM_RESULTS
|
35
|
-
opts = {:
|
35
|
+
opts = {count: MAX_SEARCH_RESULTS}
|
36
36
|
opts[:include_entities] = !!options['decode_uris']
|
37
37
|
tweets = client.search(query, opts).take(count)
|
38
38
|
tweets.reverse! if options['reverse']
|
@@ -57,15 +57,15 @@ module T
|
|
57
57
|
end
|
58
58
|
|
59
59
|
desc 'favorites [USER] QUERY', "Returns Tweets you've favorited that match the specified query."
|
60
|
-
method_option 'csv', :
|
61
|
-
method_option 'decode_uris', :
|
62
|
-
method_option 'id', :
|
63
|
-
method_option 'long', :
|
64
|
-
method_option 'relative_dates', :
|
60
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
61
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
62
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
63
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
64
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
65
65
|
def favorites(*args)
|
66
66
|
query = args.pop
|
67
67
|
user = args.pop
|
68
|
-
opts = {:
|
68
|
+
opts = {count: MAX_NUM_RESULTS}
|
69
69
|
opts[:include_entities] = !!options['decode_uris']
|
70
70
|
if user
|
71
71
|
require 't/core_ext/string'
|
@@ -85,17 +85,17 @@ module T
|
|
85
85
|
end
|
86
86
|
print_tweets(tweets)
|
87
87
|
end
|
88
|
-
map %w
|
88
|
+
map %w(faves) => :favorites
|
89
89
|
|
90
90
|
desc 'list [USER/]LIST QUERY', 'Returns Tweets on a list that match the specified query.'
|
91
|
-
method_option 'csv', :
|
92
|
-
method_option 'decode_uris', :
|
93
|
-
method_option 'id', :
|
94
|
-
method_option 'long', :
|
95
|
-
method_option 'relative_dates', :
|
91
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
92
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
93
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
94
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
95
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
96
96
|
def list(user_list, query)
|
97
97
|
owner, list_name = extract_owner(user_list, options)
|
98
|
-
opts = {:
|
98
|
+
opts = {count: MAX_NUM_RESULTS}
|
99
99
|
opts[:include_entities] = !!options['decode_uris']
|
100
100
|
tweets = collect_with_max_id do |max_id|
|
101
101
|
opts[:max_id] = max_id unless max_id.nil?
|
@@ -108,12 +108,12 @@ module T
|
|
108
108
|
end
|
109
109
|
|
110
110
|
desc 'mentions QUERY', 'Returns Tweets mentioning you that match the specified query.'
|
111
|
-
method_option 'csv', :
|
112
|
-
method_option 'decode_uris', :
|
113
|
-
method_option 'long', :
|
114
|
-
method_option 'relative_dates', :
|
111
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
112
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
113
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
114
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
115
115
|
def mentions(query)
|
116
|
-
opts = {:
|
116
|
+
opts = {count: MAX_NUM_RESULTS}
|
117
117
|
opts[:include_entities] = !!options['decode_uris']
|
118
118
|
tweets = collect_with_max_id do |max_id|
|
119
119
|
opts[:max_id] = max_id unless max_id.nil?
|
@@ -124,18 +124,18 @@ module T
|
|
124
124
|
end
|
125
125
|
print_tweets(tweets)
|
126
126
|
end
|
127
|
-
map %w
|
127
|
+
map %w(replies) => :mentions
|
128
128
|
|
129
129
|
desc 'retweets [USER] QUERY', "Returns Tweets you've retweeted that match the specified query."
|
130
|
-
method_option 'csv', :
|
131
|
-
method_option 'decode_uris', :
|
132
|
-
method_option 'id', :
|
133
|
-
method_option 'long', :
|
134
|
-
method_option 'relative_dates', :
|
130
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
131
|
+
method_option 'decode_uris', aliases: '-d', type: :boolean, desc: 'Decodes t.co URLs into their original form.'
|
132
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
133
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
134
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
135
135
|
def retweets(*args)
|
136
136
|
query = args.pop
|
137
137
|
user = args.pop
|
138
|
-
opts = {:
|
138
|
+
opts = {count: MAX_NUM_RESULTS}
|
139
139
|
opts[:include_entities] = !!options['decode_uris']
|
140
140
|
if user
|
141
141
|
require 't/core_ext/string'
|
@@ -155,21 +155,21 @@ module T
|
|
155
155
|
end
|
156
156
|
print_tweets(tweets)
|
157
157
|
end
|
158
|
-
map %w
|
158
|
+
map %w(rts) => :retweets
|
159
159
|
|
160
160
|
desc 'timeline [USER] QUERY', 'Returns Tweets in your timeline that match the specified query.'
|
161
|
-
method_option 'csv', :
|
162
|
-
method_option 'decode_uris', :
|
163
|
-
method_option 'exclude', :
|
164
|
-
method_option 'id', :
|
165
|
-
method_option 'long', :
|
166
|
-
method_option 'max_id', :
|
167
|
-
method_option 'relative_dates', :
|
168
|
-
method_option 'since_id', :
|
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 'exclude', aliases: '-e', type: :string, enum: %w(replies retweets), desc: 'Exclude certain types of Tweets from the results.', banner: 'TYPE'
|
164
|
+
method_option 'id', aliases: '-i', type: :boolean, desc: 'Specify user via ID instead of screen name.'
|
165
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
166
|
+
method_option 'max_id', aliases: '-m', type: :numeric, desc: 'Returns only the results with an ID less than the specified ID.'
|
167
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
168
|
+
method_option 'since_id', aliases: '-s', type: :numeric, desc: 'Returns only the results with an ID greater than the specified ID.'
|
169
169
|
def timeline(*args)
|
170
170
|
query = args.pop
|
171
171
|
user = args.pop
|
172
|
-
opts = {:
|
172
|
+
opts = {count: MAX_NUM_RESULTS}
|
173
173
|
opts[:exclude_replies] = true if options['exclude'] == 'replies'
|
174
174
|
opts[:include_entities] = !!options['decode_uris']
|
175
175
|
opts[:include_rts] = false if options['exclude'] == 'retweets'
|
@@ -193,18 +193,18 @@ module T
|
|
193
193
|
end
|
194
194
|
print_tweets(tweets)
|
195
195
|
end
|
196
|
-
map %w
|
196
|
+
map %w(tl) => :timeline
|
197
197
|
|
198
198
|
desc 'users QUERY', 'Returns users that match the specified query.'
|
199
|
-
method_option 'csv', :
|
200
|
-
method_option 'long', :
|
201
|
-
method_option 'relative_dates', :
|
202
|
-
method_option 'reverse', :
|
203
|
-
method_option 'sort', :
|
204
|
-
method_option 'unsorted', :
|
199
|
+
method_option 'csv', aliases: '-c', type: :boolean, desc: 'Output in CSV format.'
|
200
|
+
method_option 'long', aliases: '-l', type: :boolean, desc: 'Output in long format.'
|
201
|
+
method_option 'relative_dates', aliases: '-a', type: :boolean, desc: 'Show relative dates.'
|
202
|
+
method_option 'reverse', aliases: '-r', type: :boolean, desc: 'Reverse the order of the sort.'
|
203
|
+
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'
|
204
|
+
method_option 'unsorted', aliases: '-u', type: :boolean, desc: 'Output is not sorted.'
|
205
205
|
def users(query)
|
206
206
|
users = collect_with_page do |page|
|
207
|
-
client.user_search(query, :
|
207
|
+
client.user_search(query, page: page)
|
208
208
|
end
|
209
209
|
print_users(users)
|
210
210
|
end
|