ayadn 0.6.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.travis.yml +17 -0
- data/Gemfile +14 -0
- data/Guardfile +26 -0
- data/LICENSE.txt +22 -0
- data/MANUAL.md +946 -0
- data/README.md +26 -411
- data/Rakefile +6 -0
- data/ayadn.gemspec +39 -0
- data/bin/ayadn +3 -3
- data/lib/ayadn.rb +12 -25
- data/lib/ayadn/action.rb +1121 -0
- data/lib/ayadn/alias.rb +106 -0
- data/lib/ayadn/api.rb +312 -301
- data/lib/ayadn/app.rb +429 -365
- data/lib/ayadn/authorize.rb +127 -28
- data/lib/ayadn/blacklist.rb +116 -0
- data/lib/ayadn/cnx.rb +105 -0
- data/lib/ayadn/databases.rb +110 -0
- data/lib/ayadn/descriptions.rb +1043 -0
- data/lib/ayadn/endpoints.rb +220 -153
- data/lib/ayadn/errors.rb +37 -0
- data/lib/ayadn/extend.rb +4 -10
- data/lib/ayadn/fileops.rb +48 -0
- data/lib/ayadn/logs.rb +32 -0
- data/lib/ayadn/pinboard.rb +46 -35
- data/lib/ayadn/post.rb +229 -212
- data/lib/ayadn/scroll.rb +251 -0
- data/lib/ayadn/set.rb +377 -0
- data/lib/ayadn/settings.rb +195 -0
- data/lib/ayadn/status.rb +226 -165
- data/lib/ayadn/switch.rb +72 -0
- data/lib/ayadn/version.rb +4 -0
- data/lib/ayadn/view.rb +506 -269
- data/lib/ayadn/workers.rb +362 -0
- data/spec/helpers.rb +19 -0
- data/spec/mock/@ericd.json +160 -0
- data/spec/mock/@m.json +45 -0
- data/spec/mock/checkins.json +1856 -0
- data/spec/mock/fwr_@ayadn.json +1077 -0
- data/spec/mock/posted.json +1 -0
- data/spec/mock/stream.json +1 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/unit/api_spec.rb +61 -0
- data/spec/unit/databases_spec.rb +5 -0
- data/spec/unit/descriptions_spec.rb +9 -0
- data/spec/unit/endpoints_spec.rb +35 -0
- data/spec/unit/post_spec.rb +136 -0
- data/spec/unit/status_spec.rb +9 -0
- data/spec/unit/view_spec.rb +119 -0
- data/spec/unit/workers_spec.rb +147 -0
- metadata +216 -40
- data/CHANGELOG.md +0 -250
- data/CONTRIBUTORS.md +0 -5
- data/LICENSE.md +0 -14
- data/lib/ayadn/adn_files.rb +0 -84
- data/lib/ayadn/client-http.rb +0 -226
- data/lib/ayadn/colors.rb +0 -62
- data/lib/ayadn/config.yml +0 -35
- data/lib/ayadn/debug.rb +0 -36
- data/lib/ayadn/files.rb +0 -184
- data/lib/ayadn/get-api.rb +0 -43
- data/lib/ayadn/help.rb +0 -152
- data/lib/ayadn/list.rb +0 -89
- data/lib/ayadn/main.rb +0 -542
- data/lib/ayadn/requires.rb +0 -12
- data/lib/ayadn/skip.rb +0 -27
- data/lib/ayadn/tools.rb +0 -208
- data/lib/ayadn/user-stream.rb +0 -91
- data/lib/ayadn/view-channels.rb +0 -120
- data/lib/ayadn/view-interactions.rb +0 -57
- data/lib/ayadn/view-object.rb +0 -195
- data/lib/experiments.rb +0 -109
data/lib/ayadn/main.rb
DELETED
@@ -1,542 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'pstore'
|
3
|
-
|
4
|
-
# encoding: utf-8
|
5
|
-
class AyaDN
|
6
|
-
def initialize(token)
|
7
|
-
$PROGRAM_NAME = "AyaDN"
|
8
|
-
@token = token
|
9
|
-
@api = AyaDN::API.new(@token)
|
10
|
-
@view = AyaDN::View
|
11
|
-
@last_page_id_path = $tools.ayadn_configuration[:last_page_id_path]
|
12
|
-
@progress_indicator = $tools.ayadn_configuration[:progress_indicator]
|
13
|
-
end
|
14
|
-
def stream
|
15
|
-
$files.makedir(@last_page_id_path)
|
16
|
-
puts @view.new(@hash).showStream
|
17
|
-
end
|
18
|
-
def completeStream
|
19
|
-
$files.makedir(@last_page_id_path)
|
20
|
-
stream, pagination_array = @view.new(@hash).showCompleteStream
|
21
|
-
last_page_id = pagination_array.last
|
22
|
-
puts "\n" if last_page_id != nil
|
23
|
-
return stream, last_page_id
|
24
|
-
end
|
25
|
-
def displayStream(stream)
|
26
|
-
!stream.empty? ? (puts stream) : (puts $status.noNewPosts)
|
27
|
-
end
|
28
|
-
def displayScrollStream(stream)
|
29
|
-
!stream.empty? ? (puts stream) : (print "\r")
|
30
|
-
end
|
31
|
-
def ayadnScroll(value, target)
|
32
|
-
@progress_indicator = true
|
33
|
-
value = "unified" if value == nil
|
34
|
-
if target == nil
|
35
|
-
fileURL = @last_page_id_path + "/last_page_id-#{value}"
|
36
|
-
else
|
37
|
-
fileURL = @last_page_id_path + "/last_page_id-#{value}-#{target}"
|
38
|
-
end
|
39
|
-
loop do
|
40
|
-
begin
|
41
|
-
print "\r \r"
|
42
|
-
#puts "\n"
|
43
|
-
last_page_id = $files.get_last_page_id(fileURL)
|
44
|
-
case value
|
45
|
-
when "unified"
|
46
|
-
@hash = @api.getUnified(last_page_id)
|
47
|
-
when "global"
|
48
|
-
@hash = @api.getGlobal(last_page_id)
|
49
|
-
when "checkins", "photos", "conversations", "trending"
|
50
|
-
@hash = @api.getExplore(value, last_page_id)
|
51
|
-
when "mentions"
|
52
|
-
@hash = @api.getUserMentions(target, last_page_id)
|
53
|
-
when "posts"
|
54
|
-
@hash = @api.getUserPosts(target, last_page_id)
|
55
|
-
end
|
56
|
-
stream, last_page_id = completeStream
|
57
|
-
displayScrollStream(stream)
|
58
|
-
@progress_indicator = false
|
59
|
-
if last_page_id != nil
|
60
|
-
$files.write_last_page_id(fileURL, last_page_id)
|
61
|
-
print "\r "
|
62
|
-
puts "\n"
|
63
|
-
$tools.countdown($tools.config['timeline']['countdown_1'])
|
64
|
-
else
|
65
|
-
print "\rNo new posts ".red
|
66
|
-
sleep 2
|
67
|
-
$tools.countdown($tools.config['timeline']['countdown_2'])
|
68
|
-
end
|
69
|
-
rescue Exception
|
70
|
-
abort($status.stopped)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
def ayadnInteractions
|
75
|
-
puts $status.getInteractions
|
76
|
-
puts @view.new(@api.getInteractions).showInteractions + "\n\n"
|
77
|
-
end
|
78
|
-
def check_count(count, target)
|
79
|
-
@counted = false
|
80
|
-
if count != nil && count.is_integer?
|
81
|
-
case target
|
82
|
-
when "conversations", "photos", "trending"
|
83
|
-
$tools.config['counts']['explore'] = count
|
84
|
-
else
|
85
|
-
$tools.config['counts'][target] = count
|
86
|
-
end
|
87
|
-
@counted = true
|
88
|
-
end
|
89
|
-
end
|
90
|
-
def ayadnGlobal(count=nil)
|
91
|
-
puts $status.getGlobal
|
92
|
-
fileURL = @last_page_id_path + "/last_page_id-global"
|
93
|
-
check_count(count, "global")
|
94
|
-
@hash = @api.getGlobal($files.get_last_page_id(fileURL))
|
95
|
-
stream, last_page_id = completeStream
|
96
|
-
if @counted == false
|
97
|
-
$files.write_last_page_id(fileURL, last_page_id) unless last_page_id == nil
|
98
|
-
end
|
99
|
-
displayStream(stream)
|
100
|
-
puts "\n"
|
101
|
-
end
|
102
|
-
def ayadnUnified(count=nil)
|
103
|
-
fileURL = @last_page_id_path + "/last_page_id-unified"
|
104
|
-
puts $status.getUnified
|
105
|
-
check_count(count, "unified")
|
106
|
-
@hash = @api.getUnified($files.get_last_page_id(fileURL))
|
107
|
-
stream, last_page_id = completeStream
|
108
|
-
if @counted == false
|
109
|
-
$files.write_last_page_id(fileURL, last_page_id) unless last_page_id == nil
|
110
|
-
end
|
111
|
-
displayStream(stream)
|
112
|
-
puts "\n"
|
113
|
-
end
|
114
|
-
def ayadnHashtags(tag)
|
115
|
-
puts $status.getHashtags(tag)
|
116
|
-
@hash = @api.getHashtags(tag)
|
117
|
-
displayStream(completeStream[0])
|
118
|
-
puts "\n"
|
119
|
-
end
|
120
|
-
def ayadnExplore(explore, count=nil)
|
121
|
-
fileURL = @last_page_id_path + "/last_page_id-#{explore}"
|
122
|
-
puts $status.getExplore(explore)
|
123
|
-
check_count(count, explore)
|
124
|
-
@hash = @api.getExplore(explore, $files.get_last_page_id(fileURL))
|
125
|
-
stream, last_page_id = completeStream
|
126
|
-
if @counted == false
|
127
|
-
$files.write_last_page_id(fileURL, last_page_id) unless last_page_id == nil
|
128
|
-
end
|
129
|
-
displayStream(stream)
|
130
|
-
puts "\n"
|
131
|
-
end
|
132
|
-
def ayadnUserMentions(name, count=nil)
|
133
|
-
fileURL = @last_page_id_path + "/last_page_id-mentions-#{name}"
|
134
|
-
puts $status.mentionsUser(name)
|
135
|
-
check_count(count, "mentions")
|
136
|
-
@hash = @api.getUserMentions(name, $files.get_last_page_id(fileURL))
|
137
|
-
stream, last_page_id = completeStream
|
138
|
-
if @counted == false
|
139
|
-
$files.write_last_page_id(fileURL, last_page_id) unless last_page_id == nil
|
140
|
-
end
|
141
|
-
displayStream(stream)
|
142
|
-
puts "\n"
|
143
|
-
end
|
144
|
-
def ayadnUserPosts(name, count=nil)
|
145
|
-
fileURL = @last_page_id_path + "/last_page_id-posts-#{name}"
|
146
|
-
puts $status.postsUser(name)
|
147
|
-
check_count(count, "posts")
|
148
|
-
@hash = @api.getUserPosts(name, $files.get_last_page_id(fileURL))
|
149
|
-
stream, last_page_id = completeStream
|
150
|
-
if @counted == false
|
151
|
-
$files.write_last_page_id(fileURL, last_page_id) unless last_page_id == nil
|
152
|
-
end
|
153
|
-
displayStream(stream)
|
154
|
-
end
|
155
|
-
def ayadnUserInfos(name)
|
156
|
-
puts $status.infosUser(name)
|
157
|
-
puts @view.new(@api.getUserInfos(name)).showUsersInfos(name)
|
158
|
-
end
|
159
|
-
def get_loaded_channels
|
160
|
-
loaded_channels = $files.load_channels
|
161
|
-
channels_with_messages = $files.load_channels_with_messages
|
162
|
-
if loaded_channels != nil
|
163
|
-
puts "Backed-up list of your active channels:\n".green
|
164
|
-
loaded_channels.each do |k,v|
|
165
|
-
puts "Channel: ".cyan + k.brown
|
166
|
-
puts "Title: ".cyan + v.magenta
|
167
|
-
if channels_with_messages != nil && channels_with_messages[k] != nil
|
168
|
-
puts "Last message by @#{channels_with_messages[k]['username']} (#{channels_with_messages[k]['message_date']}): \n".cyan + channels_with_messages[k]['text']
|
169
|
-
end
|
170
|
-
puts "\n"
|
171
|
-
end
|
172
|
-
puts "Do you want to refresh the list? (y/N)".green
|
173
|
-
abort("\nCanceled.\n\n".red) unless STDIN.getch == ("y" || "Y")
|
174
|
-
puts "\n"
|
175
|
-
end
|
176
|
-
end
|
177
|
-
def ayadn_get_channels
|
178
|
-
@hash = @api.get_pm_channels
|
179
|
-
the_channels, channels_list = @view.new(@hash).show_pm_channels
|
180
|
-
puts the_channels
|
181
|
-
@hash = @api.get_channels
|
182
|
-
the_channels, channels_list = @view.new(@hash).show_channels
|
183
|
-
puts the_channels
|
184
|
-
end
|
185
|
-
def ayadnGetMessages(target, action = nil)
|
186
|
-
$files.makedir($tools.ayadn_configuration[:messages_path])
|
187
|
-
@progress_indicator = false
|
188
|
-
if target != nil
|
189
|
-
if !target.is_integer?
|
190
|
-
target = $files.load_channel_id(target)
|
191
|
-
end
|
192
|
-
fileURL = @last_page_id_path + "/last_page_id-channels-#{target}"
|
193
|
-
last_page_id = $files.get_last_page_id(fileURL) unless action == "all"
|
194
|
-
messages_string, last_page_id = @view.new(@api.getMessages(target, last_page_id)).showMessagesFromChannel
|
195
|
-
$files.write_last_page_id(fileURL, last_page_id) unless last_page_id == nil
|
196
|
-
displayStream(messages_string)
|
197
|
-
puts $status.noNewPosts if messages_string == "\n"
|
198
|
-
else
|
199
|
-
puts $status.errorSyntax
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
def ayadnDeletePost(postID)
|
204
|
-
puts $status.deletePost(postID)
|
205
|
-
if @api.goDelete(postID) == nil
|
206
|
-
abort($status.errorAlreadyDeleted)
|
207
|
-
else
|
208
|
-
$tools.checkHTTPResp(@api.http_delete)
|
209
|
-
puts $status.postDeleted
|
210
|
-
exit
|
211
|
-
end
|
212
|
-
end
|
213
|
-
def ayadn_delete_message(channel_id, message_id)
|
214
|
-
puts "\nDeleting message #{message_id} in channel #{channel_id}".green
|
215
|
-
@url = @api.unique_message(channel_id, message_id)
|
216
|
-
$tools.checkHTTPResp(@api.http_delete)
|
217
|
-
puts "\nDone!\n".green
|
218
|
-
end
|
219
|
-
|
220
|
-
def ayadnWhoReposted(postID)
|
221
|
-
puts $status.whoReposted(postID)
|
222
|
-
@hash = @api.getWhoReposted(postID)
|
223
|
-
abort($status.errorNobodyReposted) if @hash['data'].empty?
|
224
|
-
puts @view.new(@hash).showUsersList
|
225
|
-
end
|
226
|
-
def ayadnWhoStarred(postID)
|
227
|
-
puts $status.whoStarred(postID)
|
228
|
-
@hash = @api.getWhoStarred(postID)
|
229
|
-
abort($status.errorNobodyStarred) if @hash['data'].empty?
|
230
|
-
puts @view.new(@hash).showUsersList
|
231
|
-
end
|
232
|
-
def ayadnStarredPosts(name, count=nil)
|
233
|
-
puts $status.starsUser(name)
|
234
|
-
check_count(count, "starred")
|
235
|
-
@hash = @api.getStarredPosts(name)
|
236
|
-
displayStream(completeStream[0])
|
237
|
-
end
|
238
|
-
def ayadnConversation(postID)
|
239
|
-
puts $status.getPostReplies(postID)
|
240
|
-
@hash = @api.getPostReplies(postID)
|
241
|
-
displayStream(completeStream[0])
|
242
|
-
end
|
243
|
-
def ayadnPostInfos(postID)
|
244
|
-
puts $status.infosPost(postID)
|
245
|
-
puts @view.new(@api.getPostInfos(postID)).showPostInfos(postID, false)
|
246
|
-
end
|
247
|
-
def ayadnLoadPost(postID)
|
248
|
-
puts $status.infosPost(postID)
|
249
|
-
puts @view.new(nil).buildPostInfo(load_post(postID), true)
|
250
|
-
end
|
251
|
-
def load_post(post_id)
|
252
|
-
fileContent = {}
|
253
|
-
File.open("#{$tools.ayadn_configuration[:posts_path]}/#{post_id}.post", "r") do |f|
|
254
|
-
fileContent = f.gets
|
255
|
-
end
|
256
|
-
eval(fileContent)
|
257
|
-
end
|
258
|
-
def ayadnSavePost(postID)
|
259
|
-
@progress_indicator = false
|
260
|
-
name = postID.to_s
|
261
|
-
posts_path = $tools.ayadn_configuration[:posts_path]
|
262
|
-
$files.makedir(posts_path)
|
263
|
-
file = "/#{name}.post"
|
264
|
-
fileURL = posts_path + file
|
265
|
-
abort("\nYou already saved this post.\n\n".red) if File.exists?(fileURL)
|
266
|
-
puts "\nLoading post from App.net...".green + name.brown
|
267
|
-
puts $status.savingFile(name, posts_path, file)
|
268
|
-
f = File.new(fileURL, "w")
|
269
|
-
resp = @api.getSinglePost(postID)
|
270
|
-
f.puts(resp['data'])
|
271
|
-
f.close
|
272
|
-
puts "\nSuccessfully saved the post.\n\n".green
|
273
|
-
exit
|
274
|
-
end
|
275
|
-
|
276
|
-
def ayadnSearch(value)
|
277
|
-
@hash = @api.getSearch(value)
|
278
|
-
displayStream(completeStream[0])
|
279
|
-
end
|
280
|
-
|
281
|
-
def ayadnFollowing(action, name)
|
282
|
-
@progress_indicator = false
|
283
|
-
following = @api.getUserFollowInfo(name)
|
284
|
-
if action == "follow"
|
285
|
-
if following[:you_follow]
|
286
|
-
abort("You're already following this user.\n\n".red)
|
287
|
-
else
|
288
|
-
@api.followUser(name)
|
289
|
-
puts "\nYou just followed user ".green + "#{name}".brown + "\n\n"
|
290
|
-
end
|
291
|
-
elsif action == "unfollow"
|
292
|
-
if following[:you_follow]
|
293
|
-
@api.unfollowUser(name)
|
294
|
-
puts "\nYou just unfollowed user ".green + "#{name}".brown + "\n\n"
|
295
|
-
else
|
296
|
-
abort("You're already not following this user.\n\n".red)
|
297
|
-
end
|
298
|
-
else
|
299
|
-
abort($status.errorSyntax)
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
def ayadnMuting(action, name)
|
304
|
-
@progress_indicator = false
|
305
|
-
you_muted = @api.getUserMuteInfo(name)
|
306
|
-
if action == "mute"
|
307
|
-
if you_muted
|
308
|
-
abort("You've already muted this user.\n\n".red)
|
309
|
-
else
|
310
|
-
@api.muteUser(name)
|
311
|
-
puts "\nYou just muted user ".green + "#{name}".brown + "\n\n"
|
312
|
-
end
|
313
|
-
elsif action == "unmute"
|
314
|
-
if you_muted
|
315
|
-
@api.unmuteUser(name)
|
316
|
-
puts "\nYou just unmuted user ".green + "#{name}".brown + "\n\n"
|
317
|
-
else
|
318
|
-
abort("This user is not muted.\n\n".red)
|
319
|
-
end
|
320
|
-
else
|
321
|
-
abort($status.errorSyntax)
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
def ayadnBlocking(action, name)
|
326
|
-
@progress_indicator = false
|
327
|
-
you_blocked = @api.getUserBlockInfo(name)
|
328
|
-
if action == "block"
|
329
|
-
if you_blocked
|
330
|
-
abort("\nYou've already blocked this user.\n\n".red)
|
331
|
-
else
|
332
|
-
puts "\nAre you sure you want to block ".red + "#{name} ".brown + "?\n\nIt will mute him/her, then both of you will automatically unfollow each other (if applicable).".red + "\n\n(y/N)?\n\n".brown
|
333
|
-
case STDIN.getch
|
334
|
-
when "y", "Y"
|
335
|
-
@api.blockUser(name)
|
336
|
-
puts "\nYou just blocked user ".green + "#{name}".brown + "\n\n"
|
337
|
-
end
|
338
|
-
puts $status.canceled
|
339
|
-
end
|
340
|
-
elsif action == "unblock"
|
341
|
-
if you_blocked
|
342
|
-
@api.unblockUser(name)
|
343
|
-
puts "\nYou just unblocked user ".green + "#{name}".brown + "\n\n"
|
344
|
-
else
|
345
|
-
abort("\nThis user is not blocked.\n\n".red)
|
346
|
-
end
|
347
|
-
else
|
348
|
-
abort($status.errorSyntax)
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
def ayadnStarringPost(action, postID)
|
353
|
-
@progress_indicator = false
|
354
|
-
@hash = @api.getSinglePost(postID)
|
355
|
-
post_data = @hash['data']
|
356
|
-
you_starred = post_data['you_starred']
|
357
|
-
is_repost = post_data['repost_of']
|
358
|
-
if is_repost != nil
|
359
|
-
puts $status.errorIsRepost(postID)
|
360
|
-
puts "Redirecting to the original post.\n".cyan
|
361
|
-
postID = is_repost['id']
|
362
|
-
you_starred = is_repost['you_starred']
|
363
|
-
end
|
364
|
-
if action == "star"
|
365
|
-
if you_starred == false
|
366
|
-
puts "\nStarring post ".green + "#{postID}\n".brown
|
367
|
-
@api.starPost(postID)
|
368
|
-
puts "\nSuccessfully starred the post.\n\n".green
|
369
|
-
else
|
370
|
-
abort("Canceled: the post is already starred.\n\n".red)
|
371
|
-
end
|
372
|
-
elsif action == "unstar"
|
373
|
-
if you_starred == false
|
374
|
-
abort("Canceled: the post wasn't already starred.\n\n".red)
|
375
|
-
else
|
376
|
-
puts "\nUnstarring post ".green + "#{postID}\n".brown
|
377
|
-
@api.unstarPost(postID)
|
378
|
-
puts "\nSuccessfully unstarred the post.\n\n".green
|
379
|
-
end
|
380
|
-
else
|
381
|
-
abort("\nsyntax error\n".red)
|
382
|
-
end
|
383
|
-
end
|
384
|
-
def ayadnReposting(action, postID)
|
385
|
-
@progress_indicator = false
|
386
|
-
@hash = @api.getSinglePost(postID)
|
387
|
-
post_data = @hash['data']
|
388
|
-
is_repost = post_data['repost_of']
|
389
|
-
you_reposted = post_data['you_reposted']
|
390
|
-
if is_repost != nil && you_reposted == false
|
391
|
-
puts $status.errorIsRepost(postID)
|
392
|
-
puts "Redirecting to the original post.\n".cyan
|
393
|
-
postID = is_repost['id']
|
394
|
-
you_reposted = is_repost['you_reposted']
|
395
|
-
end
|
396
|
-
if action == "repost"
|
397
|
-
if you_reposted
|
398
|
-
abort("Canceled: you already reposted this post.\n\n".red)
|
399
|
-
else
|
400
|
-
puts "\nReposting post ".green + "#{postID}\n".brown
|
401
|
-
@api.repostPost(postID)
|
402
|
-
puts "\nSuccessfully reposted the post.\n\n".green
|
403
|
-
end
|
404
|
-
elsif action == "unrepost"
|
405
|
-
if you_reposted
|
406
|
-
puts "\nUnreposting post ".green + "#{postID}\n".brown
|
407
|
-
@api.unrepostPost(postID)
|
408
|
-
puts "\nSuccessfully unreposted the post.\n\n".green
|
409
|
-
else
|
410
|
-
abort("Canceled: this post wasn't reposted by you.\n\n".red)
|
411
|
-
end
|
412
|
-
else
|
413
|
-
abort($status.errorSyntax)
|
414
|
-
end
|
415
|
-
end
|
416
|
-
def ayadnReset(content, option)
|
417
|
-
$files.reset_pagination(content, option)
|
418
|
-
end
|
419
|
-
def ayadn_list_aliases
|
420
|
-
db = PStore.new($tools.ayadn_configuration[:db_path] + "/channels_alias.db")
|
421
|
-
db.transaction do
|
422
|
-
db.roots.each do |root|
|
423
|
-
puts "#{db[root]} ".brown + "=> " + "#{root} ".green
|
424
|
-
end
|
425
|
-
end
|
426
|
-
puts "\n"
|
427
|
-
end
|
428
|
-
def ayadn_alias_channel(channel_id, channel_alias)
|
429
|
-
puts "\nAdding new alias: ".cyan + "#{channel_id} ".brown + "=> " + "#{channel_alias}\n".green
|
430
|
-
unless channel_id.nil? || channel_alias.nil?
|
431
|
-
if channel_id.is_integer?
|
432
|
-
$files.save_channel_alias(channel_id, channel_alias)
|
433
|
-
else
|
434
|
-
puts $status.errorSyntax
|
435
|
-
puts "List of saved aliases: \n".cyan
|
436
|
-
puts ayadn_list_aliases
|
437
|
-
exit
|
438
|
-
end
|
439
|
-
else
|
440
|
-
puts $status.errorSyntax
|
441
|
-
puts "List of saved aliases: \n".cyan
|
442
|
-
puts ayadn_list_aliases
|
443
|
-
exit
|
444
|
-
end
|
445
|
-
puts "List of saved aliases: \n".cyan
|
446
|
-
puts ayadn_list_aliases
|
447
|
-
puts "Done!\n\n".green
|
448
|
-
end
|
449
|
-
def ayadn_nowplaying
|
450
|
-
unless $tools.ayadn_configuration[:platform] =~ /darwin/
|
451
|
-
puts "\nThis feature only works with Mac OS X and iTunes. Sorry.\n\n".red
|
452
|
-
exit
|
453
|
-
end
|
454
|
-
begin
|
455
|
-
track = `osascript -e 'tell application "iTunes"' -e 'set trackName to name of current track' -e 'return trackName' -e 'end tell'`
|
456
|
-
artist = `osascript -e 'tell application "iTunes"' -e 'set trackArtist to artist of current track' -e 'return trackArtist' -e 'end tell'`
|
457
|
-
rescue => e
|
458
|
-
puts "\n\nError: #{e}\n\n".red
|
459
|
-
exit
|
460
|
-
end
|
461
|
-
track.chomp!
|
462
|
-
artist.chomp!
|
463
|
-
if track.length == 0 || artist.length == 0
|
464
|
-
abort("\nCanceled: couldn't get enough information (empty field).\n\n".red)
|
465
|
-
end
|
466
|
-
text_to_post = "#nowplaying '#{track}' by #{artist}"
|
467
|
-
puts "\nAyaDN will post this to your timeline:\n\n".cyan
|
468
|
-
puts text_to_post + "\n\n"
|
469
|
-
puts "Do you confirm? (y/N) ".brown
|
470
|
-
abort("\nCanceled.\n\n".red) unless STDIN.getch == ("y" || "Y")
|
471
|
-
puts "\n"
|
472
|
-
ayadnSendPost(text_to_post, nil)
|
473
|
-
end
|
474
|
-
def ayadn_does(params)
|
475
|
-
target_name, source_name = params[3].dup, params[1].dup
|
476
|
-
case params[2]
|
477
|
-
when "follow", "follows", "following", "followed"
|
478
|
-
fw = []
|
479
|
-
target_name[0,0] = '@' if target_name[0] != "@"
|
480
|
-
source_name[0,0] = '@' if source_name[0] != "@"
|
481
|
-
real_target_name = target_name.dup
|
482
|
-
real_target_name[0] = ''
|
483
|
-
source_list = @api.getFollowings(source_name, nil)
|
484
|
-
source_list['data'].each {|user| fw << user['username']}
|
485
|
-
min_id, more = source_list['meta']['min_id'], source_list['meta']['more']
|
486
|
-
if more
|
487
|
-
loop do
|
488
|
-
source_list = @api.getFollowings(source_name, min_id)
|
489
|
-
break if source_list['meta']['more'] == false
|
490
|
-
source_list['data'].each {|user| fw << user['username']}
|
491
|
-
min_id = source_list['meta']['min_id']
|
492
|
-
end
|
493
|
-
end
|
494
|
-
@f = false
|
495
|
-
fw.each do |name|
|
496
|
-
if name == real_target_name
|
497
|
-
@f = true
|
498
|
-
break
|
499
|
-
end
|
500
|
-
end
|
501
|
-
if @f
|
502
|
-
puts "\nYes, " + "#{source_name} ".green + "follows " + "#{target_name}\n\n".green
|
503
|
-
else
|
504
|
-
puts "\nNo, " + "#{source_name} ".magenta + "doesn't follow " + "#{target_name}\n\n".magenta
|
505
|
-
end
|
506
|
-
else
|
507
|
-
puts $status.errorSyntax
|
508
|
-
end
|
509
|
-
end
|
510
|
-
def ayadn_show_options
|
511
|
-
puts "\nCurrent options in ".cyan + "config.yml\n".magenta
|
512
|
-
$tools.config.each do |k,v|
|
513
|
-
puts "#{k.capitalize}:".cyan
|
514
|
-
v.each do |x,y|
|
515
|
-
puts "\t#{x.green} => #{y.to_s.brown}"
|
516
|
-
end
|
517
|
-
end
|
518
|
-
puts "\n"
|
519
|
-
puts "AyaDN local data: \n".magenta
|
520
|
-
puts "Posts path:".cyan
|
521
|
-
puts "\t" + $tools.ayadn_configuration[:posts_path].brown + "/".brown
|
522
|
-
puts "Messages path:".cyan
|
523
|
-
puts "\t" + $tools.ayadn_configuration[:messages_path].brown + "/".brown
|
524
|
-
puts "Lists path:".cyan
|
525
|
-
puts "\t" + $tools.ayadn_configuration[:lists_path].brown + "/".brown
|
526
|
-
puts "Files path:".cyan
|
527
|
-
puts "\t" + $tools.ayadn_configuration[:files_path].brown + "/".brown
|
528
|
-
puts "Database path:".cyan
|
529
|
-
puts "\t" + $tools.ayadn_configuration[:db_path].brown + "/".brown
|
530
|
-
puts "\n"
|
531
|
-
puts "AyaDN system configuration: \n".magenta
|
532
|
-
puts "Authorization token path:".cyan
|
533
|
-
puts "\t" + $tools.ayadn_configuration[:authorization_path].brown + "/".brown
|
534
|
-
puts "API configuration path:".cyan
|
535
|
-
puts "\t" + $tools.ayadn_configuration[:api_config_path].brown + "/".brown
|
536
|
-
puts "Pagination data path:".cyan
|
537
|
-
puts "\t" + $tools.ayadn_configuration[:last_page_id_path].brown + "/".brown
|
538
|
-
puts "Detected platform:".cyan
|
539
|
-
puts "\t" + $tools.ayadn_configuration[:platform].brown
|
540
|
-
puts "\n"
|
541
|
-
end
|
542
|
-
end
|