ayadn 0.6.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +20 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +17 -0
  5. data/Gemfile +14 -0
  6. data/Guardfile +26 -0
  7. data/LICENSE.txt +22 -0
  8. data/MANUAL.md +946 -0
  9. data/README.md +26 -411
  10. data/Rakefile +6 -0
  11. data/ayadn.gemspec +39 -0
  12. data/bin/ayadn +3 -3
  13. data/lib/ayadn.rb +12 -25
  14. data/lib/ayadn/action.rb +1121 -0
  15. data/lib/ayadn/alias.rb +106 -0
  16. data/lib/ayadn/api.rb +312 -301
  17. data/lib/ayadn/app.rb +429 -365
  18. data/lib/ayadn/authorize.rb +127 -28
  19. data/lib/ayadn/blacklist.rb +116 -0
  20. data/lib/ayadn/cnx.rb +105 -0
  21. data/lib/ayadn/databases.rb +110 -0
  22. data/lib/ayadn/descriptions.rb +1043 -0
  23. data/lib/ayadn/endpoints.rb +220 -153
  24. data/lib/ayadn/errors.rb +37 -0
  25. data/lib/ayadn/extend.rb +4 -10
  26. data/lib/ayadn/fileops.rb +48 -0
  27. data/lib/ayadn/logs.rb +32 -0
  28. data/lib/ayadn/pinboard.rb +46 -35
  29. data/lib/ayadn/post.rb +229 -212
  30. data/lib/ayadn/scroll.rb +251 -0
  31. data/lib/ayadn/set.rb +377 -0
  32. data/lib/ayadn/settings.rb +195 -0
  33. data/lib/ayadn/status.rb +226 -165
  34. data/lib/ayadn/switch.rb +72 -0
  35. data/lib/ayadn/version.rb +4 -0
  36. data/lib/ayadn/view.rb +506 -269
  37. data/lib/ayadn/workers.rb +362 -0
  38. data/spec/helpers.rb +19 -0
  39. data/spec/mock/@ericd.json +160 -0
  40. data/spec/mock/@m.json +45 -0
  41. data/spec/mock/checkins.json +1856 -0
  42. data/spec/mock/fwr_@ayadn.json +1077 -0
  43. data/spec/mock/posted.json +1 -0
  44. data/spec/mock/stream.json +1 -0
  45. data/spec/spec_helper.rb +14 -0
  46. data/spec/unit/api_spec.rb +61 -0
  47. data/spec/unit/databases_spec.rb +5 -0
  48. data/spec/unit/descriptions_spec.rb +9 -0
  49. data/spec/unit/endpoints_spec.rb +35 -0
  50. data/spec/unit/post_spec.rb +136 -0
  51. data/spec/unit/status_spec.rb +9 -0
  52. data/spec/unit/view_spec.rb +119 -0
  53. data/spec/unit/workers_spec.rb +147 -0
  54. metadata +216 -40
  55. data/CHANGELOG.md +0 -250
  56. data/CONTRIBUTORS.md +0 -5
  57. data/LICENSE.md +0 -14
  58. data/lib/ayadn/adn_files.rb +0 -84
  59. data/lib/ayadn/client-http.rb +0 -226
  60. data/lib/ayadn/colors.rb +0 -62
  61. data/lib/ayadn/config.yml +0 -35
  62. data/lib/ayadn/debug.rb +0 -36
  63. data/lib/ayadn/files.rb +0 -184
  64. data/lib/ayadn/get-api.rb +0 -43
  65. data/lib/ayadn/help.rb +0 -152
  66. data/lib/ayadn/list.rb +0 -89
  67. data/lib/ayadn/main.rb +0 -542
  68. data/lib/ayadn/requires.rb +0 -12
  69. data/lib/ayadn/skip.rb +0 -27
  70. data/lib/ayadn/tools.rb +0 -208
  71. data/lib/ayadn/user-stream.rb +0 -91
  72. data/lib/ayadn/view-channels.rb +0 -120
  73. data/lib/ayadn/view-interactions.rb +0 -57
  74. data/lib/ayadn/view-object.rb +0 -195
  75. data/lib/experiments.rb +0 -109
data/lib/ayadn/app.rb CHANGED
@@ -1,367 +1,431 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: utf-8
3
-
4
- puts "\n\nAYADN".red + " - " + "App.net command-line client\n".brown
5
-
6
- $status = AyaDN::ClientStatus.new
7
- $tools = AyaDN::Tools.new
8
- $files = AyaDN::Files.new
9
- $files.makedir($tools.ayadn_configuration[:db_path])
10
-
11
- token = $files.auth_read
12
- if token != nil
13
- client = AyaDN.new(token)
14
- client.configAPI
15
- else
16
- puts $status.errorNotAuthorized
17
- AyaDN.new(nil).ayadnAuthorize(nil)
18
- exit
2
+ module Ayadn
3
+ class App < Thor
4
+ package_name "Ayadn"
5
+
6
+ %w{action api descriptions endpoints cnx view workers settings post status extend databases fileops logs pinboard set alias errors blacklist scroll authorize switch}.each { |r| require_relative "#{r}" }
7
+
8
+ desc "timeline", "Show your App.net timeline, aka the Unified Stream (-tl)"
9
+ map "unified" => :timeline
10
+ map "-tl" => :timeline
11
+ long_desc Descriptions.unified
12
+ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream"
13
+ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new
14
+ option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
15
+ option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
16
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
17
+ def timeline
18
+ Action.new.unified(options)
19
+ end
20
+
21
+ desc "checkins", "Show the Checkins Stream (-ck)"
22
+ map "-ck" => :checkins
23
+ long_desc Descriptions.checkins
24
+ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream"
25
+ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new
26
+ option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
27
+ option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
28
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
29
+ def checkins
30
+ Action.new.checkins(options)
31
+ end
32
+
33
+ desc "global", "Show the Global Stream (-gl)"
34
+ map "-gl" => :global
35
+ long_desc Descriptions.global
36
+ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream"
37
+ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new
38
+ option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
39
+ option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
40
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
41
+ def global
42
+ Action.new.global(options)
43
+ end
44
+
45
+ desc "trending", "Show the Trending Stream (-tr)"
46
+ map "-tr" => :trending
47
+ long_desc Descriptions.trending
48
+ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream"
49
+ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new
50
+ option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
51
+ option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
52
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
53
+ def trending
54
+ Action.new.trending(options)
55
+ end
56
+
57
+ # desc "photos", "Show the Photos Stream (-ph)"
58
+ # map "-ph" => :photos
59
+ # long_desc Descriptions.photos
60
+ # option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream"
61
+ # option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new
62
+ # option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
63
+ # option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
64
+ # option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
65
+ # def photos
66
+ # Action.new.photos(options)
67
+ # end
68
+
69
+ desc "conversations", "Show the Conversations Stream (-cq)"
70
+ map "-cq" => :conversations
71
+ long_desc Descriptions.conversations
72
+ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream"
73
+ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new
74
+ option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
75
+ option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
76
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
77
+ def conversations
78
+ Action.new.conversations(options)
79
+ end
80
+
81
+ desc "mentions @USERNAME", "Show posts containing a mention of @username (-m)"
82
+ map "-m" => :mentions
83
+ long_desc Descriptions.mentions
84
+ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream"
85
+ option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
86
+ option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
87
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
88
+ def mentions(*username)
89
+ Action.new.mentions(username, options)
90
+ end
91
+
92
+ desc "userposts @USERNAME", "Show posts by @username (-up)"
93
+ map "-up" => :userposts
94
+ long_desc Descriptions.posts
95
+ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream"
96
+ option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
97
+ option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
98
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
99
+ def userposts(*username)
100
+ Action.new.posts(username, options)
101
+ end
102
+
103
+ desc "interactions", "Show your recent ADN activity (-int)"
104
+ map "-int" => :interactions
105
+ long_desc Descriptions.interactions
106
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
107
+ def interactions
108
+ Action.new.interactions(options)
109
+ end
110
+
111
+ desc "whatstarred @USERNAME", "Show posts starred by @username (-was)"
112
+ map "-was" => :whatstarred
113
+ long_desc Descriptions.whatstarred
114
+ option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
115
+ option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
116
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
117
+ def whatstarred(*username)
118
+ Action.new.whatstarred(username, options)
119
+ end
120
+
121
+ desc "whoreposted POST", "List users who reposted a post (-wor)"
122
+ map "-wor" => :whoreposted
123
+ long_desc Descriptions.whoreposted
124
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
125
+ def whoreposted(post_id)
126
+ Action.new.whoreposted(post_id, options)
127
+ end
128
+
129
+ desc "whostarred POST", "List users who starred a post (-wos)"
130
+ map "-wos" => :whostarred
131
+ long_desc Descriptions.whostarred
132
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
133
+ def whostarred(post_id)
134
+ Action.new.whostarred(post_id, options)
135
+ end
136
+
137
+ desc "convo POST", "Show the conversation thread around a post (-co)"
138
+ map "-co" => :convo
139
+ map "thread" => :convo
140
+ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream"
141
+ option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
142
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
143
+ long_desc Descriptions.convo
144
+ def convo(post_id)
145
+ Action.new.convo(post_id, options)
146
+ end
147
+
148
+ desc "followings @USERNAME", "List users @username is following (-fwg)"
149
+ map "-fwg" => :followings
150
+ long_desc Descriptions.followings
151
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
152
+ def followings(*username)
153
+ Action.new.followings(username, options)
154
+ end
155
+
156
+ desc "followers @USERNAME", "List users following @username (-fwr)"
157
+ map "-fwr" => :followers
158
+ long_desc Descriptions.followers
159
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
160
+ def followers(*username)
161
+ Action.new.followers(username, options)
162
+ end
163
+
164
+ desc "muted", "List the users you muted (-mtd)"
165
+ map "-mtd" => :muted
166
+ long_desc Descriptions.muted
167
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
168
+ def muted
169
+ Action.new.muted(options)
170
+ end
171
+
172
+ desc "blocked", "List the users you blocked (-bkd)"
173
+ map "-bkd" => :blocked
174
+ long_desc Descriptions.blocked
175
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
176
+ def blocked
177
+ Action.new.blocked(options)
178
+ end
179
+
180
+ desc "hashtag HASHTAG", "Show recent posts containing #HASHTAG (-t)"
181
+ map "-t" => :hashtag
182
+ long_desc Descriptions.hashtag
183
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
184
+ def hashtag(hashtag)
185
+ Action.new.hashtag(hashtag, options)
186
+ end
187
+
188
+ desc "search WORD(S)", "Show recents posts containing WORD(S) (-s)"
189
+ map "-s" => :search
190
+ long_desc Descriptions.search
191
+ option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
192
+ option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
193
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
194
+ def search(*words)
195
+ Action.new.search(words.join(","), options)
196
+ end
197
+
198
+ desc "settings", "List current Ayadn settings (-sg)"
199
+ map "-sg" => :settings
200
+ long_desc Descriptions.settings
201
+ def settings
202
+ Action.new.view_settings
203
+ end
204
+
205
+ desc "userinfo @USERNAME", "Show detailed informations about @username (-ui)"
206
+ map "-ui" => :userinfo
207
+ long_desc Descriptions.userinfo
208
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
209
+ def userinfo(*username)
210
+ Action.new.userinfo(username, options)
211
+ end
212
+
213
+ desc "postinfo POST", "Show detailed informations about a post (-pi)"
214
+ map "-pi" => :postinfo
215
+ long_desc Descriptions.postinfo
216
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
217
+ def postinfo(post_id)
218
+ Action.new.postinfo(post_id, options)
219
+ end
220
+
221
+ desc "files", "List your files (-fl)"
222
+ map "-fl" => :files
223
+ long_desc Descriptions.files
224
+ option :count, aliases: "-c", type: :numeric, desc: "Specify the number of files to display"
225
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
226
+ option :all, aliases: "-a", type: :boolean, desc: "Retrieve the list of all your files"
227
+ def files
228
+ Action.new.files(options)
229
+ end
230
+
231
+ desc "delete POST", "Delete a post (-D)"
232
+ map "-D" => :delete
233
+ long_desc Descriptions.delete
234
+ def delete(post_id)
235
+ Action.new.delete(post_id)
236
+ end
237
+
238
+ desc "unfollow @USERNAME", "Unfollow @username (-UF)"
239
+ map "-UF" => :unfollow
240
+ long_desc Descriptions.unfollow
241
+ def unfollow(*username)
242
+ Action.new.unfollow(username)
243
+ end
244
+
245
+ desc "unmute @USERNAME", "Unmute @username (-UM)"
246
+ map "-UM" => :unmute
247
+ long_desc Descriptions.unmute
248
+ def unmute(*username)
249
+ Action.new.unmute(username)
250
+ end
251
+
252
+ desc "unblock @USERNAME", "Unblock @username (-UB)"
253
+ map "-UB" => :unblock
254
+ long_desc Descriptions.unblock
255
+ def unblock(*username)
256
+ Action.new.unblock(username)
257
+ end
258
+
259
+ desc "unrepost POST", "Unrepost a post (-UR)"
260
+ map "-UR" => :unrepost
261
+ long_desc Descriptions.unrepost
262
+ def unrepost(post_id)
263
+ Action.new.unrepost(post_id)
264
+ end
265
+
266
+ desc "unstar POST", "Unstar a post (-US)"
267
+ map "-US" => :unstar
268
+ long_desc Descriptions.unstar
269
+ def unstar(post_id)
270
+ Action.new.unstar(post_id)
271
+ end
272
+
273
+ desc "star POST", "Star a post (-ST)"
274
+ map "-ST" => :star
275
+ long_desc Descriptions.star
276
+ def star(post_id)
277
+ Action.new.star(post_id)
278
+ end
279
+
280
+ desc "repost POST", "Repost a post (-O)"
281
+ map "-O" => :repost
282
+ long_desc Descriptions.repost
283
+ def repost(post_id)
284
+ Action.new.repost(post_id)
285
+ end
286
+
287
+ desc "follow @USERNAME", "Follow @username (-FO)"
288
+ map "-FO" => :follow
289
+ long_desc Descriptions.follow
290
+ def follow(*username)
291
+ Action.new.follow(username)
292
+ end
293
+
294
+ desc "mute @USERNAME", "Mute @username (-MU)"
295
+ map "-MU" => :mute
296
+ long_desc Descriptions.mute
297
+ def mute(*username)
298
+ Action.new.mute(username)
299
+ end
300
+
301
+ desc "block @USERNAME", "Block @username (-BL)"
302
+ map "-BL" => :block
303
+ long_desc Descriptions.block
304
+ def block(*username)
305
+ Action.new.block(username)
306
+ end
307
+
308
+ desc "channels", "List your active channels (-ch)"
309
+ map "-ch" => :channels
310
+ long_desc Descriptions.channels
311
+ def channels
312
+ Action.new.channels
313
+ end
314
+
315
+ desc "messages CHANNEL", "Show messages in a CHANNEL (-ms)"
316
+ map "-ms" => :messages
317
+ long_desc Descriptions.messages
318
+ option :scroll, aliases: "-s", type: :boolean, desc: "Scroll the stream"
319
+ option :new, aliases: "-n", type: :boolean, desc: Descriptions.options_new
320
+ option :count, aliases: "-c", type: :numeric, desc: "Specify the number of messages to retrieve"
321
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
322
+ def messages(channel_id)
323
+ Action.new.messages(channel_id, options)
324
+ end
325
+
326
+ desc "pin POST TAG(S)", "Export a post's link and text with tags to Pinboard"
327
+ long_desc Descriptions.pin
328
+ def pin(post_id, *tags)
329
+ Action.new.pin(post_id, tags)
330
+ end
331
+
332
+ desc "post Your text", "Simple post to App.net (-P)"
333
+ map "-P" => :post
334
+ long_desc Descriptions.post
335
+ def post(*args)
336
+ Action.new.post(args)
337
+ end
338
+
339
+ desc "write", "Multi-line post to App.net (-W)"
340
+ map "compose" => :write
341
+ map "-W" => :write
342
+ long_desc Descriptions.write
343
+ def write
344
+ Action.new.write
345
+ end
346
+
347
+ desc "pm @USERNAME", "Send a private message to @username"
348
+ long_desc Descriptions.pmess
349
+ def pm(*username)
350
+ Action.new.pmess(username)
351
+ end
352
+
353
+ desc "send CHANNEL", "Send a message to a CHANNEL (-C)"
354
+ map "-C" => :send_to_channel
355
+ long_desc Descriptions.send_to_channel
356
+ def send_to_channel(channel_id)
357
+ Action.new.send_to_channel(channel_id)
358
+ end
359
+
360
+ desc "reply POST", "Reply to post n°POST (-R)"
361
+ map "-R" => :reply
362
+ long_desc Descriptions.reply
363
+ def reply(id)
364
+ ayadn = Action.new
365
+ ayadn.reply(id)
366
+ end
367
+
368
+ desc "auto", "Auto post every line of input to App.net"
369
+ long_desc Descriptions.auto
370
+ def auto
371
+ Action.new.auto(options)
372
+ end
373
+
374
+ desc "set TYPE PARAM VALUE", "Set/configure a parameter and save it"
375
+ long_desc Descriptions.set
376
+ subcommand "set", Set
377
+
378
+ desc "alias COMMAND (PARAM)", "Create/delete/list aliases for channels (-A)"
379
+ map "-A" => :alias
380
+ long_desc Descriptions.alias
381
+ subcommand "alias", Alias
382
+
383
+ desc "download FILE", "Download the file with id FILE (-df)"
384
+ map "-df" => :download
385
+ long_desc Descriptions.download
386
+ def download(file_id)
387
+ ayadn = Action.new
388
+ ayadn.download(file_id)
389
+ end
390
+
391
+ desc "blacklist COMMAND (PARAM)", "Manage your blacklist (-K)"
392
+ map "-K" => :blacklist
393
+ long_desc Descriptions.blacklist
394
+ subcommand "blacklist", Blacklist
395
+
396
+ desc "nowplaying", "Post the current iTunes track (-np)"
397
+ map "-np" => :nowplaying
398
+ long_desc Descriptions.nowplaying
399
+ def nowplaying
400
+ Action.new.nowplaying
401
+ end
402
+
403
+ desc "random", "Show random posts from App.net (-rnd)"
404
+ map "-rnd" => :random
405
+ option :wait, aliases: "-w", type: :numeric, desc: "In seconds, time to wait before next page"
406
+ long_desc Descriptions.random_posts
407
+ def random
408
+ Action.new.random_posts(options)
409
+ end
410
+
411
+ desc "authorize", "Authorize Ayadn (-auth)"
412
+ map "-auth" => :authorize
413
+ long_desc Descriptions.authorize
414
+ def authorize
415
+ Authorize.new.authorize
416
+ end
417
+
418
+ desc "switch @USERNAME", "Switch between authorized App.net accounts (-@)"
419
+ map "-@" => :switch
420
+ option :list, aliases: "-l", type: :boolean, desc: "List authorized accounts"
421
+ long_desc Descriptions.switch
422
+ def switch(*username)
423
+ unless options[:list]
424
+ Switch.new.switch(username)
425
+ else
426
+ Switch.new.list
427
+ end
428
+ end
429
+
430
+ end
19
431
  end
20
-
21
- arg1, arg2, arg3, arg4 = ARGV[0], ARGV[1], ARGV[2], ARGV[3]
22
-
23
- case arg1
24
-
25
- when "scroll"
26
- client.ayadnScroll(arg2, arg3)
27
-
28
- when nil
29
- client.ayadnUnified(nil)
30
-
31
- when "unified", "uni"
32
- client.ayadnUnified(arg2)
33
-
34
- when "write", "w"
35
- arg2 != nil ? client.ayadnSendPost(arg2, nil) : client.ayadn_compose_post
36
-
37
- when "reply", "r"
38
- if arg2 != nil
39
- arg2.is_integer? ? client.ayadn_reply(arg2) : (puts $status.errorPostID(arg2))
40
- else
41
- puts $status.errorNoID
42
- end
43
-
44
- when "global", "g"
45
- client.ayadnGlobal(arg2)
46
-
47
- when "mentions", "m"
48
- (arg2 =~ /^@/ || arg2 == "me") ? client.ayadnUserMentions(arg2, arg3) : (puts $status.errorUserID(arg2))
49
-
50
- when "posts", "p"
51
- (arg2 =~ /^@/ || arg2 == "me") ? client.ayadnUserPosts(arg2, arg3) : (puts $status.errorUserID(arg2))
52
-
53
- when "trending", "conversations", "checkins", "photos"
54
- client.ayadnExplore(arg1, arg2)
55
-
56
- when "infos", "i", "info"
57
- if arg2 =~ /^@/ || arg2 == "me"
58
- client.ayadnUserInfos(arg2)
59
- elsif arg2.is_integer?
60
- client.ayadnPostInfos(arg2)
61
- else
62
- puts $status.errorInfos(arg2)
63
- end
64
-
65
- when "convo", "c", "thread"
66
- arg2.is_integer? ? client.ayadnConversation(arg2) : (puts $status.errorPostID(arg2))
67
-
68
- when "tag", "t", "hashtag"
69
- theTag = arg2.dup
70
- theTag[0] = "" if theTag =~ /^#/
71
- client.ayadnHashtags(theTag)
72
-
73
- when "delete"
74
- if arg2.is_integer?
75
- puts "\nAre you sure you want to delete post ".green + "#{arg2}? ".brown + "(n/y) ".green
76
- input = STDIN.getch
77
- (input == "y" || input == "Y") ? client.ayadnDeletePost(arg2) : (puts "\nCanceled.\n\n".red)
78
- else
79
- puts $status.errorPostID(arg2)
80
- end
81
-
82
- when "list"
83
- case arg2
84
- when "followings", "fwings"
85
- (arg3 =~ /^@/ || arg3 == "me") ? client.ayadnShowList("followings", arg3) : (puts $status.errorSyntax)
86
- when "followers", "fwers"
87
- (arg3 =~ /^@/ || arg3 == "me") ? client.ayadnShowList("followers", arg3) : (puts $status.errorSyntax)
88
- when "muted"
89
- client.ayadnShowList("muted", "me")
90
- when "blocked"
91
- client.ayadnShowList("blocked", "me")
92
- when "files"
93
- client.ayadn_list_files(arg3)
94
- when "options","config"
95
- client.ayadn_show_options
96
- when "channels", "ch"
97
- client.get_loaded_channels
98
- client.ayadn_get_channels
99
- when "aliases", "alias", "channel-alias", "alias-channel"
100
- client.ayadn_list_aliases
101
- else
102
- puts $status.errorSyntax
103
- end
104
-
105
- when "star"
106
- arg2.is_integer? ? client.ayadnStarringPost("star", arg2) : (puts $status.errorPostID(arg2))
107
-
108
- when "unstar"
109
- arg2.is_integer? ? client.ayadnStarringPost("unstar", arg2) : (puts $status.errorPostID(arg2))
110
-
111
- when "repost"
112
- arg2.is_integer? ? client.ayadnReposting("repost", arg2) : (puts $status.errorPostID(arg2))
113
-
114
- when "unrepost"
115
- arg2.is_integer? ? client.ayadnReposting("unrepost", arg2) : (puts $status.errorPostID(arg2))
116
-
117
- when "follow"
118
- arg2 =~ /^@/ ? client.ayadnFollowing("follow", arg2) : (puts $status.errorUserID(arg2))
119
-
120
- when "unfollow"
121
- arg2 =~ /^@/ ? client.ayadnFollowing("unfollow", arg2) : (puts $status.errorUserID(arg2))
122
-
123
- when "pm"
124
- if arg2 =~ /^@/
125
- if arg3 != nil
126
- # ayadn pm @ericd "hello!"
127
- client.ayadnSendMessage(arg2, arg3)
128
- else
129
- client.ayadnComposeMessage(arg2)
130
- end
131
- else
132
- puts $status.errorSyntax
133
- end
134
-
135
- when "send"
136
- if arg3 != nil
137
- # ayadn send 12345 "hello, channel!"
138
- client.ayadnSendMessageToChannel(arg2, arg3)
139
- else
140
- client.ayadnComposeMessageToChannel(arg2)
141
- end
142
-
143
- when "channels", "ch"
144
- client.get_loaded_channels
145
- client.ayadn_get_channels
146
-
147
- when "messages", "msg"
148
- # arg2 is integer -> display channel stream
149
- # arg3 == nil = with pagination, arg3 == "all" = no pagination
150
- client.ayadnGetMessages(arg2, arg3)
151
-
152
- when "quote", "comment", "q"
153
- if arg2.is_integer?
154
- client.ayadn_quote(arg2)
155
- else
156
- puts $status.errorSyntax
157
- end
158
-
159
- when "nowplaying", "itunes", "np"
160
- client.ayadn_nowplaying
161
-
162
- when "search", "s"
163
- arg2 != nil ? client.ayadnSearch(arg2) : (puts $status.errorSyntax)
164
-
165
- when "starred"
166
- if arg2 =~ /^@/ || arg2 == "me"
167
- client.ayadnStarredPosts(arg2, arg3)
168
- elsif arg2.is_integer?
169
- client.ayadnWhoStarred(arg2)
170
- else
171
- puts $status.errorUserID(arg2)
172
- end
173
-
174
- when "reposted"
175
- arg2.is_integer? ? client.ayadnWhoReposted(arg2) : (puts $status.errorPostID(arg2))
176
-
177
- when "inter", "interactions", "events"
178
- client.ayadnInteractions
179
-
180
- when "save"
181
- arg2.is_integer? ? client.ayadnSavePost(arg2) : (puts $status.errorPostID(arg2))
182
-
183
- when "load"
184
- arg2.is_integer? ? client.ayadnLoadPost(arg2) : (puts $status.errorPostID(arg2))
185
-
186
- when "backup"
187
- if arg2 == "followings"
188
- (arg3 =~ /^@/ || arg3 == "me") ? client.ayadnSaveList("followings", arg3) : (puts $status.errorSyntax)
189
- elsif arg2 == "followers"
190
- (arg3 =~ /^@/ || arg3 == "me") ? client.ayadnSaveList("followers", arg3) : (puts $status.errorSyntax)
191
- elsif arg2 == "muted"
192
- client.ayadnSaveList("muted", "me")
193
- end
194
-
195
- when "help", "h"
196
- puts $tools.helpScreen
197
-
198
- when "commands", "usage"
199
- puts $tools.list_of_commands
200
-
201
- when "webhelp"
202
- puts $tools.helpScreen
203
- begin
204
- if $tools.ayadn_configuration[:platform] =~ /darwin/
205
- $tools.startBrowser("https://github.com/ericdke/ayadn#ayadn")
206
- else
207
- puts "\nCan't start a browser automatically. Please visit ".cyan + "https://github.com/ericdke/ayadn#ayadn".magenta
208
- end
209
- end
210
-
211
- when "options"
212
- client.ayadn_show_options
213
-
214
- when "debug"
215
- if arg2 == nil
216
- client.ayadnDebugStream
217
- elsif arg2 =~ /^@/
218
- client.ayadnDebugUser(arg2)
219
- elsif arg3.is_integer?
220
- if arg2 == "post"
221
- client.ayadnDebugPost(arg3)
222
- elsif arg2 == "message"
223
- # channel_id, message_id
224
- client.ayadnDebugMessage(arg3, arg4)
225
- elsif arg2 == "channel"
226
- client.ayadnDebugChannel(arg3)
227
- end
228
- end
229
-
230
- when "skip-source", "skip-client"
231
- case arg2
232
- when "add"
233
- client.ayadn_skip_add("sources", arg3)
234
- when "remove"
235
- client.ayadn_skip_remove("sources", arg3)
236
- when "show"
237
- client.ayadn_show_options
238
- else
239
- puts $status.errorSyntax
240
- end
241
-
242
- when "skip-tag", "skip-hashtag"
243
- case arg2
244
- when "add"
245
- client.ayadn_skip_add("hashtags", arg3)
246
- when "remove"
247
- client.ayadn_skip_remove("hashtags", arg3)
248
- when "show"
249
- client.ayadn_show_options
250
- else
251
- puts $status.errorSyntax
252
- end
253
-
254
- when "skip-mention", "skip-name", "skip-username"
255
- case arg2
256
- when "add"
257
- client.ayadn_skip_add("mentions", arg3)
258
- when "remove"
259
- client.ayadn_skip_remove("mentions", arg3)
260
- when "show"
261
- client.ayadn_show_options
262
- else
263
- puts $status.errorSyntax
264
- end
265
-
266
- when "mute"
267
- arg2 =~ /^@/ ? client.ayadnMuting("mute", arg2) : (puts $status.errorUserID(arg2))
268
-
269
- when "unmute"
270
- arg2 =~ /^@/ ? client.ayadnMuting("unmute", arg2) : (puts $status.errorUserID(arg2))
271
-
272
- when "block"
273
- arg2 =~ /^@/ ? client.ayadnBlocking("block", arg2) : (puts $status.errorUserID(arg2))
274
-
275
- when "unblock"
276
- arg2 =~ /^@/ ? client.ayadnBlocking("unblock", arg2) : (puts $status.errorUserID(arg2))
277
-
278
- when "reset"
279
- if arg2 == "pagination"
280
- client.ayadnReset(arg3, arg4)
281
- elsif arg2 == nil
282
- client.ayadnReset(nil, nil)
283
- end
284
-
285
- # when "deactivate"
286
- # # deactivate a user channel
287
- # client.ayadnDeactivateChannel(arg2)
288
-
289
- when "random"
290
- # just for fun, a quick & dirty hack :)
291
- api = AyaDN::API.new(token)
292
- puts "Fetching random posts, wait a second... (quit with CTRL+C)\n\n".green
293
- $tools.config['counts']['global'] = 20
294
- hash = api.getGlobal(2)
295
- puts "\e[H\e[2J"
296
- last_post = hash['data'][0]['id'].to_i
297
- rnd_post_num = rand(last_post + 1)
298
- hash = api.getSinglePost(rnd_post_num)
299
- hash = hash['data']
300
- puts AyaDN::View.new(nil).buildSimplePost(hash)
301
- if hash['text'] == nil
302
- puts "\n-- SKIPPED POST (NO TEXT) --\n\n"
303
- sleep 0.2
304
- end
305
- loop do
306
- begin
307
- sleep 0.7
308
- rnd_post_num = rand(last_post + 1)
309
- hash = api.getSinglePost(rnd_post_num)
310
- hash = hash['data']
311
- if hash['text'] == nil
312
- puts "\n-- SKIPPED POST (NO TEXT) --\n\n"
313
- sleep 0.2
314
- next
315
- end
316
- #jj hash['annotations'] if hash['annotations']
317
- puts AyaDN::View.new(nil).buildSimplePost(hash)
318
- rescue Exception => e
319
- #puts e.inspect
320
- abort($status.stopped)
321
- end
322
- end
323
-
324
- when "delete-message"
325
- client.ayadn_delete_message(arg2, arg3) #channel, message
326
-
327
- when "download"
328
- client.ayadn_download_files(arg2)
329
-
330
- when "delete-file"
331
- client.ayadn_delete_file(arg2)
332
-
333
- when "upload"
334
- client.ayadn_upload_files(arg2)
335
-
336
- when "private", "public"
337
- client.ayadn_attribute_file(arg1, arg2)
338
-
339
- when "pin"
340
- client.ayadnBookmark(ARGV)
341
-
342
- when "alias-channel"
343
- client.ayadn_alias_channel(arg2, arg3)
344
-
345
- when "stream_global"
346
- client.ayadn_userstream
347
-
348
- when "does", "do", "is", "has"
349
- client.ayadn_does(ARGV)
350
-
351
- when "authorize", "login"
352
- AyaDN.new(nil).ayadnAuthorize("reset")
353
-
354
- when "install"
355
- if arg2 == "config"
356
- $tools.installConfig
357
- else
358
- puts $status.errorSyntax
359
- end
360
-
361
- else
362
- # if not any known argument
363
- puts $status.errorSyntax
364
- puts "#{ARGV.join(" ")} ".brown + "is not a valid option.\n\n".red
365
- puts $tools.helpScreen
366
-
367
- end