ayadn 1.0.13 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 178f8d0b90c3d05a395d913d20b5ceeb8e9e4889
4
- data.tar.gz: f8905a19ce739307c6dd510a8776e2ea58c1e11e
3
+ metadata.gz: ec4024b66d88bd66154dec00328a519791012ec6
4
+ data.tar.gz: 723fa86ee438661970ea213b71f69bd3f5b78e62
5
5
  SHA512:
6
- metadata.gz: 7dc47ef7305ce368c37200bac11320620ed2fdd25733bba82df29e6449e750420de501b7f2d43239267d324ea4c551d90024db2d616f997bf30d7a221e97b9bd
7
- data.tar.gz: 491d12154549d299528217d8561edfbf4eb6e2d44b8bac4baac906b9480d0dde2413ec8821844590bc8eb1a2ef7f349464a24d53a854a5bf238d5b5e4d015eee
6
+ metadata.gz: dc50e43e6f535da4b7c686aefcfb634d6406b3ac4109f1422be2ac44c2b0c536027d5cc07c4f311ce17c4c164990b718c7cac75e2c9aae03eb2440a0b1a314c3
7
+ data.tar.gz: 91df36971df60e26dcf8f90aa836401780af35bb70a6c40dfd1fe9aa9ba529c5792a01f06f69a78126ccb5acddb9efa3d2ae57b2d5deb03b5b8e170ecacbf9cc
data/CHANGELOG.md CHANGED
@@ -1,35 +1,47 @@
1
- # 1.0.13
1
+ # 1.1.0 - 'Leviathan'
2
+
3
+ - Show who's writing, and who's the recipient
4
+ - Less help text when writing, more concise
5
+ - The blacklist works better (recorded and compared downcased)
6
+ - New command: convert blacklist
7
+ - Export blacklist as CSV, aliases and settings as JSON
8
+ - New option: 'extract'. Extracts all links from results of a search by word or by hashtag, or from the 'what starred' command
9
+ - New command: show current version
10
+ - New command: photos stream
11
+ - New command: delete message (private or in a channel)
12
+
13
+ # 1.0.13 - 'Charlotte'
2
14
 
3
15
  - New layout for '#nowplaying'
4
16
  - Compact index.db and pagination.db if necessary
5
17
  - New api urls
6
18
  - Fix 'download file'
7
19
 
8
- # 1.0.12
20
+ # 1.0.12 - 'Rolando'
9
21
 
10
22
  - Fixed an error in: authorizing an account if its folders already exists
11
23
 
12
- # 1.0.11
24
+ # 1.0.11 - 'Chris'
13
25
 
14
26
  - There was a typo in the last version that caused a bug in the PM command
15
27
 
16
- # 1.0.10
28
+ # 1.0.10 - 'Johannes'
17
29
 
18
30
  - Fixes the help bug (doubled commands)
19
31
  - Auto adds the @ if missing in pm
20
32
 
21
- # 1.0.9
33
+ # 1.0.9 - 'Brian'
22
34
 
23
35
  - Fixes the stubborn 'nowplaying' database bug
24
36
 
25
- # 1.0.8
37
+ # 1.0.8 - 'Laurent'
26
38
 
27
39
  - Better error messages/logs (specifically when HTTP errors)
28
40
  - Token is anonymized if in error logs
29
41
  - No more database error when canceling a 'nowplaying' post
30
42
  - Better mentions colorization
31
43
 
32
- # 1.0.7
44
+ # 1.0.7 - 'Hugo'
33
45
 
34
46
  - Machine-only messages in channels are now viewable
35
47
  - Don't output "Downloading" if options = raw in messages view
@@ -37,28 +49,28 @@
37
49
  - Removed username in front of ">>" in Auto (in case the authd user changed)
38
50
  - Compatibility with Windows is broken
39
51
 
40
- # 1.0.6
52
+ # 1.0.6 - 'Matthew'
41
53
 
42
54
  - Fixed a bug where post_max_chars was displayed instead of message_max_chars
43
55
  - Show raw JSON in messages even if no data
44
56
 
45
- # 1.0.5
57
+ # 1.0.5 - 'Joel'
46
58
 
47
59
  - Fixed the colorization for mentions
48
60
  - Added tests for colorization
49
61
 
50
- # 1.0.4
62
+ # 1.0.4 - 'Jeremy'
51
63
 
52
64
  - Fixed 'reply to an indexed stream' for Ruby < 2.1
53
65
  - More tests for Databases
54
66
  - Tests for Blacklist
55
67
  - Tests for Set
56
68
 
57
- # 1.0.3
69
+ # 1.0.3 - 'Donny'
58
70
 
59
71
  - Fixed the bug introduced by the last bugfix (yes, I know... sigh...)
60
72
 
61
- # 1.0.2
73
+ # 1.0.2 - 'Mark'
62
74
 
63
75
  - Fixed a critical bug in Reply (when the original post was a repost)
64
76
  - Tests for Databases
@@ -66,7 +78,7 @@
66
78
  - Better layout for checkins
67
79
  - Better alert message if error 429
68
80
 
69
- # 1.0.1
81
+ # 1.0.1 - 'Phoenix'
70
82
 
71
83
  Release!
72
84
 
data/MANUAL.md CHANGED
@@ -17,10 +17,12 @@
17
17
  - [INDEX](#index)
18
18
  - [NEW](#new)
19
19
  - [RAW](#raw)
20
+ - [EXTRACT](#extract)
20
21
  - [GLOBAL](#global)
21
22
  - [CHECKINS](#checkins)
22
23
  - [CONVERSATIONS](#conversations)
23
24
  - [TRENDING](#trending)
25
+ - [PHOTOS](#photos)
24
26
  - [MENTIONS](#mentions)
25
27
  - [POSTS](#posts)
26
28
  - [MESSAGES](#messages)
@@ -40,6 +42,7 @@
40
42
  - [SEND](#send)
41
43
  - [ACTIONS](#actions)
42
44
  - [DELETE](#delete)
45
+ - [DELETE MESSAGE](#delete-message)
43
46
  - [REPOST](#repost)
44
47
  - [UNREPOST](#unrepost)
45
48
  - [STAR](#star)
@@ -284,8 +287,26 @@ Displays only the new posts in the stream since your last visit.
284
287
 
285
288
  Displays the raw response from the App.net API instead of the formatted Ayadn output. For debugging and learning purposes.
286
289
 
290
+ `ayadn --raw timeline`
291
+
287
292
  `ayadn -x -tl`
288
293
 
294
+ #### EXTRACT
295
+
296
+ Extracts all links from posts.
297
+
298
+ `ayadn hashtag --extract instagram`
299
+
300
+ `ayadn -t -e instagram`
301
+
302
+ `ayadn search --extract ruby gem`
303
+
304
+ `ayadn -s -e ruby gem`
305
+
306
+ `ayadn whatstarred @ericd -e`
307
+
308
+ `ayadn -was -e ericd`
309
+
289
310
  ## GLOBAL
290
311
 
291
312
  Display the 'Global stream'.
@@ -330,6 +351,16 @@ This is a stream of trending posts.
330
351
 
331
352
  `ayadn -tr`
332
353
 
354
+ ## PHOTOS
355
+
356
+ Display the 'Photos stream'.
357
+
358
+ This is a stream of posts including a picture.
359
+
360
+ `ayadn photos`
361
+
362
+ `ayadn -ph`
363
+
333
364
  ## MENTIONS
334
365
 
335
366
  Display posts containing a mention of @username.
@@ -544,6 +575,18 @@ Delete a post.
544
575
 
545
576
  `ayadn -D 23365251`
546
577
 
578
+ ## DELETE MESSAGE
579
+
580
+ Delete a message.
581
+
582
+ You have to specify channel id (or alias) then message number.
583
+
584
+ `ayadn delete_m 42666 3365251`
585
+
586
+ `ayadn -DM 42666 3365251`
587
+
588
+ `ayadn -DM my_alias 3365251`
589
+
547
590
  ## REPOST
548
591
 
549
592
  Repost a post.
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/ayadn.svg)](http://badge.fury.io/rb/ayadn)
2
2
  [![Build Status](https://travis-ci.org/ericdke/na.svg?branch=master)](https://travis-ci.org/ericdke/na)
3
+ [![Flattr this](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=ericdejonckheere&url=https://github.com/ericdke/na&title=Ayadn&language=&tags=github&category=software)
3
4
 
4
5
  AYADN
5
6
  =====
data/lib/ayadn/action.rb CHANGED
@@ -94,7 +94,7 @@ module Ayadn
94
94
  (no_new_posts unless Databases.has_new?(stream, 'explore:replies')) if options[:new]
95
95
  Databases.save_max_id(stream)
96
96
  render_view(stream, options)
97
- Scroll.new(@api, @view).conversations(options) if options[:scroll]
97
+ Scroll.new(@api, @view).replies(options) if options[:scroll]
98
98
  rescue => e
99
99
  Errors.global_error("action/conversations", options, e)
100
100
  ensure
@@ -164,7 +164,12 @@ module Ayadn
164
164
  doing(options)
165
165
  stream = @api.get_whatstarred(username, options)
166
166
  user_404(username) if meta_404(stream)
167
- stream['data'].empty? ? no_data('whatstarred') : render_view(stream, options)
167
+ no_data('whatstarred') if stream['data'].empty?
168
+ if options[:extract]
169
+ view_all_stars_links(stream)
170
+ else
171
+ render_view(stream, options)
172
+ end
168
173
  rescue => e
169
174
  Errors.global_error("action/whatstarred", [username, options], e)
170
175
  ensure
@@ -245,6 +250,22 @@ module Ayadn
245
250
  end
246
251
  end
247
252
 
253
+ def delete_m(args)
254
+ begin
255
+ missing_message_id unless args.length == 2
256
+ message_id = args[1]
257
+ missing_message_id unless message_id.is_integer?
258
+ channel_id = get_channel_id_from_alias(args[0])
259
+ print Status.deleting_message(message_id)
260
+ resp = @api.delete_message(channel_id, message_id)
261
+ check_message_has_been_deleted(message_id, resp)
262
+ rescue => e
263
+ Errors.global_error("action/delete message", message_id, e)
264
+ ensure
265
+ Databases.close_all
266
+ end
267
+ end
268
+
248
269
  def unfollow(username)
249
270
  begin
250
271
  missing_username if username.empty?
@@ -388,7 +409,11 @@ module Ayadn
388
409
  doing(options)
389
410
  stream = @api.get_hashtag(hashtag)
390
411
  no_data('hashtag') if stream['data'].empty?
391
- render_view(stream, options)
412
+ if options[:extract]
413
+ view_all_hashtag_links(stream, hashtag)
414
+ else
415
+ render_view(stream, options)
416
+ end
392
417
  rescue => e
393
418
  Errors.global_error("action/hashtag", [hashtag, options], e)
394
419
  ensure
@@ -401,7 +426,11 @@ module Ayadn
401
426
  doing(options)
402
427
  stream = @api.get_search(words, options)
403
428
  no_data('search') if stream['data'].empty?
404
- render_view(stream, options)
429
+ if options[:extract]
430
+ view_all_search_links(stream, words)
431
+ else
432
+ render_view(stream, options)
433
+ end
405
434
  rescue => e
406
435
  Errors.global_error("action/search", [words, options], e)
407
436
  ensure
@@ -488,12 +517,16 @@ module Ayadn
488
517
  end
489
518
  end
490
519
 
491
- def view_settings
520
+ def view_settings(options)
492
521
  begin
493
- @view.clear_screen
494
- @view.show_settings
522
+ if options[:raw]
523
+ puts Settings.options.to_json
524
+ else
525
+ @view.clear_screen
526
+ @view.show_settings
527
+ end
495
528
  rescue => e
496
- Errors.global_error("action/settings", nil, e)
529
+ Errors.global_error("action/settings", options, e)
497
530
  ensure
498
531
  Databases.close_all
499
532
  end
@@ -698,6 +731,7 @@ module Ayadn
698
731
  def write
699
732
  begin
700
733
  writer = Post.new
734
+ puts Status.writing
701
735
  puts Status.post
702
736
  lines_array = writer.compose
703
737
  writer.check_post_length(lines_array)
@@ -721,6 +755,7 @@ module Ayadn
721
755
  temp = Workers.add_arobase_if_missing(username)
722
756
  username = [temp]
723
757
  messenger = Post.new
758
+ puts Status.message_from(username)
724
759
  puts Status.message
725
760
  lines_array = messenger.compose
726
761
  messenger.check_message_length(lines_array)
@@ -742,6 +777,7 @@ module Ayadn
742
777
  begin
743
778
  channel_id = get_channel_id_from_alias(channel_id)
744
779
  messenger = Post.new
780
+ puts Status.writing
745
781
  puts Status.post
746
782
  lines_array = messenger.compose
747
783
  messenger.check_message_length(lines_array)
@@ -773,6 +809,7 @@ module Ayadn
773
809
  end
774
810
  end
775
811
  poster = Post.new
812
+ puts Status.writing
776
813
  puts Status.reply
777
814
  lines_array = poster.compose
778
815
  poster.check_post_length(lines_array)
@@ -802,6 +839,7 @@ module Ayadn
802
839
  @view.clear_screen
803
840
  #text_to_post = "#nowplaying '#{itunes.track}' from '#{itunes.album}' by #{itunes.artist}"
804
841
  text_to_post = "#nowplaying\nTitle: ‘#{itunes.track}’\nArtist: #{itunes.artist}\nfrom ‘#{itunes.album}’"
842
+ puts Status.writing
805
843
  show_nowplaying(text_to_post)
806
844
  unless STDIN.getch == ("y" || "Y")
807
845
  puts "\nCanceled.\n\n".color(:red)
@@ -933,6 +971,15 @@ module Ayadn
933
971
  end
934
972
  end
935
973
 
974
+ def check_message_has_been_deleted(message_id, resp)
975
+ if resp['meta']['code'] == 200
976
+ puts Status.deleted_m(message_id)
977
+ Logs.rec.info "Deleted message #{message_id}."
978
+ else
979
+ whine(Status.not_deleted(message_id), resp)
980
+ end
981
+ end
982
+
936
983
  def check_has_been_unblocked(username, resp)
937
984
  if resp['meta']['code'] == 200
938
985
  puts Status.unblocked(username)
@@ -1111,6 +1158,11 @@ module Ayadn
1111
1158
  exit
1112
1159
  end
1113
1160
 
1161
+ def missing_message_id
1162
+ puts Status.error_missing_message_id
1163
+ exit
1164
+ end
1165
+
1114
1166
  def auto_save_followings(list)
1115
1167
  FileOps.save_followings_list(list) if Settings.options[:backup][:auto_save_lists]
1116
1168
  end
@@ -1146,5 +1198,41 @@ module Ayadn
1146
1198
  end
1147
1199
  end
1148
1200
 
1201
+ def links_from_posts(stream)
1202
+ links = []
1203
+ worker = Workers.new
1204
+ stream['data'].each do |post|
1205
+ from = worker.extract_links(post)
1206
+ from.each {|l| links << l}
1207
+ end
1208
+ links.uniq!
1209
+ links
1210
+ end
1211
+
1212
+ def show_links(links)
1213
+ links.each {|l| puts "#{l}\n".color(Settings.options[:colors][:link])}
1214
+ end
1215
+
1216
+ def view_all_hashtag_links(stream, hashtag)
1217
+ links = links_from_posts(stream)
1218
+ @view.clear_screen
1219
+ puts "Links from posts containing hashtag '##{hashtag}': \n".color(:cyan)
1220
+ show_links(links)
1221
+ end
1222
+
1223
+ def view_all_search_links(stream, words)
1224
+ links = links_from_posts(stream)
1225
+ @view.clear_screen
1226
+ puts "Links from posts containing word(s) '#{words}': \n".color(:cyan)
1227
+ show_links(links)
1228
+ end
1229
+
1230
+ def view_all_stars_links(stream)
1231
+ links = links_from_posts(stream)
1232
+ @view.clear_screen
1233
+ puts "Links from your starred posts: \n".color(:cyan)
1234
+ show_links(links)
1235
+ end
1236
+
1149
1237
  end
1150
1238
  end
data/lib/ayadn/alias.rb CHANGED
@@ -74,14 +74,21 @@ module Ayadn
74
74
 
75
75
  desc "list", "List previously created aliases"
76
76
  long_desc Descriptions.alias_list
77
+ option :raw, aliases: "-x", type: :boolean, desc: "Outputs the raw list in JSON"
77
78
  def list
78
79
  begin
79
80
  init
80
- puts "\e[H\e[2J"
81
81
  list = Databases.aliases
82
82
  unless list.empty? || list.nil?
83
- puts Workers.new.build_aliases_list(list)
84
- puts "\n"
83
+ if options[:raw]
84
+ h = {}
85
+ list.each {|k,v| h[k] = v}
86
+ puts h.to_json
87
+ else
88
+ puts "\e[H\e[2J"
89
+ puts Workers.new.build_aliases_list(list)
90
+ puts "\n"
91
+ end
85
92
  else
86
93
  puts Status.empty_list
87
94
  end
data/lib/ayadn/api.rb CHANGED
@@ -171,6 +171,10 @@ module Ayadn
171
171
  JSON.parse(CNX.delete(Endpoints.new.delete_post(post_id)))
172
172
  end
173
173
 
174
+ def delete_message(channel_id, message_id)
175
+ JSON.parse(CNX.delete(Endpoints.new.delete_message(channel_id, message_id)))
176
+ end
177
+
174
178
  def unstar(post_id)
175
179
  JSON.parse(CNX.delete(Endpoints.new.star(post_id)))
176
180
  end
data/lib/ayadn/app.rb CHANGED
@@ -54,17 +54,17 @@ module Ayadn
54
54
  Action.new.trending(options)
55
55
  end
56
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
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
68
 
69
69
  desc "conversations", "Show the Conversations Stream (-cq)"
70
70
  map "-cq" => :conversations
@@ -114,6 +114,7 @@ module Ayadn
114
114
  option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
115
115
  option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
116
116
  option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
117
+ option :extract, aliases: "-e", type: :boolean, desc: Descriptions.options_extract
117
118
  def whatstarred(*username)
118
119
  Action.new.whatstarred(username, options)
119
120
  end
@@ -181,6 +182,7 @@ module Ayadn
181
182
  map "-t" => :hashtag
182
183
  long_desc Descriptions.hashtag
183
184
  option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
185
+ option :extract, aliases: "-e", type: :boolean, desc: Descriptions.options_extract
184
186
  def hashtag(hashtag)
185
187
  Action.new.hashtag(hashtag, options)
186
188
  end
@@ -191,6 +193,7 @@ module Ayadn
191
193
  option :count, aliases: "-c", type: :numeric, desc: Descriptions.options_count
192
194
  option :index, aliases: "-i", type: :boolean, desc: Descriptions.options_index
193
195
  option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
196
+ option :extract, aliases: "-e", type: :boolean, desc: Descriptions.options_extract
194
197
  def search(*words)
195
198
  Action.new.search(words.join(","), options)
196
199
  end
@@ -198,8 +201,9 @@ module Ayadn
198
201
  desc "settings", "List current Ayadn settings (-sg)"
199
202
  map "-sg" => :settings
200
203
  long_desc Descriptions.settings
204
+ option :raw, aliases: "-x", type: :boolean, desc: "Outputs the raw list in JSON"
201
205
  def settings
202
- Action.new.view_settings
206
+ Action.new.view_settings(options)
203
207
  end
204
208
 
205
209
  desc "userinfo @USERNAME", "Show detailed informations about @username (-ui)"
@@ -235,6 +239,13 @@ module Ayadn
235
239
  Action.new.delete(post_id)
236
240
  end
237
241
 
242
+ desc "delete_m CHANNEL MESSAGE", "Delete a message (-DM)"
243
+ map "-DM" => :delete_m
244
+ long_desc Descriptions.delete_m
245
+ def delete_m(*args)
246
+ Action.new.delete_m(args)
247
+ end
248
+
238
249
  desc "unfollow @USERNAME", "Unfollow @username (-UF)"
239
250
  map "-UF" => :unfollow
240
251
  long_desc Descriptions.unfollow
@@ -427,5 +438,16 @@ module Ayadn
427
438
  end
428
439
  end
429
440
 
441
+ desc "version", "Show the current Ayadn version (-v)"
442
+ map "-v" => :version
443
+ def version
444
+ puts "\nAYADN\n".color(:red)
445
+ puts "Version:\t".color(:cyan) + "#{VERSION}\n".color(:green)
446
+ puts "Changelog:\t".color(:cyan) + "https://github.com/ericdke/na/blob/master/CHANGELOG.md\n".color(:yellow)
447
+ puts "Readme:\t\t".color(:cyan) + "https://github.com/ericdke/na/blob/master/README.md".color(:yellow)
448
+ puts "Manual:\t\t".color(:cyan) + "https://github.com/ericdke/na/blob/master/MANUAL.md".color(:yellow)
449
+ puts "\n"
450
+ end
451
+
430
452
  end
431
453
  end