Class: Ayadn::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/ayadn/action.rb

Instance Method Summary collapse

Constructor Details

#initializeAction

This class is the main initializer + dispatcher



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ayadn/action.rb', line 8

def initialize
  @api = API.new
  @view = View.new
  @workers = Workers.new
  @stream = Stream.new(@api, @view, @workers)
  @search = Search.new(@api, @view, @workers)
  Settings.load_config
  Settings.get_token
  Settings.init_config
  Logs.create_logger
  Databases.open_databases
  at_exit { Databases.close_all }
end

Instance Method Details

#auto(options) ⇒ Object



490
491
492
493
494
495
496
497
498
# File 'lib/ayadn/action.rb', line 490

def auto(options)
  begin
    @view.clear_screen
    puts Status.auto
    Post.new.auto_readline
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#block(usernames) ⇒ Object



235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/ayadn/action.rb', line 235

def block(usernames)
  begin
    Check.no_username(usernames)
    users = @workers.all_but_me(usernames)
    puts Status.blocking(users.join(','))
    users.each do |user|
      resp = @api.block(user)
      Check.has_been_blocked(user, resp)
      sleep 1 unless users.length == 1
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [usernames]})
  end
end

#blocked(options) ⇒ Object



347
348
349
350
351
352
353
# File 'lib/ayadn/action.rb', line 347

def blocked(options)
  begin
    @stream.blocked(options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#channelsObject



441
442
443
444
445
446
447
448
449
450
# File 'lib/ayadn/action.rb', line 441

def channels
  begin
    @view.downloading
    resp = @api.get_channels
    @view.clear_screen
    @view.show_channels(resp)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [resp['meta']]})
  end
end

#checkins(options) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/ayadn/action.rb', line 30

def checkins(options)
  begin
    @stream.checkins(options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#conversations(options) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/ayadn/action.rb', line 62

def conversations(options)
  begin
    @stream.conversations(options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#convo(post_id, options) ⇒ Object



118
119
120
121
122
123
124
# File 'lib/ayadn/action.rb', line 118

def convo(post_id, options)
  begin
    @stream.convo(post_id, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id, options]})
  end
end

#delete(post_ids) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/ayadn/action.rb', line 126

def delete(post_ids)
  begin
    ids = post_ids.select { |post_id| post_id.is_integer? }
    abort(Status.error_missing_post_id) if ids.empty?
    ids.each do |post_id|
      print Status.deleting_post(post_id)
      resp = @api.delete_post(post_id)
      Check.has_been_deleted(post_id, resp)
      sleep 1 unless ids.length == 1
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id]})
  end
end

#delete_m(args) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/ayadn/action.rb', line 141

def delete_m(args)
  begin
    abort(Status.error_missing_message_id) unless args.length >= 2
    channel = args[0]
    args.shift
    ids = args.select {|message_id| message_id.is_integer?}
    abort(Status.error_missing_message_id) if ids.empty?
    channel_id = @workers.get_channel_id_from_alias(channel)
    ids.each do |message_id|
      print Status.deleting_message(message_id)
      resp = @api.delete_message(channel_id, message_id)
      Check.message_has_been_deleted(message_id, resp)
      sleep 1 unless ids.length == 1
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [message_id]})
  end
end

#download(file_id) ⇒ Object



431
432
433
434
435
436
437
438
439
# File 'lib/ayadn/action.rb', line 431

def download(file_id)
  begin
    file = @api.get_file(file_id)['data']
    FileOps.download_url(file['name'], file['url'])
    puts Status.downloaded(file['name'])
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [file_id, file['url']]})
  end
end

#files(options) ⇒ Object



416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/ayadn/action.rb', line 416

def files(options)
  begin
    @view.downloading(options)
    if options[:raw]
      @view.show_raw(@api.get_files_list(options), options)
      exit
    end
    list = @api.get_files_list(options)
    @view.clear_screen
    list.empty? ? Errors.no_data('files') : @view.show_files_list(list)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#follow(usernames) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/ayadn/action.rb', line 175

def follow(usernames)
  begin
    Check.no_username(usernames)
    users = @workers.all_but_me(usernames)
    puts Status.following(users.join(','))
    users.each do |user|
      resp = @api.follow(user)
      Check.has_been_followed(user, resp)
      sleep 1 unless users.length == 1
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [usernames]})
  end
end

#followers(username, options) ⇒ Object



331
332
333
334
335
336
337
# File 'lib/ayadn/action.rb', line 331

def followers(username, options)
  begin
    @stream.followers(username, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [username, options]})
  end
end

#followings(username, options) ⇒ Object



323
324
325
326
327
328
329
# File 'lib/ayadn/action.rb', line 323

def followings(username, options)
  begin
    @stream.followings(username, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [username, options]})
  end
end

#global(settings) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/ayadn/action.rb', line 38

def global(settings)
  begin
    @stream.global(settings)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [settings]})
  end
end

#hashtag(hashtag, options) ⇒ Object



307
308
309
310
311
312
313
# File 'lib/ayadn/action.rb', line 307

def hashtag(hashtag, options)
  begin
    @search.hashtag(hashtag, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [hashtag, options]})
  end
end

#interactions(options) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/ayadn/action.rb', line 86

def interactions(options)
  begin
    @stream.interactions(options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#mentions(username, options) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/ayadn/action.rb', line 70

def mentions(username, options)
  begin
    @stream.mentions(username, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [username, options]})
  end
end

#messages(channel_id, options) ⇒ Object



452
453
454
455
456
457
458
# File 'lib/ayadn/action.rb', line 452

def messages(channel_id, options)
  begin
    @stream.messages(channel_id, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [channel_id, options]})
  end
end

#mute(usernames) ⇒ Object



205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/ayadn/action.rb', line 205

def mute(usernames)
  begin
    Check.no_username(usernames)
    users = @workers.all_but_me(usernames)
    puts Status.muting(users.join(','))
    users.each do |user|
      resp = @api.mute(user)
      Check.has_been_muted(user, resp)
      sleep 1 unless users.length == 1
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [usernames]})
  end
end

#muted(options) ⇒ Object



339
340
341
342
343
344
345
# File 'lib/ayadn/action.rb', line 339

def muted(options)
  begin
    @stream.muted(options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#nowplaying(options = {}) ⇒ Object



641
642
643
644
# File 'lib/ayadn/action.rb', line 641

def nowplaying(options = {})
  np = NowPlaying.new(@api, @view, @workers)
  options['lastfm'] ? np.lastfm(options) : np.itunes(options)
end

#nowwatching(args, options = {}) ⇒ Object



646
647
648
649
650
651
652
653
654
655
656
657
# File 'lib/ayadn/action.rb', line 646

def nowwatching(args, options = {})
  begin
    abort(Status.error_missing_title) if args.empty?
    nw = NowWatching.new(@view)
    nw.post(args, options)
  rescue ArgumentError => e
    puts Status.no_movie
  rescue => e
    puts Status.wtf
    Errors.global_error({error: e, caller: caller, data: [args, options]})
  end
end

#photos(options) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/ayadn/action.rb', line 54

def photos(options)
  begin
    @stream.photos(options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#pin(post_id, usertags) ⇒ Object



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
# File 'lib/ayadn/action.rb', line 460

def pin(post_id, usertags)
  require 'pinboard'
  require 'base64'
  begin
    Check.bad_post_id(post_id)
    @view.downloading
    resp = @api.get_details(post_id)['data']
    @view.clear_screen
    links = @workers.extract_links(resp)
    resp['text'].nil? ? text = "" : text = resp['text']
    usertags << "ADN"
    handle = "@" + resp['user']['username']
    post_text = "From: #{handle} -- Text: #{text} -- Links: #{links.join(" ")}"
    pinner = Ayadn::PinBoard.new
    unless pinner.has_credentials_file?
      puts Status.no_pin_creds
      pinner.ask_credentials
      puts Status.pin_creds_saved
    end
    credentials = pinner.load_credentials
    maker = Struct.new(:username, :password, :url, :tags, :text, :description)
    bookmark = maker.new(credentials[0], credentials[1], resp['canonical_url'], usertags.join(","), post_text, links[0])
    puts Status.saving_pin
    pinner.pin(bookmark)
    puts Status.done
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id, usertags]})
  end
end

#pmess(username, options = {}) ⇒ Object



549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/ayadn/action.rb', line 549

def pmess(username, options = {})
	begin
    files = FileOps.make_paths(options['embed']) if options['embed']
    Check.no_username(username)
    username = [@workers.add_arobase(username)]
		messenger = Post.new
    puts Status.message_from(username)
		puts Status.message
		lines_array = messenger.compose
		messenger.check_message_length(lines_array)
    text = lines_array.join("\n")
		@view.clear_screen
    if options['embed']
      puts Status.uploading(options['embed'])
      resp = messenger.send_pm_embedded(username, text, files)
    else
      puts Status.posting
      resp = messenger.send_pm(username, text)
    end
    FileOps.save_message(resp) if Settings.options[:backup][:auto_save_sent_messages]
		@view.clear_screen
		puts Status.yourmessage(username[0])
		@view.show_posted(resp)
	rescue => e
    Errors.global_error({error: e, caller: caller, data: [username, options]})
	end
end

#post(args, options) ⇒ Object



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'lib/ayadn/action.rb', line 500

def post(args, options)
  begin
    writer = Post.new
    @view.clear_screen
    if options['embed']
      embed = options['embed']
      text = args.join(" ")
      puts Status.uploading(embed)
      resp = writer.send_embedded(text, FileOps.make_paths(embed))
    else
      puts Status.posting
      resp = writer.post(args)
    end
    FileOps.save_post(resp) if Settings.options[:backup][:auto_save_sent_posts]
    @view.clear_screen
    puts Status.yourpost
    @view.show_posted(resp)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [args, options]})
  end
end

#postinfo(post_id, options) ⇒ Object



382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/ayadn/action.rb', line 382

def (post_id, options)
  begin
    Check.bad_post_id(post_id)
    @view.downloading(options)
    if options[:raw]
      details = @api.get_details(post_id, options)
      @view.show_raw(details, options)
      exit
    end
    @view.clear_screen
    response = @api.get_details(post_id, options)
    Check.no_post(response, post_id)
    resp = response['data']
    response = @api.get_user("@#{resp['user']['username']}")
    Check.no_user(response, response['data']['username'])
    stream = response['data']
    puts "POST:\n".inverse
    @view.show_simple_post([resp], options)
    if resp['repost_of']
      puts "REPOST OF:\n".inverse
      Errors.repost(post_id, resp['repost_of']['id'])
      @view.show_simple_post([resp['repost_of']], options)
    end
    puts "AUTHOR:\n".inverse
    if response['data']['username'] == Settings.config[:identity][:username]
      @view.show_userinfos(stream, @api.get_token_info['data'], true)
    else
      @view.show_userinfos(stream, nil, true)
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id, options]})
  end
end

#posts(username, options) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/ayadn/action.rb', line 78

def posts(username, options)
  begin
    @stream.posts(username, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [username, options]})
  end
end

#random_posts(options) ⇒ Object



676
677
678
679
680
681
682
# File 'lib/ayadn/action.rb', line 676

def random_posts(options)
  begin
    @stream.random_posts(options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [@max_id, @random_post_id, @resp, options]})
  end
end

#reply(post_id, options = {}) ⇒ Object



597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
# File 'lib/ayadn/action.rb', line 597

def reply(post_id, options = {})
  begin
    files = FileOps.make_paths(options['embed']) if options['embed']
    post_id = @workers.get_real_post_id(post_id)
  	puts Status.replying_to(post_id)
  	replied_to = @api.get_details(post_id)
    Check.no_post(replied_to, post_id)
    post_id = @workers.get_original_id(post_id, replied_to)
    if replied_to['data']['repost_of']
      if post_id == replied_to['data']['repost_of']['id']
        replied_to = @api.get_details(post_id)
        Check.no_post(replied_to, post_id)
      end
    end
    poster = Post.new
    puts Status.writing
    puts Status.reply
    lines_array = poster.compose
    poster.check_post_length(lines_array)
    @view.clear_screen
    reply = poster.reply(lines_array.join("\n"), @workers.build_posts([replied_to['data']]))
    if options['embed']
      puts Status.uploading(options['embed'])
      resp = poster.send_reply_embedded(reply, post_id, files)
    else
      puts Status.posting
      resp = poster.send_reply(reply, post_id)
    end
    FileOps.save_post(resp) if Settings.options[:backup][:auto_save_sent_posts]
    @view.clear_screen
    puts Status.done

    options = options.dup
    unless resp['data']['reply_to'].nil?
      options[:reply_to] = resp['data']['reply_to'].to_i
    end
    options[:post_id] = resp['data']['id'].to_i

    @view.render(@api.get_convo(post_id), options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id, options]})
  end
end

#repost(post_id) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/ayadn/action.rb', line 250

def repost(post_id)
  begin
    Check.bad_post_id(post_id)
    puts Status.reposting(post_id)
    resp = @api.get_details(post_id)
    Check.already_reposted(resp)
    id = @workers.get_original_id(post_id, resp)
    Check.has_been_reposted(id, @api.repost(id))
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id, id]})
  end
end

#search(words, options) ⇒ Object



315
316
317
318
319
320
321
# File 'lib/ayadn/action.rb', line 315

def search(words, options)
  begin
    @search.find(words, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [words, options]})
  end
end

#send_to_channel(channel_id) ⇒ Object



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
# File 'lib/ayadn/action.rb', line 577

def send_to_channel(channel_id)
	begin
    channel_id = @workers.get_channel_id_from_alias(channel_id)
	messenger = Post.new
    puts Status.writing
	puts Status.post
	lines_array = messenger.compose
	messenger.check_message_length(lines_array)
	@view.clear_screen
	puts Status.posting
	resp = messenger.send_message(channel_id, lines_array.join("\n"))
    FileOps.save_message(resp) if Settings.options[:backup][:auto_save_sent_messages]
	@view.clear_screen
	puts Status.yourpost
	@view.show_posted(resp)
	rescue => e
    Errors.global_error({error: e, caller: caller, data: [channel_id]})
	end
end

#star(post_id) ⇒ Object



294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/ayadn/action.rb', line 294

def star(post_id)
  begin
    Check.bad_post_id(post_id)
    puts Status.starring(post_id)
    resp = @api.get_details(post_id)
    Check.already_starred(resp)
    id = @workers.get_original_id(post_id, resp)
    Check.has_been_starred(id, @api.star(id))
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id]})
  end
end


46
47
48
49
50
51
52
# File 'lib/ayadn/action.rb', line 46

def trending(options)
  begin
    @stream.trending(options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#tvshow(args, options = {}) ⇒ Object



659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
# File 'lib/ayadn/action.rb', line 659

def tvshow(args, options = {})
  begin
    abort(Status.error_missing_title) if args.empty?
    client = TvShow.new
    if options['alt']
      show_obj = client.find_alt(args.join(' '))
    else
      show_obj = client.find(args.join(' '))
    end
    candidate = client.create_details(show_obj)
    candidate.ok ? candidate.post(options) : candidate.cancel
  rescue => e
    puts Status.wtf
    Errors.global_error({error: e, caller: caller, data: [args, options]})
  end
end

#unblock(usernames) ⇒ Object



220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/ayadn/action.rb', line 220

def unblock(usernames)
  begin
    Check.no_username(usernames)
    users = @workers.all_but_me(usernames)
    puts Status.unblocking(users.join(','))
    users.each do |user|
      resp = @api.unblock(user)
      Check.has_been_unblocked(user, resp)
      sleep 1 unless users.length == 1
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [usernames]})
  end
end

#unfollow(usernames) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/ayadn/action.rb', line 160

def unfollow(usernames)
  begin
    Check.no_username(usernames)
    users = @workers.all_but_me(usernames)
    puts Status.unfollowing(users.join(','))
    users.each do |user|
      resp = @api.unfollow(user)
      Check.has_been_unfollowed(user, resp)
      sleep 1 unless users.length == 1
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [usernames]})
  end
end

#unified(options) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ayadn/action.rb', line 22

def unified(options)
  begin
    @stream.unified(options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#unmute(usernames) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/ayadn/action.rb', line 190

def unmute(usernames)
  begin
    Check.no_username(usernames)
    users = @workers.all_but_me(usernames)
    puts Status.unmuting(users.join(','))
    users.each do |user|
      resp = @api.unmute(user)
      Check.has_been_unmuted(user, resp)
      sleep 1 unless users.length == 1
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [usernames]})
  end
end

#unrepost(post_id) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/ayadn/action.rb', line 263

def unrepost(post_id)
  begin
    Check.bad_post_id(post_id)
    puts Status.unreposting(post_id)
    if @api.get_details(post_id)['data']['you_reposted']
      Check.has_been_unreposted(post_id, @api.unrepost(post_id))
    else
      puts Status.not_your_repost
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id]})
  end
end

#unstar(post_id) ⇒ Object



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/ayadn/action.rb', line 277

def unstar(post_id)
  begin
    Check.bad_post_id(post_id)
    puts Status.unstarring(post_id)
    resp = @api.get_details(post_id)
    id = @workers.get_original_id(post_id, resp)
    resp = @api.get_details(id)
    if resp['data']['you_starred']
      Check.has_been_unstarred(id, @api.unstar(id))
    else
      puts Status.not_your_starred
    end
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id]})
  end
end

#userinfo(username, options) ⇒ Object



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/ayadn/action.rb', line 363

def userinfo(username, options)
  begin
    Check.no_username(username)
    username = @workers.add_arobase(username)
    @view.downloading(options)
    if options[:raw]
      resp = @api.get_user(username)
      @view.show_raw(resp, options)
      exit
    end
    stream = @api.get_user(username)
    Check.no_user(stream, username)
    Check.same_username(stream) ? token = @api.get_token_info['data'] : token = nil
    @view.infos(stream['data'], token)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [username, options]})
  end
end

#versionObject



684
685
686
687
688
689
690
691
692
693
694
# File 'lib/ayadn/action.rb', line 684

def version
  begin
    puts "\nAYADN\n".color(:red)
    puts "Version:\t".color(:cyan) + "#{VERSION}\n".color(:green)
    puts "Changelog:\t".color(:cyan) + "https://github.com/ericdke/na/blob/master/CHANGELOG.md\n".color(Settings.options[:colors][:link])
    puts "Docs:\t\t".color(:cyan) + "https://github.com/ericdke/na/tree/master/doc".color(Settings.options[:colors][:link])
    puts "\n"
  rescue => e
    Errors.global_error({error: e, caller: caller, data: []})
  end
end

#view_settings(options) ⇒ Object



355
356
357
358
359
360
361
# File 'lib/ayadn/action.rb', line 355

def view_settings(options)
  begin
    options[:raw] ? (puts Settings.options.to_json) : @view.show_settings
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [options]})
  end
end

#whatstarred(username, options) ⇒ Object



94
95
96
97
98
99
100
# File 'lib/ayadn/action.rb', line 94

def whatstarred(username, options)
  begin
    @stream.whatstarred(username, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [username, options]})
  end
end

#whoreposted(post_id, options) ⇒ Object



102
103
104
105
106
107
108
# File 'lib/ayadn/action.rb', line 102

def whoreposted(post_id, options)
  begin
    @stream.whoreposted(post_id, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id, options]})
  end
end

#whostarred(post_id, options) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/ayadn/action.rb', line 110

def whostarred(post_id, options)
  begin
    @stream.whostarred(post_id, options)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [post_id, options]})
  end
end

#write(options) ⇒ Object



522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/ayadn/action.rb', line 522

def write(options)
  begin
    files = FileOps.make_paths(options['embed']) if options['embed']
    writer = Post.new
    puts Status.writing
    puts Status.post
    lines_array = writer.compose
    writer.check_post_length(lines_array)
    text = lines_array.join("\n")
    if options['embed']
      @view.clear_screen
      puts Status.uploading(options['embed'])
      resp = writer.send_embedded(text, files)
    else
      resp = writer.send_post(text)
    end
    @view.clear_screen
    puts Status.posting
    FileOps.save_post(resp) if Settings.options[:backup][:auto_save_sent_posts]
    @view.clear_screen
    puts Status.yourpost
    @view.show_posted(resp)
  rescue => e
    Errors.global_error({error: e, caller: caller, data: [text, options]})
  end
end