<commit_before>module VetBot
  class << self
    def handle_message(data)
      puts data unless ENV["RACK_ENV"] == "test"

      return unless spoken_to?(data)

      VetBot.typing channel: data.channel
      message = select_response(data)

      VetBot.message(channel: data.channel, text: message) if message
    end

    private

    def spoken_to?(data)
      data.text.match(VetBot.id) || direct_message?(channel: data.channel)
    end

    def direct_message?(channel:)
      direct_messages.include? channel
    end

    def direct_messages
      client.ims&.keys || []
    end

    def select_response(data)
      case data.text
      when /hi|hello|hey/ then
        "Hi <@#{data.user}>!"
      else
        "Sorry, I'm not smart enough yet"
      end
    end
  end
end<commit_msg>Give VetBot a idk response<commit_after>module VetBot
  class << self
    def handle_message(data)
      puts data unless ENV["RACK_ENV"] == "test"

      return unless spoken_to?(data)

      VetBot.typing channel: data.channel
      message = select_response(data)

      VetBot.message(channel: data.channel, text: message) if message
    end

    private

    def spoken_to?(data)
      data.text&.match(VetBot.id) || direct_message?(channel: data.channel)
    end

    def direct_message?(channel:)
      direct_messages.include? channel
    end

    def direct_messages
      client.ims&.keys || []
    end

    def select_response(data)
      case data.text
      when /ruby/i then
        VetBot.formatted_resources "ruby"
      when /hi|hello|hey/i then
        "Hi <@#{data.user}>!"
      else
        idk_response
      end
    end

    def idk_response
      "Sorry, I'm not smart enough yet to answer that. " \
        "Maybe post in the <##{channel('general')}|general> " \
        "or <##{channel('web-dev')}|web-dev> channel " \
        "so a human can assist."
    end

    def channels
      client.channels
    end

    # Returns a channel id.  Returns nil if channel doesn't exist.
    def channel(name)
      obj = channels.select do |_k, hsh|
        hsh["name"].to_s.casecmp(name.to_s).zero?
      end

      obj&.keys&.first
    end
  end
end
{'fraction_non_alphanumeric': 0.1056533827618165, 'fraction_numerical': 0.0, 'mean_word_length': 2.3524844720496896, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '3181865', 'n_tokens_mistral': 705, 'n_tokens_neox': 688, 'n_words': 177}