<commit_before>module Chatterbot
  
  #
  # routines for connecting to Twitter and validating the bot
  module Client

    # the Twitter client
    attr_accessor :client

    # track the access token so we can get screen name when
    # registering new bots
    attr_accessor :access_token

    #
    # default options when querying twitter -- this could be extended
    # with a language, etc.
    def default_opts
      return {} if since_id <= 0
      {
        :since_id => since_id,
        :result_type => "recent"
      }
    end
    

    #
    # Initialize the Twitter client
    def init_client
      @client ||= TwitterOAuth::Client.new(client_params)
    end
    
    #
    # Re-initialize with Twitter, handy during the auth process
    def reset_client
      @client = nil
      init_client
    end
    
    #
    # Call this before doing anything that requires an authorized Twitter
    # connection.
    def require_login(do_update_config=true)
      init_client
      login(do_update_config)
    end

    #
    # print out a message about getting a PIN from twitter, then output
    # the URL the user needs to visit to authorize
    #
    def get_oauth_verifier(request_token)
      puts "Please go to the following URL and authorize the bot.\n"        
      puts "#{request_token.authorize_url}\n"

      puts "Paste your PIN and hit enter when you have completed authorization."
      STDIN.readline.chomp
    rescue Interrupt => e

    end

    #
    # Ask the user to get an API key from Twitter.
    def get_api_key
      puts "****************************************"
      puts "****************************************"
      puts "****        API SETUP TIME!         ****"
      puts "****************************************"
      puts "****************************************"      
      
      puts "Hey, looks like you need to get an API key from Twitter before you can get started."
      puts "Please go to this URL: https://twitter.com/apps/new"

      puts "\nChoose 'Client' as the app type."
      puts "Choose 'Read & Write' access."

      print "\n\n\nPaste the 'Consumer Key' here: "
      STDOUT.flush
      config[:consumer_key] = STDIN.readline.chomp

      print "Paste the 'Consumer Secret' here: "
      STDOUT.flush<commit_msg>The message Choose 'Client ...' is removed since the new twitter app creation form removed it<commit_after>module Chatterbot
  
  #
  # routines for connecting to Twitter and validating the bot
  module Client

    # the Twitter client
    attr_accessor :client

    # track the access token so we can get screen name when
    # registering new bots
    attr_accessor :access_token

    #
    # default options when querying twitter -- this could be extended
    # with a language, etc.
    def default_opts
      return {} if since_id <= 0
      {
        :since_id => since_id,
        :result_type => "recent"
      }
    end
    

    #
    # Initialize the Twitter client
    def init_client
      @client ||= TwitterOAuth::Client.new(client_params)
    end
    
    #
    # Re-initialize with Twitter, handy during the auth process
    def reset_client
      @client = nil
      init_client
    end
    
    #
    # Call this before doing anything that requires an authorized Twitter
    # connection.
    def require_login(do_update_config=true)
      init_client
      login(do_update_config)
    end

    #
    # print out a message about getting a PIN from twitter, then output
    # the URL the user needs to visit to authorize
    #
    def get_oauth_verifier(request_token)
      puts "Please go to the following URL and authorize the bot.\n"        
      puts "#{request_token.authorize_url}\n"

      puts "Paste your PIN and hit enter when you have completed authorization."
      STDIN.readline.chomp
    rescue Interrupt => e

    end

    #
    # Ask the user to get an API key from Twitter.
    def get_api_key
      puts "****************************************"
      puts "****************************************"
      puts "****        API SETUP TIME!         ****"
      puts "****************************************"
      puts "****************************************"      
      
      puts "Hey, looks like you need to get an API key from Twitter before you can get started."
      puts "Please go to this URL: https://twitter.com/apps/new"

      print "\n\nPaste the 'Consumer Key' here: "
      STDOUT.flush
      config[:consumer_key] = STDIN.readline.chomp

      print "Paste the 'Consumer Secret' here: "
      STDOUT.flush
{'fraction_non_alphanumeric': 0.1350637923449186, 'fraction_numerical': 0.0004399472063352398, 'mean_word_length': 2.4316981132075473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7286127', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1225, 'n_words': 447}