 
 querystring = require('querystring')
 _ = require('lodash')
-request = require('request')
+Promise = require('bluebird')
+request = Promise.promisify(require('request'))
 LANGUAGES = require('./data/languages.json')
 TRANSLATE_URI = 'https://translate.yandex.net/api/v1.5/tr.json/translate'
 API_KEY = process.env.YANDEX_TRANSLATE_API_KEY
 LOCAL_LANGUAGE = process.env.HUBOT_GARBLE_LOCAL_LANGUAGE || 'en'
-SHOW_TRANSLATION_PATH = process.env.HUBOT_GARBLE_TRANSLATION_PATH_LOG || true
+DISPLAY_TRANSLATION_PATH = process.env.HUBOT_GARBLE_TRANSLATION_PATH_LOG || true
 DEFAULT_GARBLE_AMOUNT = 5
 
 # get full language name from a language code

# an array of languages to translate text through
# wraps LOCAL_LANGUAGE around random assortment of languages
getTranslationPath = (garbleAmount) ->
  _.chain(getRandomLanguages(getLanguageCodes(), garbleAmount))
    .unshift(LOCAL_LANGUAGE)
    .push(LOCAL_LANGUAGE)
    .value()

# a string that indicates what "translation path" the text was passed through
getTranslationPathLog = (languageCodes) ->
  languageNames = _.map languageCodes, (code) -> getLanguageName(code)
  "translation path: #{languageNames.join(' → ')}"

# a URI that satisfies the Yandex API requirements

    text: text
  return "#{TRANSLATE_URI}?#{querystring.stringify(opts)}"

# returns request promise
getTranslation = (fromLang, toLang, text) ->
  request getRequestURI(fromLang, toLang, text)

# a string of translated text
parseResponse = (str) ->
  try
    return JSON.parse(str).text[0]
  catch e
    return str

module.exports = (robot) ->

