Guest User

Untitled

a guest
Oct 13th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. require 'rubygems'
  2. require 'highline/import'
  3. require 'twitter'
  4.  
  5. def login_on_twitter
  6. screen_name = ask("enter your screen name: ") {|q| q.echo = true}
  7. password = ask("enter your password: ") {|q| q.echo = false }
  8.  
  9. httpauth = Twitter::HTTPAuth.new(screen_name,password,:ssl => true)
  10. @client = Twitter::Base.new(httpauth)
  11. begin
  12. @client.verify_credentials
  13. rescue Twitter::Unauthorized
  14. puts "login failed! wrong credentials..."
  15. exit
  16. end
  17. end
  18.  
  19. def block_users
  20. friends = @client.friend_ids
  21. followers = @client.follower_ids
  22. to_be_blocked = followers - friends
  23.  
  24. if to_be_blocked.empty?
  25. puts "no bots detected, exiting..."
  26. exit
  27. end
  28.  
  29. to_be_blocked.each do |id|
  30. user = @client.user id
  31. puts "#{user.name} (#{user.screen_name})"
  32. end
  33. puts "block all listed followers? [ALL|N]"
  34. confirmation = gets.chomp
  35. if confirmation == "ALL"
  36. to_be_blocked.each do |id|
  37. @client.block(id)
  38. end
  39. else
  40. to_be_blocked.each do |id|
  41. user = @client.user id
  42. puts "block #{user.name} (#{user.screen_name})? [Yn]"
  43. confirmation = gets.chomp
  44. @client.block(id) if confirmation == "Y"
  45. end
  46. end
  47. end
  48.  
  49. login_on_twitter
  50. block_users
Add Comment
Please, Sign In to add comment