 Redis = require 'redis'
 
 module.exports = (robot) ->
-  # Configure redis the same way that redis-brain does.
-  info = Url.parse process.env.REDISTOGO_URL or
-    process.env.REDISCLOUD_URL or
-    process.env.BOXEN_REDIS_URL or
-    'redis://localhost:6379'
-  client = Redis.createClient(info.port, info.hostname)
-  client.auth info.auth.split(":")[1] if info.auth
-
-  buffer = new PantsBuffer(client)
+  buffer = new PantsBuffer()
 
   # We listen to everything.
   # Everything.

    console.log "=> Trimming #{@key()} 0 #{end} (Now: #{Date.now()})"
    @storage.zremrangebyscore @key(), 0, end, (err, response) =>
      return console.log "WARNING: Failed to trim '#{@key()}': #{err}" if err

      msg.message.text.trim()
    )

  # Ask for what currently serves as "output"
  robot.respond /ayp(\s+(me)?)?\s*$/i, (msg) ->
    msg.reply "HOLD YOUR FUCKING HORSES"

class PantsBuffer
  # The zset that stores the buffer of logs
  key: -> "#{@options.prefix}:buffer"

  # Store and timestamp `who` saying `what`.
  # Also trims the set with `@trim` to the configured
  # length
  store: (who, what) ->
    do @trim
    stamp = Date.now()
