Class: Ayadn::Action
- Inherits:
-
Object
- Object
- Ayadn::Action
- Defined in:
- lib/ayadn/action.rb
Instance Method Summary collapse
- #auto(options) ⇒ Object
- #block(usernames) ⇒ Object
- #blocked(options) ⇒ Object
- #channels(options) ⇒ Object
- #convo(post_id, options) ⇒ Object
- #delete(post_ids, options = {}) ⇒ Object
- #delete_m(args) ⇒ Object
- #download(file_id) ⇒ Object
- #files(options) ⇒ Object
- #follow(usernames) ⇒ Object
- #followers(username, options) ⇒ Object
- #followings(username, options) ⇒ Object
- #hashtag(hashtag, options) ⇒ Object
-
#initialize ⇒ Action
constructor
This class is the main initializer + dispatcher It responds to the CLI commands dispatcher, app.rb.
- #mentions(username, options) ⇒ Object
- #messages(channel_id, options) ⇒ Object
- #messages_unread(options) ⇒ Object
- #method_missing(meth, options) ⇒ Object
- #mute(usernames) ⇒ Object
- #muted(options) ⇒ Object
- #nowplaying(options = {}) ⇒ Object
- #nowwatching(args, options = {}) ⇒ Object
- #pin(post_id, usertags, options = {}) ⇒ Object
- #pmess(username, options = {}) ⇒ Object
- #post(args, options) ⇒ Object
- #postinfo(post_id, options) ⇒ Object
- #posts(username, options) ⇒ Object
- #random_posts(options) ⇒ Object
- #reply(post_id, options = {}) ⇒ Object
- #repost(post_ids, options = {}) ⇒ Object
- #search(words, options) ⇒ Object
- #send_to_channel(channel_id, options = {}) ⇒ Object
- #star(post_ids, options = {}) ⇒ Object
- #tvshow(args, options = {}) ⇒ Object
- #unblock(usernames) ⇒ Object
- #unfollow(usernames) ⇒ Object
- #unmute(usernames) ⇒ Object
- #unrepost(post_ids, options = {}) ⇒ Object
- #unstar(post_ids, options = {}) ⇒ Object
- #userinfo(username, options = {}) ⇒ Object
- #userupdate(options) ⇒ Object
- #version ⇒ Object
- #view_settings(options) ⇒ Object
- #whatstarred(username, options) ⇒ Object
- #whoreposted(post_id, options) ⇒ Object
- #whostarred(post_id, options) ⇒ Object
- #write(options) ⇒ Object
Constructor Details
#initialize ⇒ Action
This class is the main initializer + dispatcher It responds to the CLI commands dispatcher, app.rb
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ayadn/action.rb', line 9 def initialize @api = API.new @view = View.new @workers = Workers.new @thor = Thor::Shell::Color.new @status = Status.new @check = Check.new Settings.load_config Settings.get_token Settings.init_config Logs.create_logger Databases.open_databases end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ayadn/action.rb', line 23 def method_missing(meth, ) case meth.to_s when 'unified', 'checkins', 'global', 'trending', 'photos', 'conversations', 'interactions' begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.send(meth.to_sym, ) rescue => e Errors.global_error({error: e, caller: caller, data: [meth, ]}) end else super end end |
Instance Method Details
#auto(options) ⇒ Object
655 656 657 658 659 660 661 662 663 |
# File 'lib/ayadn/action.rb', line 655 def auto() begin @view.clear_screen @status.auto Post.new.auto_readline rescue => e Errors.global_error({error: e, caller: caller, data: []}) end end |
#block(usernames) ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/ayadn/action.rb', line 221 def block(usernames) begin @check.no_username(usernames) users = @workers.all_but_me(usernames) puts "\n" @status.blocking(users.join(',')) users.each do |user| resp = @api.block(user) @check.has_been_blocked(user, resp) end rescue => e Errors.global_error({error: e, caller: caller, data: [usernames]}) end end |
#blocked(options) ⇒ Object
391 392 393 394 395 396 397 398 399 |
# File 'lib/ayadn/action.rb', line 391 def blocked() begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.blocked() rescue => e Errors.global_error({error: e, caller: caller, data: []}) end end |
#channels(options) ⇒ Object
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/ayadn/action.rb', line 520 def channels begin channels = if [:id] channel_id = [:id].map {|id| @workers.get_channel_id_from_alias(id)} lambda { @api.get_channel(channel_id, ) } else lambda { @api.get_channels } end if [:raw] @view.show_raw(channels.call) exit else @view.downloading resp = channels.call @view.clear_screen @view.show_channels(resp, ) end rescue => e Errors.global_error({error: e, caller: caller, data: []}) end end |
#convo(post_id, options) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/ayadn/action.rb', line 88 def convo(post_id, ) begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.convo(post_id, ) rescue => e Errors.global_error({error: e, caller: caller, data: [post_id, ]}) end end |
#delete(post_ids, options = {}) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ayadn/action.rb', line 98 def delete(post_ids, = {}) begin ids = post_ids.select { |post_id| post_id.is_integer? } if ids.empty? @status.error_missing_post_id exit end if [:force] Settings.global[:force] = true else ids.map! { |post_id| @workers.get_real_post_id(post_id) } end puts "\n" ids.each do |post_id| @status.deleting_post(post_id) resp = @api.delete_post(post_id) @check.has_been_deleted(post_id, resp) end rescue => e Errors.global_error({error: e, caller: caller, data: [post_ids]}) end end |
#delete_m(args) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/ayadn/action.rb', line 121 def delete_m(args) begin unless args.length >= 2 @status. exit end channel = args[0] args.shift ids = args.select {|| .is_integer?} if ids.empty? @status. exit end channel_id = @workers.get_channel_id_from_alias(channel) puts "\n" ids.each do || @status.() resp = @api.(channel_id, ) @check.(, resp) end rescue => e Errors.global_error({error: e, caller: caller, data: [args]}) end end |
#download(file_id) ⇒ Object
510 511 512 513 514 515 516 517 518 |
# File 'lib/ayadn/action.rb', line 510 def download(file_id) begin file = @api.get_file(file_id)['data'] FileOps.download_url(file['name'], file['url']) @status.downloaded(file['name']) rescue => e Errors.global_error({error: e, caller: caller, data: [file_id, file['url']]}) end end |
#files(options) ⇒ Object
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/ayadn/action.rb', line 493 def files() begin get_files = lambda { @api.get_files_list() } if [:raw] @view.show_raw(get_files.call) else @view.downloading list = get_files.call Errors.no_data('files') if list.empty? @view.clear_screen @view.show_files_list(list) end rescue => e Errors.global_error({error: e, caller: caller, data: []}) end end |
#follow(usernames) ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/ayadn/action.rb', line 161 def follow(usernames) begin @check.no_username(usernames) users = @workers.all_but_me(usernames) puts "\n" @status.following(users.join(',')) users.each do |user| resp = @api.follow(user) @check.has_been_followed(user, resp) end rescue => e Errors.global_error({error: e, caller: caller, data: [usernames]}) end end |
#followers(username, options) ⇒ Object
371 372 373 374 375 376 377 378 379 |
# File 'lib/ayadn/action.rb', line 371 def followers(username, ) begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.followers(username, ) rescue => e Errors.global_error({error: e, caller: caller, data: [username, ]}) end end |
#followings(username, options) ⇒ Object
361 362 363 364 365 366 367 368 369 |
# File 'lib/ayadn/action.rb', line 361 def followings(username, ) begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.followings(username, ) rescue => e Errors.global_error({error: e, caller: caller, data: [username, ]}) end end |
#hashtag(hashtag, options) ⇒ Object
341 342 343 344 345 346 347 348 349 |
# File 'lib/ayadn/action.rb', line 341 def hashtag(hashtag, ) begin Settings.[:timeline][:compact] = true if [:compact] == true search = Search.new(@api, @view, @workers) search.hashtag(hashtag, ) rescue => e Errors.global_error({error: e, caller: caller, data: [hashtag, ]}) end end |
#mentions(username, options) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/ayadn/action.rb', line 38 def mentions(username, ) begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.mentions(username, ) rescue => e Errors.global_error({error: e, caller: caller, data: [username, ]}) end end |
#messages(channel_id, options) ⇒ Object
542 543 544 545 546 547 548 549 550 |
# File 'lib/ayadn/action.rb', line 542 def (channel_id, ) begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.(channel_id, ) rescue => e Errors.global_error({error: e, caller: caller, data: [channel_id, ]}) end end |
#messages_unread(options) ⇒ Object
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
# File 'lib/ayadn/action.rb', line 552 def () begin Settings.[:timeline][:compact] = true if [:compact] == true if [:silent] Settings.[:marker][:messages] = false end puts "\n" @thor.say_status :searching, "channels with unread PMs" response = @api.get_channels unread_channels = [] response['data'].map do |ch| if ch['type'] == "net.app.core.pm" && ch['has_unread'] == true unread_channels << ch['id'] end end if unread_channels.empty? @status. exit end = {} unread_channels.reverse.each do |id| @thor.say_status :downloading, "messages from channel #{id}" since = Databases.find_last_id_from("channel:#{id}") unless since.nil? = {count: 20, since_id: since} else = {count: 20} end ch = @api.(id, ) last_read_id = ch['meta']['marker']['last_read_id'].to_i = ch['meta']['max_id'] = [] ch['data'].each do |msg| << msg if msg['id'].to_i > last_read_id end [id] = [, ] end if Settings.[:marker][:messages] == true .each do |k,v| name = "channel:#{k}" Databases.pagination_insert(name, v[1]) resp = @api.update_marker(name, v[1]) res = JSON.parse(resp) if res['meta']['code'] != 200 @thor.say_status :error, "couldn't update channel #{k} as read", :red else @thor.say_status :updated, "channel #{k} as read", :green end end end @view.clear_screen .each do |k,v| @status.unread_from_channel(k) @view.show_posts(v[0]) end puts "\n" if Settings.[:timeline][:compact] rescue => e Errors.global_error({error: e, caller: caller, data: []}) end end |
#mute(usernames) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/ayadn/action.rb', line 191 def mute(usernames) begin @check.no_username(usernames) users = @workers.all_but_me(usernames) puts "\n" @status.muting(users.join(',')) users.each do |user| resp = @api.mute(user) @check.has_been_muted(user, resp) end rescue => e Errors.global_error({error: e, caller: caller, data: [usernames]}) end end |
#muted(options) ⇒ Object
381 382 383 384 385 386 387 388 389 |
# File 'lib/ayadn/action.rb', line 381 def muted() begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.muted() rescue => e Errors.global_error({error: e, caller: caller, data: []}) end end |
#nowplaying(options = {}) ⇒ Object
838 839 840 841 842 843 844 845 846 847 848 |
# File 'lib/ayadn/action.rb', line 838 def ( = {}) Settings.[:timeline][:compact] = true if [:compact] == true np = NowPlaying.new(@api, @view, @workers, ) if [:lastfm] np.lastfm() elsif [:deezer] np.deezer() else np.itunes() end end |
#nowwatching(args, options = {}) ⇒ Object
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 |
# File 'lib/ayadn/action.rb', line 850 def nowwatching(args, = {}) begin Settings.[:timeline][:compact] = true if [:compact] == true if args.empty? @status.error_missing_title exit end nw = NowWatching.new(@view) nw.post(args, ) rescue ArgumentError => e @status.no_movie rescue => e @status.wtf Errors.global_error({error: e, caller: caller, data: [args, ]}) end end |
#pin(post_id, usertags, options = {}) ⇒ Object
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 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/ayadn/action.rb', line 613 def pin(post_id, , = {}) begin require 'pinboard' require 'base64' rescue LoadError => e puts "\nAYADN: Error while loading Gems\n\n" puts "RUBY: #{e}\n\n" exit end begin @check.bad_post_id(post_id) Settings.[:timeline][:compact] = true if [:compact] == true if [:force] Settings.global[:force] = true else post_id = @workers.get_real_post_id(post_id) end @view.downloading resp = @api.get_details(post_id)['data'] @view.clear_screen links = @workers.extract_links(resp) resp['text'].nil? ? text = "" : text = resp['text'] << "ADN" handle = "@" + resp['user']['username'] post_text = "From: #{handle} -- Text: #{text} -- Links: #{links.join(" ")}" pinner = Ayadn::PinBoard.new unless pinner.has_credentials_file? @status.no_pin_creds pinner.ask_credentials @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'], .join(","), post_text, resp['canonical_url']) @status.saving_pin pinner.pin(bookmark) @status.done rescue => e Errors.global_error({error: e, caller: caller, data: [post_id, ]}) end end |
#pmess(username, options = {}) ⇒ Object
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
# File 'lib/ayadn/action.rb', line 706 def pmess(username, = {}) begin Settings.[:timeline][:compact] = true if [:compact] == true if [:silent] Settings.[:marker][:messages] = false end @check.no_username(username) username = [@workers.add_arobase(username)] writer = Post.new @status.(username) @status. lines_array = writer.compose text = lines_array.join("\n") writer.(text) if writer.(text) == false @view.clear_screen @status.posting if [:poster] settings = .dup = NowWatching.new.get_poster(settings[:poster], settings) end resp = writer.pm({options: , text: text, username: username}) if Settings.[:marker][:messages] == true if resp['meta']['code'] == 200 data = resp['data'] name = "channel:#{data['channel_id']}" Databases.pagination_insert(name, data['id']) marked = @api.update_marker(name, data['id']) updated = JSON.parse(marked) if updated['meta']['code'] != 200 raise "couldn't update channel #{data['channel_id']} as read" end end end FileOps.(resp) if Settings.[:backup][:messages] @view.clear_screen @status.(username[0]) @view.show_posted(resp) rescue => e Errors.global_error({error: e, caller: caller, data: [username, ]}) end end |
#post(args, options) ⇒ Object
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 |
# File 'lib/ayadn/action.rb', line 665 def post(args, ) begin Settings.[:timeline][:compact] = true if [:compact] == true writer = Post.new if [:poster] # Returns the same options hash + poster embed settings = .dup = NowWatching.new.get_poster(settings[:poster], settings) end text = args.join(" ") writer.post_size_error(text) if writer.post_size_ok?(text) == false @view.clear_screen @status.posting resp = writer.post({options: , text: text}) save_and_view(resp) rescue => e Errors.global_error({error: e, caller: caller, data: [args, ]}) end end |
#postinfo(post_id, options) ⇒ Object
451 452 453 454 455 456 457 458 459 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 489 490 491 |
# File 'lib/ayadn/action.rb', line 451 def postinfo(post_id, ) begin @check.bad_post_id(post_id) Settings.[:timeline][:compact] = true if [:compact] == true if [:force] Settings.global[:force] = true else post_id = @workers.get_real_post_id(post_id) end details = lambda { @api.get_details(post_id, ) } if [:raw] @view.show_raw(details.call, ) exit end @view.clear_screen response = details.call @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'] @status.post_info @view.show_simple_post([resp], ) puts "\n" if Settings.[:timeline][:compact] == true @thor.say_status "info", "author", "cyan" puts "\n" unless Settings.[:timeline][:compact] == true 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 if resp['repost_of'] @status.repost_info Errors.repost(post_id, resp['repost_of']['id']) @view.show_simple_post([resp['repost_of']], ) puts "\n" if Settings.[:timeline][:compact] == true end rescue => e Errors.global_error({error: e, caller: caller, data: [post_id, ]}) end end |
#posts(username, options) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/ayadn/action.rb', line 48 def posts(username, ) begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.posts(username, ) rescue => e Errors.global_error({error: e, caller: caller, data: [username, ]}) end end |
#random_posts(options) ⇒ Object
888 889 890 891 892 893 894 895 896 |
# File 'lib/ayadn/action.rb', line 888 def random_posts() begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.random_posts() rescue => e Errors.global_error({error: e, caller: caller, data: [@max_id, @random_post_id, @resp, ]}) end end |
#reply(post_id, options = {}) ⇒ Object
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
# File 'lib/ayadn/action.rb', line 748 def reply(post_id, = {}) begin Settings.[:timeline][:compact] = true if [:compact] == true @check.bad_post_id(post_id) if [:force] Settings.global[:force] = true else post_id = @workers.get_real_post_id(post_id) end @status.(post_id) replied_to = @api.get_details(post_id) @check.no_post(replied_to, post_id) unless [:noredirect] post_id = @workers.get_original_id(post_id, replied_to) end 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 # ---- writer = Post.new @status.writing @status.reply lines_array = writer.compose text = lines_array.join("\n") # text length is tested in Post class for the reply command @view.clear_screen replied_to = @workers.build_posts([replied_to['data']]) if [:poster] settings = .dup = NowWatching.new.get_poster(settings[:poster], settings) end resp = writer.reply({options: , text: text, id: post_id, reply_to: replied_to}) FileOps.save_post(resp) if Settings.[:backup][:posts] # ---- = .dup unless resp['data']['reply_to'].nil? [:reply_to] = resp['data']['reply_to'].to_i end [:post_id] = resp['data']['id'].to_i @view.render(@api.get_convo(post_id), ) puts "\n" if Settings.[:timeline][:compact] == true && ![:raw] rescue => e Errors.global_error({error: e, caller: caller, data: [post_id, ]}) end end |
#repost(post_ids, options = {}) ⇒ Object
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/ayadn/action.rb', line 236 def repost(post_ids, = {}) begin ids = post_ids.select { |post_id| post_id.is_integer? } if ids.empty? @status.error_missing_post_id exit end if [:force] Settings.global[:force] = true else ids.map! { |post_id| @workers.get_real_post_id(post_id) } end puts "\n" ids.each do |post_id| @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)) end rescue => e Errors.global_error({error: e, caller: caller, data: [post_ids, id]}) end end |
#search(words, options) ⇒ Object
351 352 353 354 355 356 357 358 359 |
# File 'lib/ayadn/action.rb', line 351 def search(words, ) begin Settings.[:timeline][:compact] = true if [:compact] == true search = Search.new(@api, @view, @workers) search.find(words, ) rescue => e Errors.global_error({error: e, caller: caller, data: [words, ]}) end end |
#send_to_channel(channel_id, options = {}) ⇒ Object
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 |
# File 'lib/ayadn/action.rb', line 797 def send_to_channel(channel_id, = {}) begin Settings.[:timeline][:compact] = true if [:compact] == true if [:silent] Settings.[:marker][:messages] = false end channel_id = @workers.get_channel_id_from_alias(channel_id) writer = Post.new @status.writing @status. lines_array = writer.compose text = lines_array.join("\n") writer.(text) if writer.(text) == false @view.clear_screen @status.posting if [:poster] settings = .dup = NowWatching.new.get_poster(settings[:poster], settings) end resp = writer.({options: , id: channel_id, text: text}) if Settings.[:marker][:messages] == true if resp['meta']['code'] == 200 data = resp['data'] name = "channel:#{data['channel_id']}" Databases.pagination_insert(name, data['id']) marked = @api.update_marker(name, data['id']) updated = JSON.parse(marked) if updated['meta']['code'] != 200 raise "couldn't update channel #{data['channel_id']} as read" end end end FileOps.(resp) if Settings.[:backup][:messages] @view.clear_screen @status.yourpost @view.show_posted(resp) rescue => e Errors.global_error({error: e, caller: caller, data: [channel_id, ]}) end end |
#star(post_ids, options = {}) ⇒ Object
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/ayadn/action.rb', line 316 def star(post_ids, = {}) begin ids = post_ids.select { |post_id| post_id.is_integer? } if ids.empty? @status.error_missing_post_id exit end if [:force] Settings.global[:force] = true else ids.map! { |post_id| @workers.get_real_post_id(post_id) } end puts "\n" ids.each do |post_id| @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)) end rescue => e Errors.global_error({error: e, caller: caller, data: [post_ids]}) end end |
#tvshow(args, options = {}) ⇒ Object
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 |
# File 'lib/ayadn/action.rb', line 867 def tvshow(args, = {}) begin Settings.[:timeline][:compact] = true if [:compact] == true if args.empty? @status.error_missing_title exit end client = TvShow.new show_obj = if [:alt] client.find_alt(args.join(' ')) else client.find(args.join(' ')) end candidate = client.create_details(show_obj) candidate.ok ? candidate.post() : candidate.cancel rescue => e @status.wtf Errors.global_error({error: e, caller: caller, data: [args, ]}) end end |
#unblock(usernames) ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/ayadn/action.rb', line 206 def unblock(usernames) begin @check.no_username(usernames) users = @workers.all_but_me(usernames) puts "\n" @status.unblocking(users.join(',')) users.each do |user| resp = @api.unblock(user) @check.has_been_unblocked(user, resp) end rescue => e Errors.global_error({error: e, caller: caller, data: [usernames]}) end end |
#unfollow(usernames) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/ayadn/action.rb', line 146 def unfollow(usernames) begin @check.no_username(usernames) users = @workers.all_but_me(usernames) puts "\n" @status.unfollowing(users.join(',')) users.each do |user| resp = @api.unfollow(user) @check.has_been_unfollowed(user, resp) end rescue => e Errors.global_error({error: e, caller: caller, data: [usernames]}) end end |
#unmute(usernames) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/ayadn/action.rb', line 176 def unmute(usernames) begin @check.no_username(usernames) users = @workers.all_but_me(usernames) puts "\n" @status.unmuting(users.join(',')) users.each do |user| resp = @api.unmute(user) @check.has_been_unmuted(user, resp) end rescue => e Errors.global_error({error: e, caller: caller, data: [usernames]}) end end |
#unrepost(post_ids, options = {}) ⇒ Object
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/ayadn/action.rb', line 261 def unrepost(post_ids, = {}) begin ids = post_ids.select { |post_id| post_id.is_integer? } if ids.empty? @status.error_missing_post_id exit end if [:force] Settings.global[:force] = true else ids.map! { |post_id| @workers.get_real_post_id(post_id) } end puts "\n" ids.each do |post_id| @status.unreposting(post_id) if @api.get_details(post_id)['data']['you_reposted'] @check.has_been_unreposted(post_id, @api.unrepost(post_id)) else @status.not_your_repost end end rescue => e Errors.global_error({error: e, caller: caller, data: [post_ids]}) end end |
#unstar(post_ids, options = {}) ⇒ Object
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/ayadn/action.rb', line 287 def unstar(post_ids, = {}) begin ids = post_ids.select { |post_id| post_id.is_integer? } if ids.empty? @status.error_missing_post_id exit end if [:force] Settings.global[:force] = true else ids.map! { |post_id| @workers.get_real_post_id(post_id) } end puts "\n" ids.each do |post_id| @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 @status.not_your_starred end end rescue => e Errors.global_error({error: e, caller: caller, data: [post_ids]}) end end |
#userinfo(username, options = {}) ⇒ Object
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 |
# File 'lib/ayadn/action.rb', line 429 def userinfo(username, = {}) begin Settings.[:timeline][:compact] = true if [:compact] == true @check.no_username(username) usernames = @workers.add_arobases_to_usernames(username) usernames.each.with_index do |username, index| if [:raw] @view.show_raw(@api.get_user(username), ) else @view.downloading if index == 0 stream = @api.get_user(username) @check.no_user(stream, username) @check.same_username(stream) ? token = @api.get_token_info['data'] : token = nil @view.clear_screen if index == 0 @view.infos(stream['data'], token) end end rescue => e Errors.global_error({error: e, caller: caller, data: [username, ]}) end end |
#userupdate(options) ⇒ Object
415 416 417 418 419 420 421 422 423 424 425 426 427 |
# File 'lib/ayadn/action.rb', line 415 def userupdate begin profile = Profile.new() profile.get_text_from_user profile.prepare_payload @status.updating_profile profile.update @status.done userinfo(['me'], ) rescue => e Errors.global_error({error: e, caller: caller, data: []}) end end |
#version ⇒ Object
898 899 900 901 902 903 904 |
# File 'lib/ayadn/action.rb', line 898 def version begin @status.version rescue => e Errors.global_error({error: e, caller: caller, data: []}) end end |
#view_settings(options) ⇒ Object
401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'lib/ayadn/action.rb', line 401 def view_settings() begin if [:raw] jj JSON.parse(Settings.config.to_json) jj JSON.parse(Settings..to_json) else Settings.[:timeline][:compact] = true if [:compact] == true @view.show_settings end rescue => e Errors.global_error({error: e, caller: caller, data: []}) end end |
#whatstarred(username, options) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/ayadn/action.rb', line 58 def whatstarred(username, ) begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.whatstarred(username, ) rescue => e Errors.global_error({error: e, caller: caller, data: [username, ]}) end end |
#whoreposted(post_id, options) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/ayadn/action.rb', line 68 def whoreposted(post_id, ) begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.whoreposted(post_id, ) rescue => e Errors.global_error({error: e, caller: caller, data: [post_id, ]}) end end |
#whostarred(post_id, options) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/ayadn/action.rb', line 78 def whostarred(post_id, ) begin Settings.[:timeline][:compact] = true if [:compact] == true stream = Stream.new(@api, @view, @workers) stream.whostarred(post_id, ) rescue => e Errors.global_error({error: e, caller: caller, data: [post_id, ]}) end end |
#write(options) ⇒ Object
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
# File 'lib/ayadn/action.rb', line 684 def write() begin Settings.[:timeline][:compact] = true if [:compact] == true writer = Post.new @status.writing @status.post lines_array = writer.compose text = lines_array.join("\n") writer.post_size_error(text) if writer.post_size_ok?(text) == false @view.clear_screen @status.posting if [:poster] settings = .dup = NowWatching.new.get_poster(settings[:poster], settings) end resp = writer.post({options: , text: text}) save_and_view(resp) rescue => e Errors.global_error({error: e, caller: caller, data: [text, ]}) end end |