```coffeescript
# Description:
#   Domain availability via DNSimple.
#
# Dependencies:
#   None
#
# Configuration:
#   DNSIMPLE_USERNAME
#   DNSIMPLE_PASSWORD
#
# Commands:
#   check domain <domainname> - returns whether a domain is available
#
# Author:
#   jonmagic

module.exports = (robot) ->
  robot.hear /check domain (.*)/i, (msg) ->
    domain = escape(msg.match[1])
    user = process.env.DNSIMPLE_USERNAME
    pass = process.env.DNSIMPLE_PASSWORD
    auth = 'Basic ' + new Buffer(user + ':' + pass).toString('base64');
    msg.http("https://api.dnsimple.com/v1/domains/#{domain}/check")
      .headers(Authorization: auth, Accept: 'application/json')
      .get() (err, res, body) ->
        switch res.statusCode
          when 200
            msg.send "Sorry, #{domain} is not available."
          when 404
            msg.send "Cybersquat that shit!"
          when 401
            msg.send "You need to authenticate by setting the DNSIMPLE_USERNAME & DNSIMPLE_PASSWORD environment variables"
          else
            msg.send "Unable to process your request and we're not sure why :("
```

Use the API token instead of the plain password
user
```coffeescript
# Description:
#   Domain availability via DNSimple.
#
# Dependencies:
#   None
#
# Configuration:
#   DNSIMPLE_USERNAME
#   DNSIMPLE_API_TOKEN
#
# Commands:
#   check domain <domainname> - returns whether a domain is available
#
# Author:
#   jonmagic

dnsimpleToken = new Buffer(process.env.DNSIMPLE_USERNAME + ':' + process.env.DNSIMPLE_API_TOKEN).toString('base64');

module.exports = (robot) ->
  robot.hear /check domain (.*)/i, (msg) ->
    domain = escape(msg.match[1])
    msg.http("https://api.dnsimple.com/v1/domains/#{domain}/check")
      .headers("X-DNSimple-Token": dnsimpleToken, Accept: 'application/json')
      .get() (err, res, body) ->
        switch res.statusCode
          when 200
            msg.send "Sorry, #{domain} is not available."
          when 404
            msg.send "Cybersquat that shit!"
          when 401
            msg.send "You need to authenticate by setting the DNSIMPLE_USERNAME & DNSIMPLE_API_TOKEN environment variables"
          else
            msg.send "Unable to process your request and we're not sure why :("
```
assistant