Class: T::Delete
- Inherits:
-
Thor
- Object
- Thor
- T::Delete
- Includes:
- Requestable, Utils
- Defined in:
- lib/t/delete.rb
Instance Method Summary collapse
- #account(account, key = nil) ⇒ Object
- #block(user, *users) ⇒ Object
- #dm(direct_message_id, *direct_message_ids) ⇒ Object
- #favorite(status_id, *status_ids) ⇒ Object
-
#initialize ⇒ Delete
constructor
A new instance of Delete.
- #list(list) ⇒ Object
- #mute(user, *users) ⇒ Object
- #status(status_id, *status_ids) ⇒ Object
Constructor Details
Instance Method Details
#account(account, key = nil) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/t/delete.rb', line 106 def account(account, key = nil) if key && @rcfile.profiles[account].keys.size > 1 @rcfile.delete_key(account, key) else @rcfile.delete_profile(account) end end |
#block(user, *users) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/t/delete.rb', line 22 def block(user, *users) unblocked_users, number = fetch_users(users.unshift(user), ) do |users_to_unblock| client.unblock(users_to_unblock) end say "@#{@rcfile.active_profile[0]} unblocked #{pluralize(number, 'user')}." say say "Run `#{File.basename($PROGRAM_NAME)} block #{unblocked_users.collect { |unblocked_user| "@#{unblocked_user.screen_name}" }.join(' ')}` to block." end |
#dm(direct_message_id, *direct_message_ids) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/t/delete.rb', line 33 def dm(, *) .unshift() require "t/core_ext/string" .collect!(&:to_i) if ["force"] client.(*) say "@#{@rcfile.active_profile[0]} deleted #{.size} direct message#{.size == 1 ? '' : 's'}." else .each do || = client.() next unless recipient = client.user(.recipient_id) next unless yes? "Are you sure you want to permanently delete the direct message to @#{recipient.screen_name}: \"#{.text}\"? [y/N]" client.() say "@#{@rcfile.active_profile[0]} deleted the direct message sent to @#{recipient.screen_name}: \"#{.text}\"" end end end |
#favorite(status_id, *status_ids) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/t/delete.rb', line 57 def favorite(status_id, *status_ids) status_ids.unshift(status_id) require "t/core_ext/string" status_ids.collect!(&:to_i) if ["force"] tweets = client.unfavorite(status_ids) tweets.each do |status| say "@#{@rcfile.active_profile[0]} unfavorited @#{status.user.screen_name}'s status: \"#{status.full_text}\"" end else status_ids.each do |status_id_to_unfavorite| status = client.status(status_id_to_unfavorite, include_my_retweet: false) next unless yes? "Are you sure you want to remove @#{status.user.screen_name}'s status: \"#{status.full_text}\" from your favorites? [y/N]" client.unfavorite(status_id_to_unfavorite) say "@#{@rcfile.active_profile[0]} unfavorited @#{status.user.screen_name}'s status: \"#{status.full_text}\"" end end end |
#list(list) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/t/delete.rb', line 81 def list(list) if ["id"] require "t/core_ext/string" list = list.to_i end list = client.list(list) return if !["force"] && !(yes? "Are you sure you want to permanently delete the list \"#{list.name}\"? [y/N]") client.destroy_list(list) say "@#{@rcfile.active_profile[0]} deleted the list \"#{list.name}\"." end |
#mute(user, *users) ⇒ Object
96 97 98 99 100 101 102 103 |
# File 'lib/t/delete.rb', line 96 def mute(user, *users) unmuted_users, number = fetch_users(users.unshift(user), ) do |users_to_unmute| client.unmute(users_to_unmute) end say "@#{@rcfile.active_profile[0]} unmuted #{pluralize(number, 'user')}." say say "Run `#{File.basename($PROGRAM_NAME)} mute #{unmuted_users.collect { |unmuted_user| "@#{unmuted_user.screen_name}" }.join(' ')}` to mute." end |
#status(status_id, *status_ids) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/t/delete.rb', line 116 def status(status_id, *status_ids) status_ids.unshift(status_id) require "t/core_ext/string" status_ids.collect!(&:to_i) if ["force"] tweets = client.destroy_status(status_ids, trim_user: true) tweets.each do |status| say "@#{@rcfile.active_profile[0]} deleted the Tweet: \"#{status.full_text}\"" end else status_ids.each do |status_id_to_delete| status = client.status(status_id_to_delete, include_my_retweet: false) next unless yes? "Are you sure you want to permanently delete @#{status.user.screen_name}'s status: \"#{status.full_text}\"? [y/N]" client.destroy_status(status_id_to_delete, trim_user: true) say "@#{@rcfile.active_profile[0]} deleted the Tweet: \"#{status.full_text}\"" end end end |