twatter.rb
# We call this function to check if a handle is available
We call this function to check if a handle is available
We call this function to check if a handle is available
def check_handle(handle)
  begin
    if handle.length < 5
      handle_error("!ts!","#{handle}")
      @twitter = false
    elsif handle.length > 15
      handle_error("!tl!","#{handle}")
      @twitter = false
    else
      @twitter = @client.user(handle)
    end
    if @twitter
      @taken_handles << handle
      @taken_count += 1
    else
      @invalid_handles << handle
      log_word = "Invalid"
    end
  rescue Exception => e
    if e.message == "User not found."
      @available_count += 1
      @available_handles << handle
      log_word = "Available"
    elsif e.message == "User has been suspended."
      @suspended_count += 1
      @suspended_handles << handle
      log_word = "Suspended"
    elsif e.message == "Rate limit exceeded"
      log_word = "Rate Limited"
      erorr = "RATE LIMIT EXCEEDED\nTwitter has stopped you checking any further user names for a little while. \nWhen this happens it's best to rerty again in 15 minutes or so. You were up to @#{handle}, you can restart your check from the same point by prefixing your pattern with #{handle}:"
      puts handle_error(erorr)
      @check_handles = false
    else
      log_word = "Error:"
      log("results",e.message)
      puts handle_error(e.message)
    end
    log("run",log_word + ": @#{handle}")
  end
end
def check_handle ( handle ) begin if handle . length < 5 handle_error ( "!ts!" , "#{handle}" ) @twitter = false elsif handle . length > 15 handle_error ( "!tl!" , "#{handle}" ) @twitter = false else @twitter = @client . user ( handle ) end if @twitter @taken_handles << handle @taken_count += 1 else @invalid_handles << handle log_word = "Invalid" end rescue Exception => e if e . message == "User not found." @available_count += 1 @available_handles << handle log_word = "Available" elsif e . message == "User has been suspended." @suspended_count += 1 @suspended_handles << handle log_word = "Suspended" elsif e . message == "Rate limit exceeded" log_word = "Rate Limited" erorr = "RATE LIMIT EXCEEDED\nTwitter has stopped you checking any further user names for a little while. \nWhen this happens it's best to rerty again in 15 minutes or so. You were up to @#{handle}, you can restart your check from the same point by prefixing your pattern with #{handle}:" puts handle_error ( erorr ) @check_handles = false else log_word = "Error:" log ( "results" , e . message ) puts handle_error ( e . message ) end log ( "run" , log_word + ": @#{handle}" ) end end
We call this function to check if a handle is available
We call this function to check if a handle is available
handle
<not_specific>