<commit_before>require 'hipchat'
require 'redis'
require 'Redditkit'

$room = ENV['ROOM']
$hipchat_api_token = ENV['HIPCHAT_TOKEN']

class Gifs
  def self.run
    hipchat = HipChat::Client.new($hipchat_api_token, api_version: 'v2')
    redis = Redis.new
    links = RedditKit.links('gifs', category: 'hot')

    links.each do |l|
      if redis.get(l.id).nil? && l.score >= 2500 && l.url[-4..-1] == '.gif'
        redis.set l.id, 'check'

        text = "Gif:<br><img src=\"#{l.url}\">"
        hipchat[$room].send('Gifs', text, message_format: 'html')
        abort
      end
    end
  end
end<commit_msg>Check if redis is inside heroku<commit_after>require 'hipchat'
require 'redis'
require 'Redditkit'

$room = ENV['ROOM']
$hipchat_api_token = ENV['HIPCHAT_TOKEN']

class Gifs
  def self.run
    hipchat = HipChat::Client.new($hipchat_api_token, api_version: 'v2')
    if ENV['REDISTOGO_URL']
      redis = Redis.new(url: ENV['REDISTOGO_URL'])
    else
      redis = Redis.new
    end
    links = RedditKit.links('gifs', category: 'hot')

    links.each do |l|
      if redis.get(l.id).nil? && l.score >= 2500 && l.url[-4..-1] == '.gif'
        redis.set l.id, 'check'

        text = "Gif:<br><img src=\"#{l.url}\">"
        hipchat[$room].send('Gifs', text, message_format: 'html')
        abort
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.17243975903614459, 'fraction_numerical': 0.010542168674698794, 'mean_word_length': 2.967164179104478, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '6896032', 'n_tokens_mistral': 527, 'n_tokens_neox': 516, 'n_words': 107}