ayadn 1.2.8 → 1.2.9
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/CHANGELOG.md +7 -0
- data/lib/ayadn/action.rb +15 -16
- data/lib/ayadn/alias.rb +4 -9
- data/lib/ayadn/api.rb +16 -25
- data/lib/ayadn/app.rb +1 -1
- data/lib/ayadn/blacklist.rb +7 -17
- data/lib/ayadn/cnx.rb +47 -27
- data/lib/ayadn/databases.rb +23 -58
- data/lib/ayadn/debug.rb +91 -0
- data/lib/ayadn/endpoints.rb +46 -47
- data/lib/ayadn/errors.rb +1 -3
- data/lib/ayadn/fileops.rb +1 -3
- data/lib/ayadn/mark.rb +1 -1
- data/lib/ayadn/nicerank.rb +5 -36
- data/lib/ayadn/pinboard.rb +2 -2
- data/lib/ayadn/post.rb +21 -24
- data/lib/ayadn/scroll.rb +13 -50
- data/lib/ayadn/settings.rb +1 -0
- data/lib/ayadn/status.rb +27 -0
- data/lib/ayadn/switch.rb +2 -0
- data/lib/ayadn/version.rb +1 -1
- data/lib/ayadn/view.rb +14 -15
- data/lib/ayadn/workers.rb +52 -44
- data/lib/ayadn.rb +1 -1
- metadata +3 -2
data/lib/ayadn/debug.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Ayadn
|
3
|
+
class Debug
|
4
|
+
|
5
|
+
def self.http response, url
|
6
|
+
if Settings.options[:timeline][:show_debug] == true
|
7
|
+
deb = ":::::\n"
|
8
|
+
deb << "Url:\t\t#{url}\n\n"
|
9
|
+
deb << "Headers:\t#{response.headers}\n"
|
10
|
+
deb << ":::::\n"
|
11
|
+
puts deb.color(Settings.options[:colors][:debug])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.db dbs
|
16
|
+
if Settings.options[:timeline][:show_debug] == true
|
17
|
+
puts "/////\nSETTINGS\n"
|
18
|
+
jj JSON.parse((Settings.config).to_json)
|
19
|
+
jj JSON.parse((Settings.options).to_json)
|
20
|
+
puts "/////\n\n"
|
21
|
+
|
22
|
+
puts ">>>>>\nDATABASES\n"
|
23
|
+
dbs.each do |db|
|
24
|
+
puts "Path:\t#{db.file}\nLength:\t#{db.size}\nSize:\t#{db.bytesize / 1024}KB"
|
25
|
+
end
|
26
|
+
puts ">>>>>\n\n"
|
27
|
+
|
28
|
+
puts "^^^^^\nTOKEN\n"
|
29
|
+
puts Settings.user_token
|
30
|
+
puts "^^^^^\n\n"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.err error
|
35
|
+
if Settings.options[:timeline][:show_debug] == true
|
36
|
+
puts "--*--\nTRACE:\n"
|
37
|
+
raise error
|
38
|
+
puts "\n--*--\n\n"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.how_many_ranks niceranks, get_these
|
43
|
+
if Settings.options[:timeline][:show_debug] == true
|
44
|
+
deb = "=====\n"
|
45
|
+
deb << "NR from DB:\t#{niceranks}\n\n"
|
46
|
+
deb << "NR to get:\t#{get_these}\n"
|
47
|
+
deb << "=====\n"
|
48
|
+
puts deb.color(Settings.options[:colors][:debug])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.ranks_pool niceranks
|
53
|
+
if Settings.options[:timeline][:show_debug] == true
|
54
|
+
deb = "=====\n"
|
55
|
+
deb << "NR in pool:\t#{niceranks}\n"
|
56
|
+
deb << "=====\n"
|
57
|
+
puts deb.color(Settings.options[:colors][:debug])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.niceranks_error resp
|
62
|
+
if Settings.options[:timeline][:show_debug] == true
|
63
|
+
deb = "=====\n"
|
64
|
+
deb << "NR Error:\t#{resp}\n"
|
65
|
+
deb << "=====\n"
|
66
|
+
puts deb.color(Settings.options[:colors][:debug])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.total_ranks niceranks
|
71
|
+
if Settings.options[:timeline][:show_debug] == true
|
72
|
+
deb = "=====\n"
|
73
|
+
deb << "NiceRanks:\t#{niceranks}\n\n"
|
74
|
+
deb << "DB size:\t#{Databases.nicerank.size}\n"
|
75
|
+
deb << "=====\n"
|
76
|
+
puts deb.color(Settings.options[:colors][:debug])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.stream stream, options, target
|
81
|
+
if Settings.options[:timeline][:show_debug] == true
|
82
|
+
deb = "+++++\nStream meta:\t#{stream['meta']}\n\n"
|
83
|
+
deb << "Options:\t#{options.inspect}\n\n"
|
84
|
+
deb << "Target:\t\t#{target.inspect}\n\n"
|
85
|
+
deb << "Posts:\t\t#{stream['data'].length}\n+++++\n"
|
86
|
+
puts deb.color(Settings.options[:colors][:debug])
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
data/lib/ayadn/endpoints.rb
CHANGED
@@ -33,82 +33,82 @@ module Ayadn
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def unified(options)
|
36
|
-
if options[:count] || options[:since_id]
|
37
|
-
|
36
|
+
@options_list = if options[:count] || options[:since_id]
|
37
|
+
API.build_query(options)
|
38
38
|
else
|
39
|
-
|
39
|
+
API.build_query({count: Settings.options[:counts][:unified]})
|
40
40
|
end
|
41
41
|
"#{@posts_url}stream/unified?access_token=#{Settings.user_token}#{@options_list}"
|
42
42
|
end
|
43
43
|
|
44
44
|
def checkins(options)
|
45
|
-
if options[:count] || options[:since_id]
|
46
|
-
|
45
|
+
@options_list = if options[:count] || options[:since_id]
|
46
|
+
API.build_query(options)
|
47
47
|
else
|
48
|
-
|
48
|
+
API.build_query({count: Settings.options[:counts][:checkins]})
|
49
49
|
end
|
50
50
|
"#{@posts_url}stream/explore/checkins?access_token=#{Settings.user_token}#{@options_list}"
|
51
51
|
end
|
52
52
|
|
53
53
|
def global(options)
|
54
|
-
if options[:count] || options[:since_id]
|
55
|
-
|
54
|
+
@options_list = if options[:count] || options[:since_id]
|
55
|
+
API.build_query(options)
|
56
56
|
else
|
57
|
-
|
57
|
+
API.build_query({count: Settings.options[:counts][:global]})
|
58
58
|
end
|
59
59
|
"#{@posts_url}stream/global?access_token=#{Settings.user_token}#{@options_list}"
|
60
60
|
end
|
61
61
|
|
62
62
|
def trending(options)
|
63
|
-
if options[:count] || options[:since_id]
|
64
|
-
|
63
|
+
@options_list = if options[:count] || options[:since_id]
|
64
|
+
API.build_query(options)
|
65
65
|
else
|
66
|
-
|
66
|
+
API.build_query({count: Settings.options[:counts][:trending]})
|
67
67
|
end
|
68
68
|
"#{@posts_url}stream/explore/trending?access_token=#{Settings.user_token}#{@options_list}"
|
69
69
|
end
|
70
70
|
|
71
71
|
def photos(options)
|
72
|
-
if options[:count] || options[:since_id]
|
73
|
-
|
72
|
+
@options_list = if options[:count] || options[:since_id]
|
73
|
+
API.build_query(options)
|
74
74
|
else
|
75
|
-
|
75
|
+
API.build_query({count: Settings.options[:counts][:photos]})
|
76
76
|
end
|
77
77
|
"#{@posts_url}stream/explore/photos?access_token=#{Settings.user_token}#{@options_list}"
|
78
78
|
end
|
79
79
|
|
80
80
|
def conversations(options)
|
81
|
-
if options[:count] || options[:since_id]
|
82
|
-
|
81
|
+
@options_list = if options[:count] || options[:since_id]
|
82
|
+
API.build_query(options)
|
83
83
|
else
|
84
|
-
|
84
|
+
API.build_query({count: Settings.options[:counts][:conversations]})
|
85
85
|
end
|
86
86
|
"#{@posts_url}stream/explore/conversations?access_token=#{Settings.user_token}#{@options_list}"
|
87
87
|
end
|
88
88
|
|
89
89
|
def mentions(username, options)
|
90
|
-
if options[:count]
|
91
|
-
|
90
|
+
@options_list = if options[:count]
|
91
|
+
API.build_query(options)
|
92
92
|
else
|
93
|
-
|
93
|
+
API.build_query({count: Settings.options[:counts][:mentions]})
|
94
94
|
end
|
95
95
|
"#{@users_url}#{username}/mentions/?access_token=#{Settings.user_token}#{@options_list}"
|
96
96
|
end
|
97
97
|
|
98
98
|
def posts(username, options)
|
99
|
-
if options[:count]
|
100
|
-
|
99
|
+
@options_list = if options[:count]
|
100
|
+
API.build_query(options)
|
101
101
|
else
|
102
|
-
|
102
|
+
API.build_query({count: Settings.options[:counts][:posts]})
|
103
103
|
end
|
104
104
|
"#{@users_url}#{username}/posts/?access_token=#{Settings.user_token}#{@options_list}"
|
105
105
|
end
|
106
106
|
|
107
107
|
def whatstarred(username, options)
|
108
|
-
if options[:count]
|
109
|
-
|
108
|
+
@options_list = if options[:count]
|
109
|
+
API.build_query(options)
|
110
110
|
else
|
111
|
-
|
111
|
+
API.build_query({count: Settings.options[:counts][:default]})
|
112
112
|
end
|
113
113
|
"#{@users_url}#{username}/stars/?access_token=#{Settings.user_token}#{@options_list}"
|
114
114
|
end
|
@@ -126,10 +126,10 @@ module Ayadn
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def convo(post_id, options)
|
129
|
-
if options[:count]
|
130
|
-
|
129
|
+
@options_list = if options[:count]
|
130
|
+
API.build_query(options)
|
131
131
|
else
|
132
|
-
|
132
|
+
API.build_query({count: Settings.options[:counts][:convo]})
|
133
133
|
end
|
134
134
|
"#{@posts_url}#{post_id}/replies/?access_token=#{Settings.user_token}#{@options_list}"
|
135
135
|
end
|
@@ -155,37 +155,37 @@ module Ayadn
|
|
155
155
|
end
|
156
156
|
|
157
157
|
def search(words, options)
|
158
|
-
if options[:count]
|
159
|
-
|
158
|
+
@options_list = if options[:count]
|
159
|
+
API.build_query(options)
|
160
160
|
else
|
161
|
-
|
161
|
+
API.build_query({count: Settings.options[:counts][:search]})
|
162
162
|
end
|
163
163
|
"#{@posts_url}search?text=#{words}&access_token=#{Settings.user_token}#{@options_list}"
|
164
164
|
end
|
165
165
|
|
166
166
|
def search_users words, options
|
167
|
-
if options[:count]
|
168
|
-
|
167
|
+
@options_list = if options[:count]
|
168
|
+
API.build_query(options)
|
169
169
|
else
|
170
|
-
|
170
|
+
API.build_query({count: Settings.options[:counts][:search]})
|
171
171
|
end
|
172
172
|
"#{@users_url}search?q=#{words}&access_token=#{Settings.user_token}#{@options_list}"
|
173
173
|
end
|
174
174
|
|
175
175
|
def search_annotations anno, options
|
176
|
-
if options[:count]
|
177
|
-
|
176
|
+
@options_list = if options[:count]
|
177
|
+
API.build_query(options)
|
178
178
|
else
|
179
|
-
|
179
|
+
API.build_query({count: Settings.options[:counts][:search]})
|
180
180
|
end
|
181
181
|
"#{@posts_url}search?annotation_types=#{anno}&access_token=#{Settings.user_token}#{@options_list}"
|
182
182
|
end
|
183
183
|
|
184
184
|
def search_messages channel_id, words, options
|
185
|
-
if options[:count]
|
186
|
-
|
185
|
+
@options_list = if options[:count]
|
186
|
+
API.build_query(options)
|
187
187
|
else
|
188
|
-
|
188
|
+
API.build_query({count: Settings.options[:counts][:search]})
|
189
189
|
end
|
190
190
|
"#{@channels_url}messages/search?query=#{words}&channel_ids=#{channel_id}&access_token=#{Settings.user_token}#{@options_list}"
|
191
191
|
end
|
@@ -200,15 +200,14 @@ module Ayadn
|
|
200
200
|
end
|
201
201
|
|
202
202
|
def single_post(post_id, options)
|
203
|
-
@
|
204
|
-
"#{@posts_url}#{post_id}?access_token=#{Settings.user_token}#{@options_list}"
|
203
|
+
"#{@posts_url}#{post_id}?access_token=#{Settings.user_token}#{API.build_query(options)}"
|
205
204
|
end
|
206
205
|
|
207
206
|
def files_list(options)
|
208
|
-
if options[:count]
|
209
|
-
|
207
|
+
@options_list = if options[:count]
|
208
|
+
API.build_query(options)
|
210
209
|
else
|
211
|
-
|
210
|
+
API.build_query({count: Settings.options[:counts][:files]})
|
212
211
|
end
|
213
212
|
"#{@users_url}me/files?access_token=#{Settings.user_token}#{@options_list}"
|
214
213
|
end
|
data/lib/ayadn/errors.rb
CHANGED
@@ -11,9 +11,7 @@ module Ayadn
|
|
11
11
|
Logs.rec.debug "STACK: #{caller}"
|
12
12
|
Logs.rec.error "--END--"
|
13
13
|
puts "\n(error logged in #{Settings.config[:paths][:log]}/ayadn.log)\n".color(:blue)
|
14
|
-
|
15
|
-
raise error
|
16
|
-
end
|
14
|
+
Debug.err error
|
17
15
|
exit
|
18
16
|
end
|
19
17
|
def self.error(status)
|
data/lib/ayadn/fileops.rb
CHANGED
data/lib/ayadn/mark.rb
CHANGED
data/lib/ayadn/nicerank.rb
CHANGED
@@ -4,7 +4,6 @@ module Ayadn
|
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@url = 'http://api.search-adn.net/user/nicerank?ids='
|
7
|
-
@show_debug = Settings.options[:timeline][:show_debug]
|
8
7
|
end
|
9
8
|
|
10
9
|
def get_ranks stream
|
@@ -27,6 +26,7 @@ module Ayadn
|
|
27
26
|
expire = Settings.options[:nicerank][:cache] * 3600
|
28
27
|
end
|
29
28
|
end
|
29
|
+
|
30
30
|
db_ranks.each do |id, ranks|
|
31
31
|
if ranks.nil? || (Time.now - ranks[:cached]) > expire
|
32
32
|
get_these << id
|
@@ -40,17 +40,17 @@ module Ayadn
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
Debug.how_many_ranks niceranks, get_these
|
44
44
|
|
45
45
|
unless get_these.empty?
|
46
46
|
resp = JSON.parse(CNX.get "#{@url}#{get_these.join(',')}")
|
47
47
|
|
48
48
|
if resp['meta']['code'] != 200
|
49
|
-
|
49
|
+
Debug.niceranks_error resp
|
50
50
|
Errors.nr "REQUESTED: #{get_these.join(' ')}"
|
51
51
|
Errors.nr "RESPONSE: #{resp}"
|
52
52
|
if niceranks
|
53
|
-
|
53
|
+
Debug.ranks_pool niceranks
|
54
54
|
return niceranks
|
55
55
|
else
|
56
56
|
return {}
|
@@ -66,7 +66,7 @@ module Ayadn
|
|
66
66
|
}
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
Debug.total_ranks niceranks
|
70
70
|
end
|
71
71
|
|
72
72
|
Databases.add_niceranks niceranks
|
@@ -74,36 +74,5 @@ module Ayadn
|
|
74
74
|
niceranks
|
75
75
|
end
|
76
76
|
|
77
|
-
private
|
78
|
-
|
79
|
-
def how_many niceranks, get_these
|
80
|
-
deb = "=====\n"
|
81
|
-
deb << "NR from DB:\t#{niceranks}\n\n"
|
82
|
-
deb << "NR to get:\t#{get_these}\n"
|
83
|
-
deb << "=====\n"
|
84
|
-
puts deb.color(Settings.options[:colors][:debug])
|
85
|
-
end
|
86
|
-
|
87
|
-
def in_pool niceranks
|
88
|
-
deb = "=====\n"
|
89
|
-
deb << "NR in pool:\t#{niceranks}\n"
|
90
|
-
deb << "=====\n"
|
91
|
-
puts deb.color(Settings.options[:colors][:debug])
|
92
|
-
end
|
93
|
-
|
94
|
-
def nr_error resp
|
95
|
-
deb = "=====\n"
|
96
|
-
deb << "NR Error:\t#{resp['meta']}"
|
97
|
-
deb << "=====\n"
|
98
|
-
puts deb.color(Settings.options[:colors][:debug])
|
99
|
-
end
|
100
|
-
|
101
|
-
def got niceranks
|
102
|
-
deb = "=====\n"
|
103
|
-
deb << "NiceRanks:\t#{niceranks}\n\n"
|
104
|
-
deb << "DB size:\t#{Databases.nicerank.size}\n"
|
105
|
-
deb << "=====\n"
|
106
|
-
puts deb.color(Settings.options[:colors][:debug])
|
107
|
-
end
|
108
77
|
end
|
109
78
|
end
|
data/lib/ayadn/pinboard.rb
CHANGED
@@ -8,9 +8,9 @@ module Ayadn
|
|
8
8
|
|
9
9
|
def ask_credentials
|
10
10
|
begin
|
11
|
-
puts
|
11
|
+
puts Status.pin_username
|
12
12
|
pin_username = STDIN.gets.chomp()
|
13
|
-
puts
|
13
|
+
puts Status.pin_password
|
14
14
|
pin_password = STDIN.noecho(&:gets).chomp()
|
15
15
|
rescue Interrupt
|
16
16
|
abort(Status.canceled)
|
data/lib/ayadn/post.rb
CHANGED
@@ -56,8 +56,7 @@ module Ayadn
|
|
56
56
|
post << buffer
|
57
57
|
end
|
58
58
|
rescue Interrupt
|
59
|
-
#
|
60
|
-
Errors.info "Write post: canceled."
|
59
|
+
#Errors.info "Write post: canceled."
|
61
60
|
abort(Status.canceled)
|
62
61
|
end
|
63
62
|
post
|
@@ -93,10 +92,10 @@ module Ayadn
|
|
93
92
|
send_content(url, payload_basic(text))
|
94
93
|
end
|
95
94
|
|
96
|
-
def send_log(data)
|
97
|
-
|
98
|
-
|
99
|
-
end
|
95
|
+
# def send_log(data)
|
96
|
+
# url = Endpoints.new.ayadnlog
|
97
|
+
# send_content(url, payload_log(data))
|
98
|
+
# end
|
100
99
|
|
101
100
|
def send_post(text)
|
102
101
|
url = Endpoints.new.posts_url
|
@@ -114,13 +113,11 @@ module Ayadn
|
|
114
113
|
end
|
115
114
|
|
116
115
|
def check_post_length(lines_array)
|
117
|
-
|
118
|
-
check_length(lines_array, max_size)
|
116
|
+
check_length(lines_array, Settings.config[:post_max_length])
|
119
117
|
end
|
120
118
|
|
121
119
|
def check_message_length(lines_array)
|
122
|
-
|
123
|
-
check_length(lines_array, max_size)
|
120
|
+
check_length(lines_array, Settings.config[:message_max_length])
|
124
121
|
end
|
125
122
|
|
126
123
|
def check_length(lines_array, max_size)
|
@@ -132,7 +129,7 @@ module Ayadn
|
|
132
129
|
exit
|
133
130
|
elsif size > max_size
|
134
131
|
Errors.warn "Canceled: too long (#{size - max_size}chars)"
|
135
|
-
abort(
|
132
|
+
abort(Status.too_long(size, max_size))
|
136
133
|
end
|
137
134
|
end
|
138
135
|
|
@@ -150,7 +147,7 @@ module Ayadn
|
|
150
147
|
end
|
151
148
|
|
152
149
|
def error_text_empty
|
153
|
-
puts
|
150
|
+
puts Status.no_text
|
154
151
|
Errors.warn "-Post without text-"
|
155
152
|
end
|
156
153
|
|
@@ -214,18 +211,18 @@ module Ayadn
|
|
214
211
|
}
|
215
212
|
end
|
216
213
|
|
217
|
-
def payload_log(data)
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
end
|
214
|
+
# def payload_log(data)
|
215
|
+
# extended = annotations
|
216
|
+
# extended << {
|
217
|
+
# "type" => "com.ayadn.log",
|
218
|
+
# "value" => data
|
219
|
+
# }
|
220
|
+
# return {
|
221
|
+
# "text" => "#ayadnlog",
|
222
|
+
# "entities" => entities,
|
223
|
+
# "annotations" => extended
|
224
|
+
# }
|
225
|
+
# end
|
229
226
|
|
230
227
|
end
|
231
228
|
end
|
data/lib/ayadn/scroll.rb
CHANGED
@@ -6,7 +6,6 @@ module Ayadn
|
|
6
6
|
@api = api
|
7
7
|
@view = view
|
8
8
|
@chars = %w{ | / - \\ }
|
9
|
-
@show_debug = Settings.options[:timeline][:show_debug]
|
10
9
|
end
|
11
10
|
|
12
11
|
def method_missing(meth, options)
|
@@ -25,19 +24,8 @@ module Ayadn
|
|
25
24
|
loop do
|
26
25
|
begin
|
27
26
|
stream = get(target, options)
|
28
|
-
|
29
|
-
|
30
|
-
unless stream['data'].empty?
|
31
|
-
niceranks = @nr.get_ranks stream
|
32
|
-
else
|
33
|
-
niceranks = {}
|
34
|
-
end
|
35
|
-
# else
|
36
|
-
# niceranks = {}
|
37
|
-
# end
|
38
|
-
|
39
|
-
debug_stream(stream, options, target) if @show_debug == true
|
40
|
-
|
27
|
+
stream['data'].empty? ? niceranks = {} : niceranks = @nr.get_ranks(stream)
|
28
|
+
Debug.stream stream, options, target
|
41
29
|
target = "explore:#{target}" if explore?(target)
|
42
30
|
show_if_new(stream, options, target, niceranks)
|
43
31
|
target = orig_target if target =~ /explore/
|
@@ -51,14 +39,11 @@ module Ayadn
|
|
51
39
|
|
52
40
|
def mentions(username, options)
|
53
41
|
options = check_raw(options)
|
54
|
-
|
55
|
-
id = user['data']['id']
|
42
|
+
id = @api.get_user(username)['data']['id']
|
56
43
|
loop do
|
57
44
|
begin
|
58
45
|
stream = @api.get_mentions(username, options)
|
59
|
-
|
60
|
-
debug_stream(stream, options, username) if @show_debug == true
|
61
|
-
|
46
|
+
Debug.stream stream, options, username
|
62
47
|
show_if_new(stream, options, "mentions:#{id}")
|
63
48
|
options = save_then_return(stream, options)
|
64
49
|
countdown
|
@@ -70,14 +55,11 @@ module Ayadn
|
|
70
55
|
|
71
56
|
def posts(username, options)
|
72
57
|
options = check_raw(options)
|
73
|
-
|
74
|
-
id = user['data']['id']
|
58
|
+
id = @api.get_user(username)['data']['id']
|
75
59
|
loop do
|
76
60
|
begin
|
77
61
|
stream = @api.get_posts(username, options)
|
78
|
-
|
79
|
-
debug_stream(stream, options, username) if @show_debug == true
|
80
|
-
|
62
|
+
Debug.stream stream, options, username
|
81
63
|
show_if_new(stream, options, "posts:#{id}")
|
82
64
|
options = save_then_return(stream, options)
|
83
65
|
countdown
|
@@ -92,9 +74,7 @@ module Ayadn
|
|
92
74
|
loop do
|
93
75
|
begin
|
94
76
|
stream = @api.get_convo(post_id, options)
|
95
|
-
|
96
|
-
debug_stream(stream, options, post_id) if @show_debug == true
|
97
|
-
|
77
|
+
Debug.stream stream, options, post_id
|
98
78
|
show_if_new(stream, options, "replies:#{post_id}")
|
99
79
|
options = save_then_return(stream, options)
|
100
80
|
countdown
|
@@ -109,9 +89,7 @@ module Ayadn
|
|
109
89
|
loop do
|
110
90
|
begin
|
111
91
|
stream = @api.get_messages(channel_id, options)
|
112
|
-
|
113
|
-
debug_stream(stream, options, channel_id) if @show_debug == true
|
114
|
-
|
92
|
+
Debug.stream stream, options, channel_id
|
115
93
|
show_if_new(stream, options, "channel:#{channel_id}")
|
116
94
|
options = save_then_return(stream, options)
|
117
95
|
countdown
|
@@ -123,20 +101,8 @@ module Ayadn
|
|
123
101
|
|
124
102
|
private
|
125
103
|
|
126
|
-
def debug_stream stream, options, target
|
127
|
-
deb = "+++++\nStream meta:\t#{stream['meta']}\n\n"
|
128
|
-
deb << "Options:\t#{options.inspect}\n\n"
|
129
|
-
deb << "Target:\t\t#{target.inspect}\n\n"
|
130
|
-
deb << "Posts:\t\t#{stream['data'].length}\n+++++\n"
|
131
|
-
puts deb.color(Settings.options[:colors][:debug])
|
132
|
-
end
|
133
|
-
|
134
104
|
def countdown
|
135
|
-
|
136
|
-
waiting
|
137
|
-
else
|
138
|
-
pause
|
139
|
-
end
|
105
|
+
Settings.options[:timeline][:show_spinner] == true ? waiting : pause
|
140
106
|
end
|
141
107
|
|
142
108
|
def clear
|
@@ -179,10 +145,7 @@ module Ayadn
|
|
179
145
|
end
|
180
146
|
|
181
147
|
def waiting
|
182
|
-
|
183
|
-
interval.times do
|
184
|
-
spin
|
185
|
-
end
|
148
|
+
(Settings.options[:scroll][:timer] * 10).times { spin }
|
186
149
|
end
|
187
150
|
|
188
151
|
def pause
|
@@ -226,10 +189,10 @@ module Ayadn
|
|
226
189
|
end
|
227
190
|
|
228
191
|
def show(stream, options, niceranks)
|
229
|
-
|
230
|
-
@view.show_posts(stream['data'], options, niceranks)
|
231
|
-
else
|
192
|
+
if options[:raw]
|
232
193
|
jj stream
|
194
|
+
else
|
195
|
+
@view.show_posts(stream['data'], options, niceranks)
|
233
196
|
end
|
234
197
|
end
|
235
198
|
|
data/lib/ayadn/settings.rb
CHANGED
data/lib/ayadn/status.rb
CHANGED
@@ -247,5 +247,32 @@ module Ayadn
|
|
247
247
|
def self.cache_range
|
248
248
|
"\nPlease enter a number of hours between 3 and 168.\n\n".color(:red)
|
249
249
|
end
|
250
|
+
def self.must_be_in_index
|
251
|
+
"\nNumber must be in the range of the indexed posts.\n".color(:red)
|
252
|
+
end
|
253
|
+
def self.user_404 username
|
254
|
+
"\nUser #{username} doesn't exist. It could be a deleted account.\n".color(:red)
|
255
|
+
end
|
256
|
+
def self.post_404(post_id)
|
257
|
+
"\nImpossible to find #{post_id}. This post may have been deleted.\n".color(:red)
|
258
|
+
end
|
259
|
+
def self.no_alias
|
260
|
+
"\nThis alias doesn't exist.\n\n".color(:red)
|
261
|
+
end
|
262
|
+
def self.no_itunes
|
263
|
+
"\nCanceled: unable to get info from iTunes.\n".color(:red)
|
264
|
+
end
|
265
|
+
def self.pin_username
|
266
|
+
"Please enter your Pinboard username (CTRL+C to cancel): ".color(:green)
|
267
|
+
end
|
268
|
+
def self.pin_password
|
269
|
+
"\nPlease enter your Pinboard password (invisible, CTRL+C to cancel): ".color(:green)
|
270
|
+
end
|
271
|
+
def self.too_long size, max_size
|
272
|
+
"\n\nCanceled: too long. #{max_size} max, #{size - max_size} characters to remove.\n\n\n".color(:red)
|
273
|
+
end
|
274
|
+
def self.no_text
|
275
|
+
"\n\nYou should provide some text.\n\n".color(:red)
|
276
|
+
end
|
250
277
|
end
|
251
278
|
end
|