<commit_before>module Lita
  module Handlers
    class HipchatExtensions < Handler
      # Fetches and persists info from the Hipchat API
      class Fetcher < Base
        on :connected,   :sync
        on :synchronize, :sync_user

        route /^hc\s+show\s+(@\w+)/, :show, command: true

        # TODO: Document me
        def show(response)
          mention_name = response.args[1].gsub "@", ""
          response.reply t("fetcher.show.usage") and return unless mention_name
          user         = Lita::User.fuzzy_find mention_name
          response.reply user.metadata.inspect
        end

        # Discovers and synchronizes additional Hipchat info for each user
        def sync(payload={})
          fetch_users.each { |json| robot.trigger :synchronize, json }
        end

        # Synchronizes each user complementing Lita::User metadata with API stuff.
        def sync_user(json)
          log.info "Checking if #{json["mention_name"]} needs synchronization..."
          user = Lita::User.fuzzy_find(json["mention_name"])
          return if user.metadata.has_key?("timezone")
          log.info "Synchronizing #{user.name}"
          json.merge! fetch_user(json["id"])
          log.debug user.metadata.merge! json
          log.info  user.save
        end

      end
      Lita.register_handler(Fetcher)
    end
  end
end<commit_msg>always fetch latest info on boot, help text for hc show @user<commit_after>module Lita
  module Handlers
    class HipchatExtensions < Handler
      # Fetches and persists info from the Hipchat API
      class Fetcher < Base
        on :connected,   :sync
        on :synchronize, :sync_user

        route /^hc\s+show\s+(@\w+)/, :show, command: true, help: { 
          "hc show @MentionName" => "Replies with a user's Hipchat API info"
        }

        # Shows Hipchat API information about a given user
        def show(response)
          mention_name = response.args[1].gsub "@", ""
          response.reply t("fetcher.show.usage") and return unless mention_name
          user         = Lita::User.fuzzy_find mention_name
          response.reply user.metadata.inspect
        end

        # Discovers and synchronizes additional Hipchat info for each user
        def sync(payload={})
          fetch_users.each { |json| robot.trigger :synchronize, json }
        end

        # Synchronizes each user complementing Lita::User metadata with API stuff.
        def sync_user(json)
          log.info "Checking if #{json["mention_name"]} needs synchronization..."
          user = Lita::User.fuzzy_find(json["mention_name"])
          log.info "Synchronizing #{user.name}"
          json.merge! fetch_user(json["id"])
          log.debug user.metadata.merge! json
          log.info  user.save
        end

      end
      Lita.register_handler(Fetcher)
    end
  end
end
{'fraction_non_alphanumeric': 0.0945326278659612, 'fraction_numerical': 0.0007054673721340388, 'mean_word_length': 2.271049596309112, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '5099731', 'n_tokens_mistral': 831, 'n_tokens_neox': 805, 'n_words': 229}