<commit_before>class Bot::Plugin::Entitleri < Bot::Plugin
  require 'nokogiri'
  require 'open-uri'

  def initialize(bot)
    @s = {
      trigger: { entitleri: [
        :call, 0,
        'Entitle Reverse Image harnesses the power of Google cloud technology ' +
        'and the information superhighway botnet to tell you what an image link is.'
      ]},
      subscribe: true,
      filters: ['http.*png', 'http.*gif', 'http.*jpg', 'http.*jpeg', 'http.*bmp'],
      timeout: 10,
      google_query: 'http://www.google.com/searchbyimage?&image_url=',
      guess_selector: '.qb-bmqc',
      user_agent: 'Mozilla/5.0 (Windows NT 6.0; rv:20.0) Gecko/20100101 Firefox/20.0'
    }
    super(bot)
  end

  def call(m)
    check_filter(m)
  end

  def receive(m)
    check_filter(m)
  end

  def check_filter(m)
    line = String.new(m.text)

    @s[:filters].each do |regex|
      results = line.scan(Regexp.new(regex))

      unless results.empty?
        results.each do |result|
          Thread.new do
            timeout(@s[:timeout]) do
              guess = get_guess(result)
              m.reply(guess) unless guess.nil?
            end
          end

          # Prevent double-matching
          line.gsub!(result, '')
        end<commit_msg>EntitleRI: Update best guess selector<commit_after>class Bot::Plugin::Entitleri < Bot::Plugin
  require 'nokogiri'
  require 'open-uri'

  def initialize(bot)
    @s = {
      trigger: { entitleri: [
        :call, 0,
        'Entitle Reverse Image harnesses the power of Google cloud technology ' +
        'and the information superhighway botnet to tell you what an image link is.'
      ]},
      subscribe: true,
      filters: ['http.*png', 'http.*gif', 'http.*jpg', 'http.*jpeg', 'http.*bmp'],
      timeout: 10,
      google_query: 'http://www.google.com/searchbyimage?&image_url=',
      guess_selector: '._hUb',
      user_agent: 'Mozilla/5.0 (Windows NT 6.0; rv:20.0) Gecko/20100101 Firefox/20.0'
    }
    super(bot)
  end

  def call(m)
    check_filter(m)
  end

  def receive(m)
    check_filter(m)
  end

  def check_filter(m)
    line = String.new(m.text)

    @s[:filters].each do |regex|
      results = line.scan(Regexp.new(regex))

      unless results.empty?
        results.each do |result|
          Thread.new do
            timeout(@s[:timeout]) do
              guess = get_guess(result)
              m.reply(guess) unless guess.nil?
            end
          end

          # Prevent double-matching
          line.gsub!(result, '')
        end
{'fraction_non_alphanumeric': 0.12831683168316832, 'fraction_numerical': 0.016633663366336635, 'mean_word_length': 2.2301790281329925, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '801031', 'n_tokens_mistral': 874, 'n_tokens_neox': 822, 'n_words': 199}